Skip to content

Commit b2454ca

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
sched/hotplug: Move sync_rcu to be with set_cpu_active(false)
The sync_rcu stuff is specificically for clearing bits in the active mask, such that everybody will observe the bit cleared and will not consider the cleared CPU for load-balancing etc. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 40190a7 commit b2454ca

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

kernel/cpu.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -703,21 +703,6 @@ static int takedown_cpu(unsigned int cpu)
703703
struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
704704
int err;
705705

706-
/*
707-
* By now we've cleared cpu_active_mask, wait for all preempt-disabled
708-
* and RCU users of this state to go away such that all new such users
709-
* will observe it.
710-
*
711-
* For CONFIG_PREEMPT we have preemptible RCU and its sync_rcu() might
712-
* not imply sync_sched(), so wait for both.
713-
*
714-
* Do sync before park smpboot threads to take care the rcu boost case.
715-
*/
716-
if (IS_ENABLED(CONFIG_PREEMPT))
717-
synchronize_rcu_mult(call_rcu, call_rcu_sched);
718-
else
719-
synchronize_rcu();
720-
721706
/* Park the smpboot threads */
722707
kthread_park(per_cpu_ptr(&cpuhp_state, cpu)->thread);
723708
smpboot_park_threads(cpu);

kernel/sched/core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7112,6 +7112,20 @@ int sched_cpu_deactivate(unsigned int cpu)
71127112
int ret;
71137113

71147114
set_cpu_active(cpu, false);
7115+
/*
7116+
* We've cleared cpu_active_mask, wait for all preempt-disabled and RCU
7117+
* users of this state to go away such that all new such users will
7118+
* observe it.
7119+
*
7120+
* For CONFIG_PREEMPT we have preemptible RCU and its sync_rcu() might
7121+
* not imply sync_sched(), so wait for both.
7122+
*
7123+
* Do sync before park smpboot threads to take care the rcu boost case.
7124+
*/
7125+
if (IS_ENABLED(CONFIG_PREEMPT))
7126+
synchronize_rcu_mult(call_rcu, call_rcu_sched);
7127+
else
7128+
synchronize_rcu();
71157129

71167130
if (!sched_smp_initialized)
71177131
return 0;

0 commit comments

Comments
 (0)