mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Christopher Lameter <cl@linux.com>,
	Dennis Zhou <dennis@kernel.org>,
	linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v2] percpu-refcount: Use normal instead of RCU-sched"
Date: Mon, 11 Nov 2019 05:38:10 -0800	[thread overview]
Message-ID: <20191111133810.GL2865@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20191111104403.5gna4pyg25v4mdin@linutronix.de>

On Mon, Nov 11, 2019 at 11:44:03AM +0100, Sebastian Andrzej Siewior wrote:
> 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.

Sebastian is quite correct, rcu_read_lock() definitely does not imply
preempt_disable() when CONFIG_PREEMPT=y.  So the splat below is expected
behavior, and not just on x86.

							Thanx, Paul

> > 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

  reply	other threads:[~2019-11-11 13:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02 11:22 [PATCH] " Sebastian Andrzej Siewior
2019-10-02 15:08 ` Paul E. McKenney
2019-10-02 15:17   ` Sebastian Andrzej Siewior
2019-11-07  9:13 ` Sebastian Andrzej Siewior
2019-11-07 16:17   ` Dennis Zhou
2019-11-07 16:28     ` Sebastian Andrzej Siewior
2019-11-07 16:55       ` Dennis Zhou
2019-11-07 17:24         ` Sebastian Andrzej Siewior
2019-11-07 17:36           ` Dennis Zhou
2019-11-08 17:35             ` [PATCH v2] " Sebastian Andrzej Siewior
2019-11-08 18:17               ` Christopher Lameter
2019-11-11 10:44                 ` Sebastian Andrzej Siewior
2019-11-11 13:38                   ` Paul E. McKenney [this message]
2019-11-17  4:11               ` Dennis Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191111133810.GL2865@paulmck-ThinkPad-P72 \
    --to=paulmck@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®