jump_label/lockdep: Assert we hold the hotplug lock for _cpuslocked() operations
A message that is not in the archive (sent off-list or not yet received): [email protected]
Peter Zijlstra
maintainerQuoted 10 lines · tip-bot for Peter Zijlstra
Commit-ID: cb538267ea1e9e025ec692577c9ae75797261889 Gitweb: https://git.kernel.org/tip/cb538267ea1e9e025ec692577c9ae75797261889 Author: Peter Zijlstra <[email protected]> AuthorDate: Tue, 31 Jul 2018 14:35:32 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 10 Sep 2018 10:16:38 +0200jump_label/lockdep: Assert we hold the hotplug lock for
_cpuslocked()operationsWeirdly we seem to have forgotten this...
This of course instantly triggered a false positive :/
---
Subject: 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.
--- kernel/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/cpu.c +7 -0
@@ -616,6 +616,12 @@ static void cpuhp_thread_fun(unsigned int cpu)*/ smp_mb (); +/* +* The BP holds the hotplug lock, but we're now running on the AP, +* ensure that anybody asserting the lock is held, will actually find +* it so. +*/ +rwsem_acquire (&cpu_hotplug_lock.rw_sem.dep_map,0 ,0 , _THIS_IP_);cpuhp_lock_acquire (bringup);if (st->single) {
@@ -661,6 +667,7 @@ static void cpuhp_thread_fun(unsigned int cpu) }cpuhp_lock_release (bringup); +rwsem_release (&cpu_hotplug_lock.rw_sem.dep_map,1 , _THIS_IP_);if (!st->should_run)complete_ap_thread (st, bringup);
tip-bot for Peter Zijlstra
merge bot[tip:locking/core] locking/lockdep, cpu/hotplug: Annotate AP thread
locking/lockdep, cpu/hotplug: Annotate AP thread
Commit-ID: f1b2f6eccf99fc457221cc84c7550a8e3b17d4df Gitweb: https://git.kernel.org/tip/f1b2f6eccf99fc457221cc84c7550a8e3b17d4df Author: Peter Zijlstra <[email protected]> AuthorDate: Tue, 11 Sep 2018 11:51:27 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Sep 2018 12:37:00 +0200
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.
--- kernel/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/cpu.c +7 -0
@@ -616,6 +616,12 @@ static void cpuhp_thread_fun(unsigned int cpu)*/ smp_mb (); +/* +* The BP holds the hotplug lock, but we're now running on the AP, +* ensure that anybody asserting the lock is held, will actually find +* it so. +*/ +rwsem_acquire (&cpu_hotplug_lock.rw_sem.dep_map,0 ,0 , _THIS_IP_);cpuhp_lock_acquire (bringup);if (st->single) {
@@ -661,6 +667,7 @@ static void cpuhp_thread_fun(unsigned int cpu) }cpuhp_lock_release (bringup); +rwsem_release (&cpu_hotplug_lock.rw_sem.dep_map,1 , _THIS_IP_);if (!st->should_run)complete_ap_thread (st, bringup);
tip-bot for Peter Zijlstra
merge bot[tip:locking/core] locking/lockdep, cpu/hotplug: Annotate AP thread
In reply to Peter Zijlstralocking/lockdep, cpu/hotplug: Annotate AP thread
Commit-ID: cb92173d1f0474784c6171a9d3fdbbca0ee53554 Gitweb: https://git.kernel.org/tip/cb92173d1f0474784c6171a9d3fdbbca0ee53554 Author: Peter Zijlstra <[email protected]> AuthorDate: Tue, 11 Sep 2018 11:51:27 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Sep 2018 20:01:03 +0200
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.
--- kernel/cpu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
kernel/cpu.c +28 -0
@@ -315,6 +315,16 @@ void lockdep_assert_cpus_held(void)percpu_rwsem_assert_held (&cpu_hotplug_lock); } +static void lockdep_acquire_cpus_lock (void ) +{ +rwsem_acquire (&cpu_hotplug_lock.rw_sem.dep_map,0 ,0 , _THIS_IP_); +} + +static void lockdep_release_cpus_lock (void ) +{ +rwsem_release (&cpu_hotplug_lock.rw_sem.dep_map,1 , _THIS_IP_); +} +/* * Wait for currently running CPU hotplug operations to complete (if any) and * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
@@ -344,6 +354,17 @@ void cpu_hotplug_enable(void) cpu_maps_update_done(); }EXPORT_SYMBOL_GPL (cpu_hotplug_enable); + +#else + +static void lockdep_acquire_cpus_lock (void ) +{ +} + +static void lockdep_release_cpus_lock (void ) +{ +} +#endif /* CONFIG_HOTPLUG_CPU */ #ifdef CONFIG_HOTPLUG_SMT
@@ -616,6 +637,12 @@ static void cpuhp_thread_fun(unsigned int cpu)*/ smp_mb (); +/* +* The BP holds the hotplug lock, but we're now running on the AP, +* ensure that anybody asserting the lock is held, will actually find +* it so. +*/ +lockdep_acquire_cpus_lock ();cpuhp_lock_acquire (bringup);if (st->single) {
@@ -661,6 +688,7 @@ static void cpuhp_thread_fun(unsigned int cpu) }cpuhp_lock_release (bringup); +lockdep_release_cpus_lock ();if (!st->should_run)complete_ap_thread (st, bringup);