From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
linux-kernel@vger.kernel.org, Li Zefan <lizf@cn.fujitsu.com>,
Miao Xie <miaox@cn.fujitsu.com>, Paul Menage <menage@google.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Gautham R Shenoy <ego@in.ibm.com>
Subject: Re: [PATCH] cpusets: fix deadlock with cpu_down()->cpuset_lock()
Date: Fri, 31 Jul 2009 10:23:16 +0800 [thread overview]
Message-ID: <4A725594.8020205@cn.fujitsu.com> (raw)
In-Reply-To: <20090730175108.GC3617@redhat.com>
Oleg Nesterov wrote:
> On 07/30, Lai Jiangshan wrote:
>> Oleg Nesterov wrote:
>>> On 07/29, Oleg Nesterov wrote:
>>>> I strongly believe the bug does exist, but this patch needs the review
>>>> from maintainers.
>>> Yes...
>>>
>>>> IOW, with this patch migration_call(CPU_DEAD) runs without callback_mutex,
>>>> but kernel/cpuset.c always takes get_online_cpus() before callback_mutex.
>>> Oh. I'm afraid this is not an option.
>>>
>>> callback_mutex should nest under cgroup_mutex, but cpu hotplu pathes
>>> take cgroup_mutex under cpu_hotplug->lock. Lockdep won't be happy.
>>>
>>> Oleg.
>>>
>> We have made great effort to remove get_online_cpus() from cgroup_mutex
>> critical region.
>
> Agreed.
>
>> We can migrate the owner of callback_mutex in migration_call(CPU_DEAD)
>> at first(and then take callback_mutex and migrate others).
>
> Not sure I understand how can we do this. Even if we know the owner
> of callback_mutex, if we can migrate it safely without callback_mutex
> why we can't migrate other tasks without this lock?
Since we have migrated the owner, we can take callback_mutex to
migrate others ...
>
> In any case this doesn't look like a clean solution,
No, it's not a clean solution.
> imho. But I hardly understand what cpuset is,
> can't suggest something clever.
We can add cpuset_lock()/cpuset_unlock() around __stop_machine()
in _cpu_down().
cpuset_lock()
__stop_machine()
......
mutex_lock(&lock);
# It's OK, because we don't require any other lock in this
# critical region. It's will not cause any kinds of deadlock.
......
flush_workqueue(stop_machine_wq);
# It's OK too. because all work functions(chill(),stop_cpu())
# of stop_machine_wq don't require any other lock.
......
mutex_unlock(&lock);
cpuset_unlock()
This fixes the bug in migrate_call(). Because there is no task which
holds callback_mutex in dead cpu after we add
cpuset_lock()/cpuset_unlock() around __stop_machine() in _cpu_down().
And it helps for your "cpu_hotplug: don't play with current->cpus_allowed"
Am I right?
Lai
next prev parent reply other threads:[~2009-07-31 2:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 2:33 + cpu_hotplug-dont-affect-current-tasks-affinity.patch added to -mm tree Oleg Nesterov
2009-07-29 21:21 ` Oleg Nesterov
2009-07-29 21:22 ` [PATCH] cpusets: fix deadlock with cpu_down()->cpuset_lock() Oleg Nesterov
2009-07-29 23:00 ` Oleg Nesterov
2009-07-30 1:53 ` Lai Jiangshan
2009-07-30 17:51 ` Oleg Nesterov
2009-07-31 2:23 ` Lai Jiangshan [this message]
2009-08-01 4:42 ` [PATCH] cpusets: rework guarantee_online_cpus() to fix deadlock with cpu_down() Oleg Nesterov
2009-08-01 5:34 ` Oleg Nesterov
2009-08-02 2:18 ` Lai Jiangshan
2009-08-02 6:55 ` Oleg Nesterov
2009-08-04 7:35 ` Lai Jiangshan
2009-08-04 16:36 ` Oleg Nesterov
2009-07-29 21:42 ` [PATCH 0/1] cpu_hotplug: don't play with current->cpus_allowed Oleg Nesterov
2009-07-29 21:43 ` [PATCH 1/1] " Oleg Nesterov
2009-07-30 2:01 ` Lai Jiangshan
2009-07-30 16:32 ` Oleg Nesterov
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=4A725594.8020205@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=miaox@cn.fujitsu.com \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=rusty@rustcorp.com.au \
/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