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 eed7dd7582b2922cf963d45dffe732119b0c96f3..d3589e16a20f29e0659bca78b5126127b1a3f9e6 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 719f94f10d41bcd6714e408eeb36b9ed62ebca8a..144f90a78d698182e50e1be9b5fcffe81fd9394f 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 bf1bec013bbb4852cf0a7a99cf3dfd499b5628d5..1d62403ae6ea5967a58548ed66523c38c8b82576 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 7c8cfedb012a99e8fa18086b590965139964d084..cdb996dba703da35814f8fb5345530679aa022c1 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;