Skip to content

Commit 40ba13b

Browse files
committed
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 <[email protected]>
1 parent 2a402aa commit 40ba13b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

arch/powerpc/xmon/xmon.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,11 +1271,7 @@ static int xmon_batch_next_cpu(void)
12711271
{
12721272
unsigned long cpu;
12731273

1274-
while (!cpumask_empty(&xmon_batch_cpus)) {
1275-
cpu = cpumask_next_wrap(smp_processor_id(), &xmon_batch_cpus,
1276-
xmon_batch_start_cpu, true);
1277-
if (cpu >= nr_cpu_ids)
1278-
break;
1274+
for_each_cpu_wrap(cpu, &xmon_batch_cpus, xmon_batch_start_cpu) {
12791275
if (xmon_batch_start_cpu == -1)
12801276
xmon_batch_start_cpu = cpu;
12811277
if (xmon_switch_cpu(cpu))

0 commit comments

Comments
 (0)