Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6032487ybx; Mon, 11 Nov 2019 02:45:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzjSZuE+bsQ9dR9H+3tz/j4GgmAWdLxfT1Il/2lfYqyump2joUkyVVPXujiDjbWTHNnHu+8 X-Received: by 2002:a17:906:32d3:: with SMTP id k19mr2802320ejk.75.1573469148743; Mon, 11 Nov 2019 02:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573469148; cv=none; d=google.com; s=arc-20160816; b=k4Ps1ez1tnIH9r/QaMriLK8QvufV7W79xKD8uEymUx0ZVrvZItZ00kmLXbVSG08xhA F0mbjyYT9fML9ZFHH0df7WpRdxTgnZgkdz1vtnvEiSxUHuWnM5CwCYHs1brmL8OuiZEy h6EnklLcL+9Y0ochNudKcsWycjx4XFwpmQHeb84L3+B5AaPLjIOCf/AfiZjvkSsQPyK4 hs190vabgc6+tEMcu0ghsbP4HC/oBTwHGwH013Ve+OHhsW0xmBBq+skq6MoJsKonCxJj URC7/Bs3Ts1sezXRfjdw2byqJbay7lyLfmHmF56JmIapoQRQI+o9oVhzTu7CDylKXngE gWaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hWMDylpTfPr4DiHR3v7Xs2XZ9lBp5g1BHHmz5myMinc=; b=daerK3D/sXqU+AkrqaImSvNlaK2rwW2fj74Rzk4/mzaQl+P5UXSzL0PFg5eQYsMYna YfuCHdy0Ouuqg4569a0miuUlqKXr5xoOpCDrZbO8cmS/yENvOl0ioVNELbbJWBDnAJmX iUSPsHnK4KUz26Wn7nYJzcluAni3uy0hXoVPCozF0taFMD2EKCuTV42s7rIM3Tkv88VS lyXxVhtPWaAQRa6+llNAlZeSHvhnhpbUM5Z9oXX6Ql2JIPamJUu9Ciyp8xwQDEbFUxD7 ZVRQe2Z2JroWF/XCUKKme8kwxygcf4xgPb71NIQn+BXZDI7iYdccNGWN8TZ2jSrIjstw zl6w== 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 o24si10927168edc.342.2019.11.11.02.45.25; Mon, 11 Nov 2019 02:45:48 -0800 (PST) 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 S1726902AbfKKKoG (ORCPT + 99 others); Mon, 11 Nov 2019 05:44:06 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:56151 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726808AbfKKKoG (ORCPT ); Mon, 11 Nov 2019 05:44:06 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1iU7Ax-0004ZX-JU; Mon, 11 Nov 2019 11:44:03 +0100 Date: Mon, 11 Nov 2019 11:44:03 +0100 From: Sebastian Andrzej Siewior To: Christopher Lameter Cc: Dennis Zhou , linux-kernel@vger.kernel.org, Tejun Heo , Thomas Gleixner , Peter Zijlstra , "Paul E. McKenney" Subject: Re: [PATCH v2] percpu-refcount: Use normal instead of RCU-sched" Message-ID: <20191111104403.5gna4pyg25v4mdin@linutronix.de> References: <20191002112252.ro7wpdylqlrsbamc@linutronix.de> <20191107091319.6zf5tmdi54amtann@linutronix.de> <20191107161749.GA93945@dennisz-mbp> <20191107162842.2qgd3db2cjmmsxeh@linutronix.de> <20191107165519.GA99408@dennisz-mbp> <20191107172434.ylz4hyxw4rbmhre2@linutronix.de> <20191107173653.GA1242@dennisz-mbp> <20191108173553.lxsdic6wa4y3ifsr@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-08 18:17:47 [+0000], Christopher Lameter wrote: > On Fri, 8 Nov 2019, Sebastian Andrzej Siewior wrote: > > > diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h > > index 7aef0abc194a2..390031e816dcd 100644 > > --- a/include/linux/percpu-refcount.h > > +++ b/include/linux/percpu-refcount.h > > @@ -186,14 +186,14 @@ static inline void percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr) > > { > > unsigned long __percpu *percpu_count; > > > > - rcu_read_lock_sched(); > > + rcu_read_lock(); > > > > if (__ref_is_percpu(ref, &percpu_count)) > > this_cpu_add(*percpu_count, nr); > > You can use > > __this_cpu_add() > > instead since rcu_read_lock implies preempt disable. Paul may correct me but rcu_read_lock() does not imply preempt_disable(). rcu_read_lock() does preempt_disable() on preemption models other than "Low-Latency Desktop". You can be preempted in a RCU-read section. > This will not change the code for x86 but other platforms that do not use > atomic operation here will be able to avoid including to code to disable > preempt for the per cpu operations. x86 triggers this warning with the suggested change: | BUG: using __this_cpu_add() in preemptible [00000000] code: login/2370 | caller is blk_mq_get_request+0x74/0x4c0 | CPU: 0 PID: 2370 Comm: login Not tainted 5.4.0-rc7+ #82 | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.12.0-1 04/01/2014 | Call Trace: | dump_stack+0x7a/0xaa | __this_cpu_preempt_check.cold+0x49/0x4e | blk_mq_get_request+0x74/0x4c0 | blk_mq_make_request+0x111/0x890 | generic_make_request+0xd3/0x3f0 | submit_bio+0x42/0x140 | submit_bh_wbc.isra.0+0x13f/0x170 | ll_rw_block+0xa0/0xb0 | __breadahead+0x3f/0x70 | __ext4_get_inode_loc+0x40a/0x520 | __ext4_iget+0x10a/0xcf0 | ext4_lookup+0x106/0x1f0 | lookup_open+0x267/0x8e0 | path_openat+0x7c8/0xcb0 | do_filp_open+0x8c/0x100 | do_sys_open+0x17a/0x230 | __x64_sys_openat+0x1b/0x20 | do_syscall_64+0x5a/0x230 | entry_SYSCALL_64_after_hwframe+0x49/0xbe > Same is valid for all other per cpu operations in the patch. Sebastian