]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
powerpc/smp: Call smp_ops->setup_cpu() directly on the boot CPU
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 27 Jul 2017 13:23:37 +0000 (23:23 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 28 Jul 2017 09:35:45 +0000 (19:35 +1000)
commit7b7622bb95eb587cbaa79608e47b832a82a262b1
treed3255b650815b86c24e3cc6a30415b5ed32c423e
parentcd63f3cf1d59b7ad8419eba1cac8f9126e79cc43
powerpc/smp: Call smp_ops->setup_cpu() directly on the boot CPU

In smp_cpus_done() we need to call smp_ops->setup_cpu() for the boot
CPU, which means it has to run *on* the boot CPU.

In the past we ensured it ran on the boot CPU by changing the CPU
affinity mask of current directly. That was removed in commit
6d11b87d55eb ("powerpc/smp: Replace open coded task affinity logic"),
and replaced with a work queue call.

Unfortunately using a work queue leads to a lockdep warning, now that
the CPU hotplug lock is a regular semaphore:

  ======================================================
  WARNING: possible circular locking dependency detected
  ...
  kworker/0:1/971 is trying to acquire lock:
   (cpu_hotplug_lock.rw_sem){++++++}, at: [<c000000000100974>] apply_workqueue_attrs+0x34/0xa0

  but task is already holding lock:
   ((&wfc.work)){+.+.+.}, at: [<c0000000000fdb2c>] process_one_work+0x25c/0x800
  ...
       CPU0                    CPU1
       ----                    ----
  lock((&wfc.work));
                               lock(cpu_hotplug_lock.rw_sem);
                               lock((&wfc.work));
  lock(cpu_hotplug_lock.rw_sem);

Although the deadlock can't happen in practice, because
smp_cpus_done() only runs in early boot before CPU hotplug is allowed,
lockdep can't tell that.

Luckily in commit 8fb12156b8db ("init: Pin init task to the boot CPU,
initially") tglx changed the generic code to pin init to the boot CPU
to begin with. The unpinning of init from the boot CPU happens in
sched_init_smp(), which is called after smp_cpus_done().

So smp_cpus_done() is always called on the boot CPU, which means we
don't need the work queue call at all - and the lockdep warning goes
away.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
arch/powerpc/kernel/smp.c