linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russ Anderson <rja@sgi.com>
To: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>, Robin Holt <holt@sgi.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Shawn Guo <shawn.guo@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Tejun Heo <tj@kernel.org>, Oleg Nesterov <oleg@redhat.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Michel Lespinasse <walken@google.com>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: Bulk CPU Hotplug (Was Re: [PATCH] Do not force shutdown/reboot to boot cpu.)
Date: Thu, 11 Apr 2013 09:23:01 -0500	[thread overview]
Message-ID: <20130411142301.GB27990@sgi.com> (raw)
In-Reply-To: <5166B05E.8010904@linux.vnet.ibm.com>

On Thu, Apr 11, 2013 at 06:15:18PM +0530, Srivatsa S. Bhat wrote:
> On 04/11/2013 11:01 AM, Paul Mackerras wrote:
> > On Wed, Apr 10, 2013 at 08:10:05AM -0700, Linus Torvalds wrote:
> >> The optimal solution would be to just speed up the
> >> disable_nonboot_cpus() code so much that it isn't an issue. That would
> >> be good for suspending too, although I guess suspend isn't a big issue
> >> if you have a thousand CPU's.
> >>
> >> Has anybody checked whether we could do the cpu_down() on non-boot
> >> CPU's in parallel? Right now we serialize the thing completely, with
> > 
> > I thought Srivatsa S. Bhat had a patchset that did exactly that.
> > Srivatsa?
> > 
> 
> Thanks for the CC, Paul! Adding some more people to CC.
> 
> Actually, my patchset was about removing stop_machine() from the CPU
> offline path.
> http://lwn.net/Articles/538819/

I certainly agree with the intent.

> And here is the performance improvement I had measured in the version
> prior to that:
> http://article.gmane.org/gmane.linux.kernel/1435249
> 
> I'm planning to revive this patchset after the 3.10 merge window closes,
> because it depends on doing a tree-wide sweep, and I think its a little
> late to do it in time for the upcoming 3.10 merge window itself.
> 
> Anyway, that's about removing stop_machine from CPU hotplug.
> 
> Coming to bulk CPU hotplug, yes, I had ideas similar to what Russ suggested.
> But I believe we can do more than that.
> 
> As Russ pointed out, the notifiers are not thread-safe, so calling them
> in parallel with different CPUs as arguments isn't going to work.
> 
> So, first, we can convert all the CPU hotplug notifiers to take a cpumask
> instead of a single CPU. So assuming that there are 'n' notifiers in total,
> the number of function calls would become n, instead of n*1024.
> But that itself most likely won't give us much benefit over the for-loop
> that Russ has done in his patch, because it'll simply do longer processing
> in each of those 'n' notifiers, by iterating over the cpumask inside each
> notifier.

As an alternative, how about each cpu have their own notifier list?
Then one task per cpu can spin through that cpu's notifier list, 
allowing them to run in parallel.

I don't know if that would be a faster solution than adding cpumask
to notifiers, but it my guess is it may.

> Now comes the interesting thing:
> 
> Consider a notifier chain that looks like this:
> Priority 0: A->B->C->D
> 
> We can't invoke say notifier callback A simultaneously on 2 CPUs with 2
> different hotcpus as argument. *However*, since A, B, C, D all (more or less)
> belong to different subsystems, we can call A, B, C and D in parallel on
> different CPUs. They won't even serialize amongst themselves because they
> take locks (if any) of different subsystems. And since they are of same
> priority, the ordering (A after B or B after A) doesn't matter as well.
> 
> So with this, if we combine the idea I wrote above about giving a cpumask
> to each of these notifiers to work with, we end up in this:
> 
> CPU 0          CPU 1          CPU2           ....
> A(cpumask)     B(cpumask)     C(cpumask)     ....
> 
> So, for example, the CPU_DOWN_PREPARE notification can be processed in parallel
> on multiple CPUs at a time, for a given cpumask! That should definitely
> give us a good speed-up.
> 
> One more thing we have to note is that, there are 4 notifiers for taking a
> CPU offline:
> 
> CPU_DOWN_PREPARE
> CPU_DYING
> CPU_DEAD
> CPU_POST_DEAD
> 
> The first can be run in parallel as mentioned above. The second is run in
> parallel in the stop_machine() phase as shown in Russ' patch. But the third
> and fourth set of notifications all end up running only on CPU0, which will
> again slow down things.

