selftests/powerpc: Allow bind_to_cpu() to automatically pick CPU

All current users of bind_to_cpu() don't care _which_ CPU they get, just
that they are bound to a single free one. So alter the interface to

	1. Accept a BIND_CPU_ANY value that tells it to automatically
	   pick a CPU
	2. Return the picked CPU

And convert all these users to bind_to_cpu(BIND_CPU_ANY).

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230406043320.125138-4-bgray@linux.ibm.com
This commit is contained in:
Benjamin Gray
2023-04-06 14:33:16 +10:00
committed by Michael Ellerman
parent c97b2fc662
commit 6ff4dc2548
7 changed files with 21 additions and 15 deletions

View File

@@ -455,13 +455,24 @@ done:
int bind_to_cpu(int cpu)
{
cpu_set_t mask;
int err;
if (cpu == BIND_CPU_ANY) {
cpu = pick_online_cpu();
if (cpu < 0)
return cpu;
}
printf("Binding to cpu %d\n", cpu);
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
return sched_setaffinity(0, sizeof(mask), &mask);
err = sched_setaffinity(0, sizeof(mask), &mask);
if (err)
return err;
return cpu;
}
bool is_ppc64le(void)