selftests/powerpc: Move bind_to_cpu() to utils.h
authorBenjamin Gray <bgray@linux.ibm.com>
Thu, 6 Apr 2023 04:33:15 +0000 (14:33 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 20 Apr 2023 03:21:45 +0000 (13:21 +1000)
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
tools/testing/selftests/powerpc/include/utils.h
tools/testing/selftests/powerpc/pmu/lib.c
tools/testing/selftests/powerpc/pmu/lib.h
tools/testing/selftests/powerpc/utils.c

index eed7dd7..d3589e1 100644 (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);
index 719f94f..144f90a 100644 (file)
 #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
 
index bf1bec0..1d62403 100644 (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);
index 7c8cfed..cdb996d 100644 (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;