summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Norov <yury.norov@gmail.com>2025-01-28 11:46:33 -0500
committerYury Norov <yury.norov@gmail.com>2025-02-24 16:37:22 -0500
commit40ba13b430cb2202ce939a5cd7ff90b7d60aca7f (patch)
tree90bb5ec892ac3e27a558c7e16accb628bf1f8bcb
parent2a402aa64c10251093273656891bf788cd95677f (diff)
powerpc/xmon: simplify xmon_batch_next_cpu()
The function opencodes for_each_cpu_wrap() macro. As a loop termination condition it uses cpumask_empty(), which is O(N), and it makes the whole algorithm O(N^2). Switching to for_each_cpu_wrap() simplifies the logic, and makes the algorithm linear. Signed-off-by: Yury Norov <yury.norov@gmail.com>
-rw-r--r--arch/powerpc/xmon/xmon.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 268859e4df87..1acb53aab252 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1271,11 +1271,7 @@ static int xmon_batch_next_cpu(void)
{
unsigned long cpu;
- while (!cpumask_empty(&xmon_batch_cpus)) {
- cpu = cpumask_next_wrap(smp_processor_id(), &xmon_batch_cpus,
- xmon_batch_start_cpu, true);
- if (cpu >= nr_cpu_ids)
- break;
+ for_each_cpu_wrap(cpu, &xmon_batch_cpus, xmon_batch_start_cpu) {
if (xmon_batch_start_cpu == -1)
xmon_batch_start_cpu = cpu;
if (xmon_switch_cpu(cpu))