diff options
Diffstat (limited to 'tools/perf/bench/futex-wake.c')
-rw-r--r-- | tools/perf/bench/futex-wake.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c index 50022cbce87e..929f762be47e 100644 --- a/tools/perf/bench/futex-wake.c +++ b/tools/perf/bench/futex-wake.c | |||
@@ -31,16 +31,18 @@ static u_int32_t futex1 = 0; | |||
31 | static unsigned int nwakes = 1; | 31 | static unsigned int nwakes = 1; |
32 | 32 | ||
33 | pthread_t *worker; | 33 | pthread_t *worker; |
34 | static bool done = false, silent = false; | 34 | static bool done = false, silent = false, fshared = false; |
35 | static pthread_mutex_t thread_lock; | 35 | static pthread_mutex_t thread_lock; |
36 | static pthread_cond_t thread_parent, thread_worker; | 36 | static pthread_cond_t thread_parent, thread_worker; |
37 | static struct stats waketime_stats, wakeup_stats; | 37 | static struct stats waketime_stats, wakeup_stats; |
38 | static unsigned int ncpus, threads_starting, nthreads = 0; | 38 | static unsigned int ncpus, threads_starting, nthreads = 0; |
39 | static int futex_flag = 0; | ||
39 | 40 | ||
40 | static const struct option options[] = { | 41 | static const struct option options[] = { |
41 | OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"), | 42 | OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"), |
42 | OPT_UINTEGER('w', "nwakes", &nwakes, "Specify amount of threads to wake at once"), | 43 | OPT_UINTEGER('w', "nwakes", &nwakes, "Specify amount of threads to wake at once"), |
43 | OPT_BOOLEAN( 's', "silent", &silent, "Silent mode: do not display data/details"), | 44 | OPT_BOOLEAN( 's', "silent", &silent, "Silent mode: do not display data/details"), |
45 | OPT_BOOLEAN( 'S', "shared", &fshared, "Use shared futexes instead of private ones"), | ||
44 | OPT_END() | 46 | OPT_END() |
45 | }; | 47 | }; |
46 | 48 | ||
@@ -58,7 +60,7 @@ static void *workerfn(void *arg __maybe_unused) | |||
58 | pthread_cond_wait(&thread_worker, &thread_lock); | 60 | pthread_cond_wait(&thread_worker, &thread_lock); |
59 | pthread_mutex_unlock(&thread_lock); | 61 | pthread_mutex_unlock(&thread_lock); |
60 | 62 | ||
61 | futex_wait(&futex1, 0, NULL, FUTEX_PRIVATE_FLAG); | 63 | futex_wait(&futex1, 0, NULL, futex_flag); |
62 | return NULL; | 64 | return NULL; |
63 | } | 65 | } |
64 | 66 | ||
@@ -130,9 +132,12 @@ int bench_futex_wake(int argc, const char **argv, | |||
130 | if (!worker) | 132 | if (!worker) |
131 | err(EXIT_FAILURE, "calloc"); | 133 | err(EXIT_FAILURE, "calloc"); |
132 | 134 | ||
133 | printf("Run summary [PID %d]: blocking on %d threads (at futex %p), " | 135 | if (!fshared) |
136 | futex_flag = FUTEX_PRIVATE_FLAG; | ||
137 | |||
138 | printf("Run summary [PID %d]: blocking on %d threads (at [%s] futex %p), " | ||
134 | "waking up %d at a time.\n\n", | 139 | "waking up %d at a time.\n\n", |
135 | getpid(), nthreads, &futex1, nwakes); | 140 | getpid(), nthreads, fshared ? "shared":"private", &futex1, nwakes); |
136 | 141 | ||
137 | init_stats(&wakeup_stats); | 142 | init_stats(&wakeup_stats); |
138 | init_stats(&waketime_stats); | 143 | init_stats(&waketime_stats); |
@@ -160,7 +165,7 @@ int bench_futex_wake(int argc, const char **argv, | |||
160 | /* Ok, all threads are patiently blocked, start waking folks up */ | 165 | /* Ok, all threads are patiently blocked, start waking folks up */ |
161 | gettimeofday(&start, NULL); | 166 | gettimeofday(&start, NULL); |
162 | while (nwoken != nthreads) | 167 | while (nwoken != nthreads) |
163 | nwoken += futex_wake(&futex1, nwakes, FUTEX_PRIVATE_FLAG); | 168 | nwoken += futex_wake(&futex1, nwakes, futex_flag); |
164 | gettimeofday(&end, NULL); | 169 | gettimeofday(&end, NULL); |
165 | timersub(&end, &start, &runtime); | 170 | timersub(&end, &start, &runtime); |
166 | 171 | ||