From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
paulmck@linux.vnet.ibm.com,
"Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
Arjan van de Ven <arjan@infradead.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Milton Miller <miltonm@bga.com>, "mingo@elte.hu" <mingo@elte.hu>,
Tejun Heo <tj@kernel.org>,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Linux PM mailing list <linux-pm@vger.kernel.org>
Subject: Re: CPU Hotplug rework
Date: Mon, 26 Mar 2012 19:59:26 +0200 [thread overview]
Message-ID: <1332784766.16159.164.camel@twins> (raw)
In-Reply-To: <1332781541.23924.110.camel@gandalf.stny.rr.com>
On Mon, 2012-03-26 at 13:05 -0400, Steven Rostedt wrote:
> On Mon, 2012-03-26 at 18:13 +0200, Peter Zijlstra wrote:
> > On Mon, 2012-03-26 at 11:22 -0400, Steven Rostedt wrote:
>
> > So how about we add another variant of kthread_freezable_should_stop(),
> > maybe call it kthread_bound_should_stop() that checks if the cpu its
> > bound to goes awol, if so, park it.
>
> Do you mean to have this function automate the "park". When it is
> called, if the cpu is going down it should simply schedule off and not
> return until the CPU comes back on line?
Yep..
> Actually, why not just keep "kthread_should_stop()" and instead create a
> "kthread_park()", and call that instead of kthread_stop(). Then when the
> task calls kthread_should_stop(), that can park the thread then.
That would add an if ((current->flags & PF_THREAD_BOUND) &&
kthread_should_park(cpu))) conditional to every kthread_stop()
invocation. So as per the example of kthread_freezable_should_stop() I
opted for another function.
Note that kernel/workqueue.c should be fixed to use kthread_stop() or
whatever variant we implement, as it currently uses a home brewn
solution to stop threads.
> > Then after CPU_DOWN_PREPARE, wait for all such threads (as registered
> > per kthread_bind()) to pass through kthread_bound_should_stop() and get
> > frozen.
>
> We could have the notifiers call kthread_park().
You mean to avoid having to track them through kthread_bind() ?
The advantage of tracking them is that its harder to 'forget' about one.
> > This should restore PF_THREAD_BOUND to mean its actually bound to this
> > cpu, since if the cpu goes down, the task won't actually run at all.
> > Which means you can again use PF_THREAD_BOUND to by-pass the whole
> > get_online_cpus()/pin_curr_cpu() muck.
> >
> > Any subsystem that can still accrue state after this (eg, softirq/rcu
> > and possible kworker) need to register a CPU_DYING or CPU_DEAD notifier
> > to either complete the state or take it away and give it to someone
> > else.
>
> I'm afraid that this part sounds easier than done.
Got anything particularly difficult in mind?
Workqueues can give the gcwq to unbound threads -- it doesn't guarantee
the per-cpu-ness of work items anyway.
Softirqs can be ran from CPU_DYING since interrupts will never be
enabled again at that point.
RCU would have to make sure the cpu doesn't complete a grace period and
fixup from CPU_DEAD, so have it complete any outstanding grace periods,
move it to extended idle and steal the callback list.
I'm not sure there's anything really hard there.
> > > Now what are the issues we have:
> > >
> > > 1) We need to get tasks off the CPU going down. For most tasks this is
> > > not an issue. But for CPU specific kernel threads, this can be an issue.
> > > To get tasks off of the CPU is required before the notifiers are called.
> > > This is to keep them from creating work on the CPU, because after the
> > > notifiers, there should be no more work added to the CPU.
> >
> > This is hard for things like ksoftirq, because for as long as interrupts
> > are enabled we can trigger softirqs. And since we need to deal with
> > that, we might as well deal with it for all and not bother.
>
> Heh, at least for -rt we don't need to worry about that. As interrupts
> are threads and are moved to other CPUS. Although I'm not sure that's
> true about the timer softirq.
Its a problem for rt, since as long as interrupts are enabled (and we
can schedule) interrupts can come in and wake their respective threads,
this can happen during the CPU_DOWN_PREPARE notifier just fine.
For both -rt and mainline we can schedule right up until we call
stop-machine, mainline (!threadirq) will continue servicing interrupts
another few instructions until the stop_machine bits disable interrupts
on all cpus. The difference is really not that big.
> > > 3) Some tasks do not go offline, instead they just get moved to another
> > > CPU. This is the case of ksoftirqd. As it is killed after the CPU is
> > > down (POST_DEAD) (at least in -rt it is).
> >
> > No, we should really stop allowing tasks that were kthread_bind() to run
> > anywhere else. Breaking the strict affinity and letting them run
> > someplace else to complete their work is what gets is in a whole heap of
> > trouble.
>
> Agreed, but to fix this is not a easy problem.
I'm not sure its that hard, just work.
If we get the above stuff done, we should be able to put BUG_ON(p->flags
& PF_THREAD_BOUND) in select_fallback_rq().
Also, I think you should opt for the solution that has the
cleanest/strongest semantics so you can add more debug infrastructure
around it to enforce it.
next prev parent reply other threads:[~2012-03-26 18:41 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 14:44 CPU Hotplug rework Srivatsa S. Bhat
2012-03-19 14:48 ` Srivatsa S. Bhat
2012-03-20 11:28 ` Peter Zijlstra
2012-04-05 17:39 ` Paul E. McKenney
2012-04-05 17:55 ` Paul E. McKenney
2012-04-05 23:06 ` Paul E. McKenney
2012-04-06 20:15 ` Srivatsa S. Bhat
2012-04-09 16:46 ` Paul E. McKenney
2012-04-10 7:56 ` Nikunj A Dadhania
2012-04-06 19:52 ` Srivatsa S. Bhat
2012-04-09 17:13 ` Paul E. McKenney
2012-04-10 13:41 ` Srivatsa S. Bhat
2012-04-10 15:46 ` Paul E. McKenney
2012-04-10 17:26 ` Srivatsa S. Bhat
2012-04-11 0:09 ` Steven Rostedt
2012-04-11 0:28 ` Paul E. McKenney
2012-04-11 0:37 ` Steven Rostedt
2012-04-11 1:00 ` Paul E. McKenney
2012-04-11 6:02 ` Srivatsa S. Bhat
2012-04-11 12:28 ` Paul E. McKenney
2012-03-19 23:42 ` Rusty Russell
2012-03-20 10:42 ` Peter Zijlstra
2012-03-20 23:00 ` Rusty Russell
2012-03-21 9:01 ` Peter Zijlstra
2012-03-22 4:25 ` Rusty Russell
2012-03-22 22:49 ` Paul E. McKenney
2012-03-23 23:27 ` Rusty Russell
2012-03-24 0:23 ` Paul E. McKenney
2012-03-26 0:41 ` Rusty Russell
2012-03-26 8:02 ` Peter Zijlstra
2012-03-26 13:09 ` Steven Rostedt
2012-03-26 13:38 ` Peter Zijlstra
2012-03-26 15:22 ` Steven Rostedt
2012-03-26 16:13 ` Peter Zijlstra
2012-03-26 17:05 ` Steven Rostedt
2012-03-26 17:59 ` Peter Zijlstra [this message]
2012-03-27 1:32 ` Rusty Russell
2012-03-27 3:05 ` Steven Rostedt
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=1332784766.16159.164.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=kosaki.motohiro@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=miltonm@bga.com \
--cc=mingo@elte.hu \
--cc=paul.gortmaker@windriver.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rjw@sisk.pl \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=tj@kernel.org \
--cc=vatsa@linux.vnet.ibm.com \
/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