diff options
Diffstat (limited to 'tools/testing/selftests/powerpc/benchmarks/context_switch.c')
-rw-r--r-- | tools/testing/selftests/powerpc/benchmarks/context_switch.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c index f4241339edd2..87f1f0252299 100644 --- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c +++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define _GNU_SOURCE | 12 | #define _GNU_SOURCE |
13 | #include <errno.h> | ||
13 | #include <sched.h> | 14 | #include <sched.h> |
14 | #include <string.h> | 15 | #include <string.h> |
15 | #include <stdio.h> | 16 | #include <stdio.h> |
@@ -75,6 +76,7 @@ static void touch(void) | |||
75 | 76 | ||
76 | static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu) | 77 | static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu) |
77 | { | 78 | { |
79 | int rc; | ||
78 | pthread_t tid; | 80 | pthread_t tid; |
79 | cpu_set_t cpuset; | 81 | cpu_set_t cpuset; |
80 | pthread_attr_t attr; | 82 | pthread_attr_t attr; |
@@ -82,14 +84,23 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu) | |||
82 | CPU_ZERO(&cpuset); | 84 | CPU_ZERO(&cpuset); |
83 | CPU_SET(cpu, &cpuset); | 85 | CPU_SET(cpu, &cpuset); |
84 | 86 | ||
85 | pthread_attr_init(&attr); | 87 | rc = pthread_attr_init(&attr); |
88 | if (rc) { | ||
89 | errno = rc; | ||
90 | perror("pthread_attr_init"); | ||
91 | exit(1); | ||
92 | } | ||
86 | 93 | ||
87 | if (pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset)) { | 94 | rc = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset); |
95 | if (rc) { | ||
96 | errno = rc; | ||
88 | perror("pthread_attr_setaffinity_np"); | 97 | perror("pthread_attr_setaffinity_np"); |
89 | exit(1); | 98 | exit(1); |
90 | } | 99 | } |
91 | 100 | ||
92 | if (pthread_create(&tid, &attr, fn, arg)) { | 101 | rc = pthread_create(&tid, &attr, fn, arg); |
102 | if (rc) { | ||
103 | errno = rc; | ||
93 | perror("pthread_create"); | 104 | perror("pthread_create"); |
94 | exit(1); | 105 | exit(1); |
95 | } | 106 | } |