Skip to content

Commit fde78e4

Browse files
Stanislav SpassovKAGA-KOKO
authored andcommitted
cpu/hotplug: Reverse order of iteration in freeze_secondary_cpus()
Whenever CPU hotplug state callbacks are registered, the startup callback is invoked on CPUs that have already reached the provided state in order of ascending CPU IDs. In freeze_secondary_cpus() the teardown of CPUs happens in the same are invoked in the same order. This is known to make a difference is the current implementation of these callbacks in arch/x86/events/intel/uncore.c: - uncore_event_cpu_online() designates the first CPU it is invoked for on each package as the uncore event collector for that package - uncore_event_cpu_offline() if the CPU being offlined is the event collector for its package, transfers that responsibility over to the next (by ascending CPU id) one in the same package With the current order of CPU teardowns in freeze_secondary_cpus(), the latter ends up doing the ownership transfer work on every single CPU. That work involves a synchronize_rcu() call, ultimately unnecessarily degrading the performance of CPU offlining. To address this make freeze_secondary_cpus() iterate through the CPUs in reverse order, so that the teardown happens in order of descending CPU IDs. [ tglx: Massage change log ] Signed-off-by: Stanislav Spassov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c4df159 commit fde78e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,8 @@ int freeze_secondary_cpus(int primary)
18911891
cpumask_clear(frozen_cpus);
18921892

18931893
pr_info("Disabling non-boot CPUs ...\n");
1894-
for_each_online_cpu(cpu) {
1895-
if (cpu == primary)
1894+
for (cpu = nr_cpu_ids - 1; cpu >= 0; cpu--) {
1895+
if (!cpu_online(cpu) || cpu == primary)
18961896
continue;
18971897

18981898
if (pm_wakeup_pending()) {

0 commit comments

Comments
 (0)