Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3701886imm; Tue, 17 Jul 2018 08:57:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdt+xhzQo82St2IV7LC2WjLFNXimec3NstErpix1avl9nhDgg2RIncIVrfmym5YdsVA/Dan X-Received: by 2002:aa7:8118:: with SMTP id b24-v6mr1272066pfi.78.1531843057768; Tue, 17 Jul 2018 08:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531843057; cv=none; d=google.com; s=arc-20160816; b=qKKJF9eTBa02N66vNNqK+w9iefF7xGQDdZabU0rWEkt/9URBJvR4pQC/lv474579gl MrsDYiuephAbUYBr6m57YYmmXgJptvkK4bquQDVw48y91gpn7xnM31HKHoOPCBAsCy5y bIXWdgNpDwnLIW1oI5uqAENhm1lUCy8GmfjFTHMTEU+cc2/tgXUVrqv6FOk7hjpMBnvw 1dtsSC1AWxFfrE8dkwBT7p/l+JQQSYQg5SFvnt3UnFD+aqZbkWeTC/kS62hYC3arMsX1 niZdmIuZG1RIeZXjpPgcdwqEYoYHdZE31GetJW7C/nEGU2KENpI4uSpw+fVla2aP7yk0 lZOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=oYKYXlpiqb7TmeZ/PlC4jn7HnrD+6jCfnYm+mfYxo1M=; b=hS9MnuQ+k5WhMTUM+lBrDFoaAqGTRQnCYzrUb+lFc7FMHgIdt9Tbzw7rFDEsXefKwf 1RGobvnUztsK0a7/Nmq82fmt3vz7XJSDuD/9N6XRmbyI0bomxk+piEqdQ6XDkXgWDya0 8VgNX7K4QZAG6H8JGf/rDwaDo73x9xf+J9QFsr8zUuQwiEE1x7ugXc6rPHOZy86I8P6F 3vh7F/f1BoWJj0+1BYrRS/y02huNzURkRMSai3Vx1VQfYPHqg6qy3yUawVS2dzd/bB7v AIEGU9p3W2iVWh5pQF/DZAgN8Ens+/1YExf18Uyfwz36IZDqLioHrLAQlzzw2QIf3nns KIqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a74-v6si1150933pfe.301.2018.07.17.08.57.22; Tue, 17 Jul 2018 08:57:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730043AbeGQQ3v (ORCPT + 99 others); Tue, 17 Jul 2018 12:29:51 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55935 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729989AbeGQQ3v (ORCPT ); Tue, 17 Jul 2018 12:29:51 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1ffSL0-0003xo-Fj; Tue, 17 Jul 2018 17:56:30 +0200 Date: Tue, 17 Jul 2018 17:56:30 +0200 From: Sebastian Andrzej Siewior To: Andrew Morton Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , linux-mm@kvack.org, Jens Axboe Subject: Re: [PATCH 3/6] bdi: Use refcount_t for reference counting instead atomic_t Message-ID: <20180717155630.5propcebpubol6x3@linutronix.de> References: <20180703200141.28415-1-bigeasy@linutronix.de> <20180703200141.28415-4-bigeasy@linutronix.de> <20180716155716.1f7ac43d211133a8cb476637@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180716155716.1f7ac43d211133a8cb476637@linux-foundation.org> User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-07-16 15:57:16 [-0700], Andrew Morton wrote: > > --- a/mm/backing-dev.c > > +++ b/mm/backing-dev.c > > @@ -438,10 +438,10 @@ wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp) > > if (new_congested) { > > /* !found and storage for new one already allocated, insert */ > > congested = new_congested; > > - new_congested = NULL; > > rb_link_node(&congested->rb_node, parent, node); > > rb_insert_color(&congested->rb_node, &bdi->cgwb_congested_tree); > > - goto found; > > + spin_unlock_irqrestore(&cgwb_lock, flags); > > + return congested; > > } > > > > spin_unlock_irqrestore(&cgwb_lock, flags); > > @@ -451,13 +451,13 @@ wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp) > > if (!new_congested) > > return NULL; > > > > - atomic_set(&new_congested->refcnt, 0); > > + refcount_set(&new_congested->refcnt, 1); > > new_congested->__bdi = bdi; > > new_congested->blkcg_id = blkcg_id; > > goto retry; > > > > found: > > - atomic_inc(&congested->refcnt); > > + refcount_inc(&congested->refcnt); > > spin_unlock_irqrestore(&cgwb_lock, flags); > > kfree(new_congested); > > return congested; > > > > ... > > > > I'm not sure that the restructuring of wb_congested_get_create() was > desirable and it does make the patch harder to review. But it looks > OK to me. By `restructuring' you mean the addition of return statement instead using the goto label in the first hunk? If so, then you would have refcount_set(&new_congested->refcnt, 0); refcount_inc(&congested->refcnt); which is a 0 -> 1 transition and is forbidden by refcount_t. So I had to avoid this one. Thank you applying the patches! You applied the bdi and userns switch from atomic_t to refcount_t. There were also the patches [PATCH 4/6] bdi: Use irqsave variant of refcount_dec_and_lock() [PATCH 6/6] userns: Use irqsave variant of refcount_dec_and_lock() in the series which make use the irqsave version of refcount_dec_and_lock(). Did you miss them by chance or skipped them on purpose? Sebastian