[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4BAB569E.5060103@cn.fujitsu.com>
Date: Thu, 25 Mar 2010 20:27:10 +0800
From: Miao Xie <miaox@...fujitsu.com>
To: Oleg Nesterov <oleg@...hat.com>
CC: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...e.hu>,
Ben Blum <bblum@...gle.com>, Jiri Slaby <jirislaby@...il.com>,
Lai Jiangshan <laijs@...fujitsu.com>,
Li Zefan <lizf@...fujitsu.com>,
Paul Menage <menage@...gle.com>,
"Rafael J. Wysocki" <rjw@...k.pl>, Tejun Heo <tj@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/6] kill the broken and deadlockable cpuset_lock/cpuset_cpus_allowed_locked
code
on 2010-3-25 18:14, Oleg Nesterov wrote:
> On 03/25, Miao Xie wrote:
>>
>> on 2010-3-15 17:10, Oleg Nesterov wrote:
>>> This patch just states the fact the cpusets/cpuhotplug interaction is
>>> broken and removes the deadlockable code which only pretends to work.
>>>
>>> - cpuset_lock() doesn't really work. It is needed for
>>> cpuset_cpus_allowed_locked() but we can't take this lock in
>>> try_to_wake_up()->select_fallback_rq() path.
>>>
>>> - cpuset_lock() is deadlockable. Suppose that a task T bound to CPU takes
>>> callback_mutex. If cpu_down(CPU) happens before T drops callback_mutex
>>> stop_machine() preempts T, then migration_call(CPU_DEAD) tries to take
>>> cpuset_lock() and hangs forever because CPU is already dead and thus
>>> T can't be scheduled.
>>
>> The problem what you said don't exist, because the kernel already move T to
>> the active cpu when preparing to turn off a CPU.
>
> we need cpuset_lock() to move T. please look at _cpu_down().
>
> OK.
>
> A task T holds callback_mutex, and it is bound to CPU 1.
>
> _cpu_down(cpu => 1) is called by the task X.
>
> _cpu_down()->stop_machine() spawns rt-threads for each cpu,
> a thread running on CPU 1 preempts T and calls take_cpu_down()
> which removes CPU 1 from online/active masks.
>
> X continues, and does raw_notifier_call_chain(CPU_DEAD), this
> calls migration_call(CPU_DEAD), and _this_ is what move the
> tasks from the dead CPU.
>
> migration_call(CPU_DEAD) calls cpuset_lock() and deadlocks.
>
> See?
But when the kernel want to offline a cpu, it does
raw_notifier_call_chain(CPU_DOWN_PREPARE)
at first. this calls cpuset_track_online_cpus() to update cpuset's cpus
and task->cpus_allowed, and then moves the task running on the dying cpu
to the other online cpu. At that time, rt-threads for each cpu have not
been created.
And when the kernel does migration_call(CPU_DEAD), the rt-threads already
exit. the task that holds callback_mutex can run as normal.
Miao
>
> Oleg.
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists