selftests/powerpc: Move bind_to_cpu() to utils.h

This function will be useful in the DSCR test patches later in this
series, so promote it to be shared by all powerpc selftests.

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

View File

@ -32,6 +32,7 @@ void *find_auxv_entry(int type, char *auxv);
void *get_auxv_entry(int type);
int pick_online_cpu(void);
int bind_to_cpu(int cpu);
int parse_intmax(const char *buffer, size_t count, intmax_t *result, int base);
int parse_uintmax(const char *buffer, size_t count, uintmax_t *result, int base);

View File

@ -14,19 +14,6 @@
#include "utils.h"
#include "lib.h"
int bind_to_cpu(int cpu)
{
cpu_set_t mask;
printf("Binding to cpu %d\n", cpu);
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
return sched_setaffinity(0, sizeof(mask), &mask);
}
#define PARENT_TOKEN 0xAA
#define CHILD_TOKEN 0x55

View File

@ -20,7 +20,6 @@ union pipe {
int fds[2];
};
extern int bind_to_cpu(int cpu);
extern int kill_child_and_wait(pid_t child_pid);
extern int wait_for_child(pid_t child_pid);
extern int sync_with_child(union pipe read_pipe, union pipe write_pipe);

View File

@ -452,6 +452,18 @@ done:
return cpu;
}
int bind_to_cpu(int cpu)
{
cpu_set_t mask;
printf("Binding to cpu %d\n", cpu);
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
return sched_setaffinity(0, sizeof(mask), &mask);
}
bool is_ppc64le(void)
{
struct utsname uts;