From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Josh Triplett <josh@joshtriplett.org>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] srcu: use cpu_online() instead custom check
Date: Thu, 28 Sep 2017 18:09:57 -0700 [thread overview]
Message-ID: <20170929010957.GV3521@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170928160207.ln2t3nlnfnkwqusg@linutronix.de>
On Thu, Sep 28, 2017 at 06:02:08PM +0200, Sebastian Andrzej Siewior wrote:
> On 2017-09-22 11:43:14 [-0700], Paul E. McKenney wrote:
> > On Fri, Sep 22, 2017 at 05:28:04PM +0200, Sebastian Andrzej Siewior wrote:
> > > The current check via srcu_online is slightly racy because after looking
> > > at srcu_online there could be an interrupt that interrupted us long
> > > enough until the CPU we checked against went offline.
> >
> > But in that case, wouldn't the interrupt block the synchronize_sched()
> > later in the offline sequence?
>
> What I meant is:
>
> CPU0 CPU1
> preempt_disable();
> if (READ_ONCE(per_cpu(srcu_online, 1)))
> *interrupt*
> WRITE_ONCE(per_cpu(srcu_online, cpu), false);
> and CPU is offnline
>
> ret = queue_delayed_work_on(1, wq, dwork, delay);
>
> is this possible or are there a safety belt for this?
I don't see anything that would prevent this. It is unlikely, but not
so unlikely that it should not be fixed.
> > More to the point, are you actually seeing this failure, or is this
> > a theoretical bug?
>
> I need to get rid of the preempt_disable() section in which
> queue_delayed_work*() is invoked for RT.
OK, but please see below...
> > > An alternative would be to hold the hotplug rwsem (so the CPUs don't
> > > change their state) and then check based on cpu_online() if we queue it
> > > on a specific CPU or not. queue_work_on() itself can handle if something
> > > is enqueued on an offline CPU but a timer which is enqueued on an offline
> > > CPU won't fire until the CPU is back online.
> > >
> > > I am not sure if the removal in rcu_init() is okay or not. I assume that
> > > SRCU won't enqueue a work item before SRCU is up and ready.
> >
> > Another alternative would be to disable preemption across the check and
> > the call to queue_delayed_work_on().
>
> you need to ensure the *other* CPU won't in the middle of checking its
> status. preempt_disable() won't do this on the other CPU.
Agreed.
> > Yet another alternative would be to have an SRCU-specific per-CPU lock
> > that is acquired across the setting and clearing of srcu_online,
> > and also across the check and the call to queue_delayed_work_on().
> > This last would be more consistent with a desire to remove the
> > synchronize_sched() from the offline sequence.
> >
> > Or am I missing something here?
> The perCPU lock should work. And cpus_read_lock() is basically that
> except that srcu_online_cpu() is not holding it but the CPU-HP code.
>
> So you want keep things as-is or do you prefer a per-CPU rwsem instead?
The per-CPU rwsem seems like a reasonable approach. Except for the
call_srcu() path, given that call_srcu()'s caller might have preemption
(or even interrupts) disabled.
Thoughts?
Thanx, Paul
prev parent reply other threads:[~2017-09-29 1:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 15:28 [PATCH 1/3] srcu: use cpu_online() instead custom check Sebastian Andrzej Siewior
2017-09-22 15:28 ` [PATCH 2/3] srcu: queue work without holding the lock Sebastian Andrzej Siewior
2017-09-22 18:46 ` Paul E. McKenney
2017-09-28 16:03 ` Sebastian Andrzej Siewior
2017-09-29 1:10 ` Paul E. McKenney
2017-10-10 21:43 ` Paul E. McKenney
2017-10-11 16:40 ` Sebastian Andrzej Siewior
2017-10-11 16:46 ` Paul E. McKenney
2017-10-12 8:53 ` Sebastian Andrzej Siewior
2017-10-12 18:24 ` Paul E. McKenney
2017-10-13 7:08 ` Sebastian Andrzej Siewior
2017-09-22 15:28 ` [PATCH 3/3] rcu/segcblist: include rcupdate.h Sebastian Andrzej Siewior
2017-09-22 18:47 ` Paul E. McKenney
2017-09-22 18:43 ` [PATCH 1/3] srcu: use cpu_online() instead custom check Paul E. McKenney
2017-09-28 16:02 ` Sebastian Andrzej Siewior
2017-09-29 1:09 ` Paul E. McKenney [this message]
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=20170929010957.GV3521@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=bigeasy@linutronix.de \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.