sbalance: Don't race with CPU hotplug

When a CPU is hotplugged, cpu_active_mask is modified without any RCU
synchronization. As a result, the only synchronization for cpu_active_mask
provided by the hotplug code is the CPU hotplug lock.

Furthermore, since IRQ balance is majorly disrupted during CPU hotplug due
to mass IRQ migration off a dying CPU, SBalance just shouldn't operate
while a CPU hotplug is in progress.

Take the CPU hotplug lock in balance_irqs() to prevent races and mishaps
during CPU hotplugs.

Change-Id: If377de7b78e3ae68a20bc95bdb84650330cfc330
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
Sultan Alsawaf 2024-12-04 14:31:52 -08:00 committed by Richard Raya
parent 8d891a9e71
commit 9d49f44e04

View File

@ -217,6 +217,7 @@ static void balance_irqs(void)
struct bal_irq *bi;
int cpu;
cpus_read_lock();
rcu_read_lock();
/* Find the available CPUs for balancing, if there are any */
@ -334,6 +335,7 @@ try_next_heaviest:
goto try_next_heaviest;
unlock:
rcu_read_unlock();
cpus_read_unlock();
/* Reset each balance domain for the next run */
for_each_possible_cpu(cpu) {