public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Miao Xie <miaox@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>, Ben Blum <bblum@google.com>,
	Jiri Slaby <jirislaby@gmail.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Li Zefan <lizf@cn.fujitsu.com>, Paul Menage <menage@google.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] kill the broken and deadlockable cpuset_lock/cpuset_cpus_allowed_locked code
Date: Thu, 25 Mar 2010 13:59:35 +0100	[thread overview]
Message-ID: <20100325125935.GA6038@redhat.com> (raw)
In-Reply-To: <4BAB569E.5060103@cn.fujitsu.com>

On 03/25, Miao Xie wrote:
>
> on 2010-3-25 18:14, Oleg Nesterov wrote:
> > On 03/25, Miao Xie wrote:
> >>
> >> 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
First of let me note that it is wrong to call scan_for_empty_cpusets()
at CPU_DOWN_PREPARE state. _cpu_down() can fail after that but we can't
revert the result of remove_tasks_in_empty_cpuset().

But this doesn't matter,

> and task->cpus_allowed, and then moves the task running on the dying cpu
> to the other online cpu.

No, it doesn't track task->cpus_allowed afaics. It only checks
cpumask_empty(cp->cpus_allowed) and does nothing otherwise.

And it is quite possible that the task belongs to some cpuset cs, bound
to a single cpu, but cs->cpus_allowed is "wide" and includes other online cpus.

> At that time, rt-threads for each cpu have not
> been created.

(doesn't matter, but the are already created and sleeping)

> And when the kernel does migration_call(CPU_DEAD), the rt-threads already
> exit.

No, there are sleeping, but this doesn't matter again.

> the task that holds callback_mutex can run as normal.

It can't afaics, please see above.


That said, let me remind. I read this code only once a long ago, during my
first attempt to fix these problems (all my attempts were ignored until
I rerouted my concerns to Peter). It is possible that I missed/forgot/both
something. But when I did the second version I bothered to actually test
my theory and the kernel hanged, see the changelog in
http://marc.info/?t=124910242400002

You was cc'ed too ;)

Oleg.


  reply	other threads:[~2010-03-25 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-15  9:10 [PATCH 1/6] kill the broken and deadlockable cpuset_lock/cpuset_cpus_allowed_locked code Oleg Nesterov
2010-03-25  3:00 ` Miao Xie
2010-03-25 10:14   ` Oleg Nesterov
2010-03-25 12:27     ` Miao Xie
2010-03-25 12:59       ` Oleg Nesterov [this message]
2010-04-02 19:11 ` [tip:sched/core] sched: Kill " tip-bot for 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=20100325125935.GA6038@redhat.com \
    --to=oleg@redhat.com \
    --cc=bblum@google.com \
    --cc=jirislaby@gmail.com \
    --cc=laijs@cn.fujitsu.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=peterz@infradead.org \
    --cc=rjw@sisk.pl \
    --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