cpuhotplug: Link lock stacks for hotplug callbacks
authorThomas Gleixner <[email protected]>
Wed, 24 May 2017 08:15:43 +0000 (10:15 +0200)
committerThomas Gleixner <[email protected]>
Fri, 26 May 2017 08:10:48 +0000 (10:10 +0200)
commit49dfe2a6779717d9c18395684ee31bdc98b22e53
treed8a067fdbef6e58d980d3137c7fa6f8a27d212ea
parent0266d81e9bf5cc1fe6405c0523dfa015fe55aae1
cpuhotplug: Link lock stacks for hotplug callbacks

The CPU hotplug callbacks are not covered by lockdep versus the cpu hotplug
rwsem.

CPU0 CPU1
cpuhp_setup_state(STATE, startup, teardown);
 cpus_read_lock();
  invoke_callback_on_ap();
    kick_hotplug_thread(ap);
    wait_for_completion(); hotplug_thread_fn()
       lock(m);
  do_stuff();
  unlock(m);

Lockdep does not know about this dependency and will not trigger on the
following code sequence:

  lock(m);
  cpus_read_lock();

Add a lockdep map and connect the initiators lock chain with the hotplug
thread lock chain, so potential deadlocks can be detected.

Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Paul E. McKenney <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sebastian Siewior <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
kernel/cpu.c