In my testing the third and fourth set were a small part of the overall
time.  Less than 10%, with cpu notifiers 90+% of the time.  So you may
not need the added complexity, or at least fix the cpu notifier part
first.

> So I suggest taking down the 1024 CPUs in multiple phases, like a binary search.
> First, take 512 CPUs down, then 256 CPUs, then 128 CPUs etc. So at every bulk
> CPU hotplug, we have enough online CPUs to handle the notifier load, and that
> helps speed things up. Moreover, a handful of calls to stop_machine() is OK
> because, stop_machine() takes progressively lesser and lesser time because
> lesser CPUs are online on each iteration (and hence it reduces the
> synchronization overhead of the stop-machine phase).
> 
> The only downside to this whole idea of running the notifiers of a given
> priority in parallel, is error handling - if a notifier fails, it would be
> troublesome to rollback I guess. But if we forget that for a moment, we can
> give this idea a try!

Yes.

> Regards,
> Srivatsa S. Bhat

-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

  parent reply	other threads:[~2013-04-11 14:23 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 19:37 [PATCH] Do not force shutdown/reboot to boot cpu Robin Holt
2013-04-08 15:57 ` Ingo Molnar
2013-04-08 16:11   ` H. Peter Anvin
2013-04-08 16:59     ` Robin Holt
2013-04-10 11:16       ` Ingo Molnar
2013-04-10 14:01         ` Robin Holt
2013-04-10 15:10         ` Linus Torvalds
2013-04-10 15:29           ` Russ Anderson
2013-04-10 16:59             ` Ingo Molnar
2013-04-10 17:14               ` Robin Holt
2013-04-10 17:22                 ` Ingo Molnar
2013-04-10 17:55                   ` Robin Holt
2013-04-10 19:00                     ` Robin Holt
2013-04-11  8:57                       ` Ingo Molnar
2013-04-11 11:34                         ` Robin Holt
2013-04-11 12:00                           ` Ingo Molnar
2013-04-11 12:03                             ` Robin Holt
2013-04-11 12:08                               ` Robin Holt
2013-04-11 12:14                                 ` Ingo Molnar
2013-04-10 17:58               ` H. Peter Anvin
2013-04-10 23:02               ` Russ Anderson
2013-04-10 22:29             ` Russ Anderson
2013-04-11  5:31           ` Paul Mackerras
2013-04-11 12:45             ` Bulk CPU Hotplug (Was Re: [PATCH] Do not force shutdown/reboot to boot cpu.) Srivatsa S. Bhat
2013-04-11 13:48               ` Robin Holt
2013-04-12  5:37                 ` Ingo Molnar
2013-04-12  6:09                   ` Srivatsa S. Bhat
2013-04-12  9:31                     ` Robin Holt
2013-04-12 10:01                       ` Robin Holt
2013-04-13 16:30                       ` Oleg Nesterov
2013-04-15 16:04                         ` Robin Holt
2013-04-15 16:09                           ` Oleg Nesterov
2013-04-15 16:10                           ` Robin Holt
2013-04-13 17:01                       ` Srivatsa S. Bhat
2013-04-15 10:16                       ` Ingo Molnar
2013-04-15 12:02                         ` Robin Holt
2013-04-15 15:59                           ` Robin Holt
2013-04-16  9:40                             ` Ingo Molnar
2013-04-11 14:23               ` Russ Anderson [this message]
2013-04-11 14:45                 ` Srivatsa S. Bhat
2013-04-11 20:08                   ` Russ Anderson
2013-04-11 20:17                     ` Srivatsa S. Bhat
2013-04-11 21:08                     ` Robin Holt
2013-04-08 16:54   ` [PATCH] Do not force shutdown/reboot to boot cpu Robin Holt
2013-04-08 17:07   ` Russ Anderson

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=20130411142301.GB27990@sgi.com \
    --to=rja@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=holt@sgi.com \
    --cc=hpa@zytor.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=rusty@rustcorp.com.au \
    --cc=shawn.guo@linaro.org \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=walken@google.com \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).