powerpc: Only obtain cpu_hotplug_lock if called by rtasd
authorThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Tue, 20 Jun 2017 22:08:30 +0000 (19:08 -0300)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 23 Jun 2017 07:32:11 +0000 (09:32 +0200)
commit3e401f7a2e5199151f735aee6a5c6b4776e6a35e
tree39a4c4f95362a6a34bede2b3f7c3c4097b43db44
parent1b3b22507e0d45dedc6a54b26d56e0b8c4d36875
powerpc: Only obtain cpu_hotplug_lock if called by rtasd

Calling arch_update_cpu_topology from a CPU hotplug state machine callback
hits a deadlock because the function tries to get a read lock on
cpu_hotplug_lock while the state machine still holds a write lock on it.

Since all callers of arch_update_cpu_topology except rtasd already hold
cpu_hotplug_lock, this patch changes the function to use
stop_machine_cpuslocked and creates a separate function for rtasd which
still tries to obtain the lock.

Michael Bringmann investigated the bug and provided a detailed analysis
of the deadlock on this previous RFC for an alternate solution:

Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: John Allen <jallen@linux.vnet.ibm.com>
Cc: Michael Bringmann <mwb@linux.vnet.ibm.com>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1497996510-4032-1-git-send-email-bauerman@linux.vnet.ibm.com
Link: https://patchwork.ozlabs.org/patch/771293/
arch/powerpc/include/asm/topology.h
arch/powerpc/kernel/rtasd.c
arch/powerpc/mm/numa.c