diff options
author | Davidlohr Bueso <dave@stgolabs.net> | 2015-04-24 13:00:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-27 12:57:49 -0400 |
commit | 052b0f6eaf8b1f02669884a177bc3ce463133a42 (patch) | |
tree | 5384301c97a338573a97a7612105410d1c3e0dab /tools | |
parent | d13855ef18e1852b2c4dc86ddf5759c5b34628cb (diff) |
perf bench futex: Fix hung wakeup tasks after requeueing
The futex-requeue benchmark can hang because of missing wakeups once the
benchmark is done, ie:
[Run 1]: Requeued 1024 of 1024 threads in 0.3290 ms
perf: couldn't wakeup all tasks (135/1024)
This bug, while perhaps suggesting missing wakeups in kernel futex code,
is merely a consequence of the crappy FUTEX_CMP_REQUEUE man page,
incorrectly mentioning that the number of requeued tasks is in fact
returned, not the wakeups.
This patch acknowledges this and updates the corresponding futex_wake
code around it.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Mel Gorman <mgorman@suse.de>
Link: http://lkml.kernel.org/r/1429894848.10273.44.camel@stgolabs.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/bench/futex-requeue.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c index bedff6b5b3cf..ad0d9b5342fb 100644 --- a/tools/perf/bench/futex-requeue.c +++ b/tools/perf/bench/futex-requeue.c | |||
@@ -132,6 +132,9 @@ int bench_futex_requeue(int argc, const char **argv, | |||
132 | if (!fshared) | 132 | if (!fshared) |
133 | futex_flag = FUTEX_PRIVATE_FLAG; | 133 | futex_flag = FUTEX_PRIVATE_FLAG; |
134 | 134 | ||
135 | if (nrequeue > nthreads) | ||
136 | nrequeue = nthreads; | ||
137 | |||
135 | printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), " | 138 | printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), " |
136 | "%d at a time.\n\n", getpid(), nthreads, | 139 | "%d at a time.\n\n", getpid(), nthreads, |
137 | fshared ? "shared":"private", &futex1, &futex2, nrequeue); | 140 | fshared ? "shared":"private", &futex1, &futex2, nrequeue); |
@@ -161,20 +164,18 @@ int bench_futex_requeue(int argc, const char **argv, | |||
161 | 164 | ||
162 | /* Ok, all threads are patiently blocked, start requeueing */ | 165 | /* Ok, all threads are patiently blocked, start requeueing */ |
163 | gettimeofday(&start, NULL); | 166 | gettimeofday(&start, NULL); |
164 | for (nrequeued = 0; nrequeued < nthreads; nrequeued += nrequeue) { | 167 | while (nrequeued < nthreads) { |
165 | /* | 168 | /* |
166 | * Do not wakeup any tasks blocked on futex1, allowing | 169 | * Do not wakeup any tasks blocked on futex1, allowing |
167 | * us to really measure futex_wait functionality. | 170 | * us to really measure futex_wait functionality. |
168 | */ | 171 | */ |
169 | futex_cmp_requeue(&futex1, 0, &futex2, 0, | 172 | nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0, |
170 | nrequeue, futex_flag); | 173 | nrequeue, futex_flag); |
171 | } | 174 | } |
175 | |||
172 | gettimeofday(&end, NULL); | 176 | gettimeofday(&end, NULL); |
173 | timersub(&end, &start, &runtime); | 177 | timersub(&end, &start, &runtime); |
174 | 178 | ||
175 | if (nrequeued > nthreads) | ||
176 | nrequeued = nthreads; | ||
177 | |||
178 | update_stats(&requeued_stats, nrequeued); | 179 | update_stats(&requeued_stats, nrequeued); |
179 | update_stats(&requeuetime_stats, runtime.tv_usec); | 180 | update_stats(&requeuetime_stats, runtime.tv_usec); |
180 | 181 | ||
@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv, | |||
184 | } | 185 | } |
185 | 186 | ||
186 | /* everybody should be blocked on futex2, wake'em up */ | 187 | /* everybody should be blocked on futex2, wake'em up */ |
187 | nrequeued = futex_wake(&futex2, nthreads, futex_flag); | 188 | nrequeued = futex_wake(&futex2, nrequeued, futex_flag); |
188 | if (nthreads != nrequeued) | 189 | if (nthreads != nrequeued) |
189 | warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads); | 190 | warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads); |
190 | 191 | ||