Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/lockdep, cpu/hotplug: Annotate AP thread

Anybody trying to assert the cpu_hotplug_lock is held (lockdep_assert_cpus_held())
from AP callbacks will fail, because the lock is held by the BP.

Stick in an explicit annotation in cpuhp_thread_fun() to make this work.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-tip-commits@vger.kernel.org
Fixes: cb538267ea1e ("jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations")
Link: http://lkml.kernel.org/r/20180911095127.GT24082@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Peter Zijlstra and committed by
Ingo Molnar
cb92173d 84818af2

+28
+28
kernel/cpu.c
··· 315 315 percpu_rwsem_assert_held(&cpu_hotplug_lock); 316 316 } 317 317 318 + static void lockdep_acquire_cpus_lock(void) 319 + { 320 + rwsem_acquire(&cpu_hotplug_lock.rw_sem.dep_map, 0, 0, _THIS_IP_); 321 + } 322 + 323 + static void lockdep_release_cpus_lock(void) 324 + { 325 + rwsem_release(&cpu_hotplug_lock.rw_sem.dep_map, 1, _THIS_IP_); 326 + } 327 + 318 328 /* 319 329 * Wait for currently running CPU hotplug operations to complete (if any) and 320 330 * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects ··· 354 344 cpu_maps_update_done(); 355 345 } 356 346 EXPORT_SYMBOL_GPL(cpu_hotplug_enable); 347 + 348 + #else 349 + 350 + static void lockdep_acquire_cpus_lock(void) 351 + { 352 + } 353 + 354 + static void lockdep_release_cpus_lock(void) 355 + { 356 + } 357 + 357 358 #endif /* CONFIG_HOTPLUG_CPU */ 358 359 359 360 #ifdef CONFIG_HOTPLUG_SMT ··· 637 616 */ 638 617 smp_mb(); 639 618 619 + /* 620 + * The BP holds the hotplug lock, but we're now running on the AP, 621 + * ensure that anybody asserting the lock is held, will actually find 622 + * it so. 623 + */ 624 + lockdep_acquire_cpus_lock(); 640 625 cpuhp_lock_acquire(bringup); 641 626 642 627 if (st->single) { ··· 688 661 } 689 662 690 663 cpuhp_lock_release(bringup); 664 + lockdep_release_cpus_lock(); 691 665 692 666 if (!st->should_run) 693 667 complete_ap_thread(st, bringup);