Commit 6ff4dc25 authored by Benjamin Gray's avatar Benjamin Gray Committed by Michael Ellerman
Browse files

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: default avatarBenjamin Gray <bgray@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230406043320.125138-4-bgray@linux.ibm.com
parent c97b2fc6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ int read_auxv(char *buf, ssize_t buf_size);
void *find_auxv_entry(int type, char *auxv);
void *get_auxv_entry(int type);

#define BIND_CPU_ANY	(-1)

int pick_online_cpu(void);
int bind_to_cpu(int cpu);

+1 −2
Original line number Diff line number Diff line
@@ -45,9 +45,8 @@ int cpu_event_pinned_vs_ebb(void)

	SKIP_IF(!ebb_is_supported());

	cpu = pick_online_cpu();
	cpu = bind_to_cpu(BIND_CPU_ANY);
	FAIL_IF(cpu < 0);
	FAIL_IF(bind_to_cpu(cpu));

	FAIL_IF(pipe(read_pipe.fds) == -1);
	FAIL_IF(pipe(write_pipe.fds) == -1);
+1 −2
Original line number Diff line number Diff line
@@ -43,9 +43,8 @@ int cpu_event_vs_ebb(void)

	SKIP_IF(!ebb_is_supported());

	cpu = pick_online_cpu();
	cpu = bind_to_cpu(BIND_CPU_ANY);
	FAIL_IF(cpu < 0);
	FAIL_IF(bind_to_cpu(cpu));

	FAIL_IF(pipe(read_pipe.fds) == -1);
	FAIL_IF(pipe(write_pipe.fds) == -1);
+1 −2
Original line number Diff line number Diff line
@@ -43,9 +43,8 @@ int ebb_vs_cpu_event(void)

	SKIP_IF(!ebb_is_supported());

	cpu = pick_online_cpu();
	cpu = bind_to_cpu(BIND_CPU_ANY);
	FAIL_IF(cpu < 0);
	FAIL_IF(bind_to_cpu(cpu));

	FAIL_IF(pipe(read_pipe.fds) == -1);
	FAIL_IF(pipe(write_pipe.fds) == -1);
+2 −4
Original line number Diff line number Diff line
@@ -75,13 +75,11 @@ static int cycles_child(void)
int multi_ebb_procs(void)
{
	pid_t pids[NR_CHILDREN];
	int cpu, rc, i;
	int rc, i;

	SKIP_IF(!ebb_is_supported());

	cpu = pick_online_cpu();
	FAIL_IF(cpu < 0);
	FAIL_IF(bind_to_cpu(cpu));
	FAIL_IF(bind_to_cpu(BIND_CPU_ANY) < 0);

	for (i = 0; i < NR_CHILDREN; i++) {
		pids[i] = fork();
Loading