cpu-hotplug: CPUx should be active before it is marked online
authorVarun Wadekar <vwadekar@nvidia.com>
Mon, 26 Dec 2011 11:20:05 +0000 (16:20 +0530)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 24 Mar 2012 04:29:24 +0000 (21:29 -0700)
commit70248d80af027a20ef4d0f7f3aff8fb733e10ba1
treeeeec6e3e4687e26e4dec241e9163ae9487507fda
parent79a9fbcd1a5cab61b0c77e14068024b2e727fbaa
cpu-hotplug: CPUx should be active before it is marked online

CPU0 CPUn

_cpu_up()
  __cpu_up()

boostrap()
  notify_cpu_starting()
  set_cpu_online()
  while (!cpu_active())
    cpu_relax()

<PREEMPT-out>

smp_call_function(.wait=1)
  /* we find cpu_online() is true */
  arch_send_call_function_ipi_mask()
  /* wait-forever-more */
<PREEMPT-in>
  local_irq_enable()

  cpu_notify(CPU_ONLINE)
    sched_cpu_active()
      set_cpu_active()

Now the purpose of cpu_active is mostly with bringing down a cpu, where
we mark it !active to avoid the load-balancer from moving tasks to it
while we tear down the cpu. This is required because we only update the
sched_domain tree after we brought the cpu-down. And this is needed so
that some tasks can still run while we bring it down, we just don't want
new tasks to appear.

On cpu-up however the sched_domain tree doesn't yet include the new cpu,
so its invisible to the load-balancer, regardless of the active state.
So instead of setting the active state after we boot the new cpu (and
consequently having to wait for it before enabling interrupts) set the
cpu active before we set it online and avoid the whole mess.

Bug 916986

Original Patch: https://lkml.org/lkml/2011/12/15/255

Change-Id: Ia1c07bdc1b3eb07a7cd4d69756fa7bec509c9400
Reported-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/72130
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>

Rebase-Id: R538b4f3b79ff4427a2fdfc27b87a97646df36dde
arch/arm/kernel/smp.c
arch/s390/kernel/smp.c
arch/x86/kernel/smpboot.c
kernel/sched/core.c