From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
netfilter-devel@vger.kernel.org, mingo@elte.hu,
akpm@linux-foundation.org, torvalds@linux-foundation.org,
davem@davemloft.net, dada1@cosmosbay.com, zbr@ioremap.net,
jeff.chua.linux@gmail.com, paulus@samba.org, jengelh@medozas.de,
r000n@r000n.net, benh@kernel.crashing.org,
mathieu.desnoyers@polymtl.ca
Subject: Re: [PATCH RFC] v7 expedited "big hammer" RCU grace periods
Date: Thu, 28 May 2009 17:08:48 -0700 [thread overview]
Message-ID: <20090529000848.GE6757@linux.vnet.ibm.com> (raw)
In-Reply-To: <4A1CD17F.1000208@cn.fujitsu.com>
On Wed, May 27, 2009 at 01:37:03PM +0800, Lai Jiangshan wrote:
> Paul E. McKenney wrote:
> > OK, good point! I do need to think about this.
> >
> > In the meantime, where do you see a need to run
> > synchronize_sched_expedited() from within a hotplug CPU notifier?
> >
> > Thanx, Paul
> >
>
> I don't worry about synchronize_sched_expedited() called
> from within a hotplug CPU notifier:
>
> 1st synchronize_sched_expedited() is newly, nobody calls it before current.
> 2nd get_online_cpus() will not cause DEADLOCK in CPU notifier:
> get_online_cpus() finds itself owns the cpu_hotplug.lock, it will
> not take it again.
>
> I worry DEADLOCK like this:(ABBA DEADLOCK)
Good point -- you had in fact mentioned this earlier.
> > get_online_cpus() is a large lock, a lot's of lock in kernel is required
> > after cpu_hotplug.lock.
> >
> > _cpu_down()
> > cpu_hotplug_begin()
> > mutex_lock(&cpu_hotplug.lock)
> > __raw_notifier_call_chain(CPU_DOWN_PREPARE)
> > Lock a-kernel-lock.
> >
> > It means when we have held a-kernel-lock, we can not call
> > synchronize_sched_expedited(). get_online_cpus() narrows
> > synchronize_sched_expedited()'s usages.
>
> One thread calls _cpu_down() which do "mutex_lock(&cpu_hotplug.lock)"
> and then do "Lock a-kernel-lock", other thread calls
> synchronize_sched_expedited() with a-kernel-lock held,
> ABBA DEADLOCK would happen:
>
> thread 1 | thread 2
> _cpu_down() | Lock a-kernel-lock.
> mutex_lock(&cpu_hotplug.lock) | synchronize_sched_expedited()
> ------------------------------------------------------------------------
> Lock a-kernel-lock.(wait thread2) | mutex_lock(&cpu_hotplug.lock)
> (wait thread 1)
>
>
> cpuset_lock() is an example of a-kernel-lock as described before.
> cpuset_lock() is required in CPU notifier.
>
> But some work in cpuset need get_online_cpus().
> (cpuset_lock() and then get_online_cpus(), we can
> not release cpuset_lock() temporarily)
>
> The fix is putting this work done in workqueue.
> (get_online_cpus() and then cpuset_lock());
But there is another way.
Continue to use the migration kthreads, given that they already exist,
already are created and destroyed by CPU hotplug operations, and given
that they run as maximal priority.
My main concern with moving from get_online_cpus() to preempt_disable()
has been the thought that somehow, sometime, in some future release
of Linux, it will be possible for the migration threads to execute
on the wrong CPU, perhaps only occasionally and perhaps only for
very short time periods. If this were to happen, there would be the
possibility that the grace period would end too soon, which would be
silently fatal. My fingers simply refused to code something with this
potential vulnerability.
But it is easy to insert a check into migration_thread() to see if it
is running on the wrong CPU. If it is, I can do a WARN_ONCE() and also
set a state variable to tell synchronize_sched_expedited() to invoke
sychronize_sched(), thus avoiding messing up RCU. On the next call
to synchronize_sched_expedited(), it would again try relying on the
migration threads.
I am putting together yet another patch, but constructed along these
lines, and will let you know how it turns out.
Thanx, Paul
prev parent reply other threads:[~2009-05-29 0:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 19:05 [PATCH RFC] v7 expedited "big hammer" RCU grace periods Paul E. McKenney
2009-05-25 6:35 ` Lai Jiangshan
2009-05-25 16:44 ` Paul E. McKenney
2009-05-26 1:03 ` Lai Jiangshan
2009-05-26 1:28 ` Paul E. McKenney
2009-05-26 15:46 ` Paul E. McKenney
2009-05-26 16:41 ` Mathieu Desnoyers
2009-05-26 18:13 ` Paul E. McKenney
2009-05-27 1:47 ` Mathieu Desnoyers
2009-05-27 4:27 ` Paul E. McKenney
2009-05-27 14:45 ` Mathieu Desnoyers
2009-05-28 23:52 ` Paul E. McKenney
2009-05-27 1:57 ` Lai Jiangshan
2009-05-27 4:30 ` Paul E. McKenney
2009-05-27 5:37 ` Lai Jiangshan
2009-05-29 0:08 ` 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=20090529000848.GE6757@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=jeff.chua.linux@gmail.com \
--cc=jengelh@medozas.de \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=r000n@r000n.net \
--cc=torvalds@linux-foundation.org \
--cc=zbr@ioremap.net \
/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;
as well as URLs for NNTP newsgroup(s).