* [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing
@ 2015-04-24 17:00 Davidlohr Bueso
2015-04-24 17:50 ` David Ahern
2015-05-01 10:15 ` [tip:perf/urgent] perf bench futex: " tip-bot for Davidlohr Bueso
0 siblings, 2 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2015-04-24 17:00 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Mel Gorman, linux-kernel, Davidlohr Bueso
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>
---
tools/perf/bench/futex-requeue.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
index bedff6b..ad0d9b5 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,
if (!fshared)
futex_flag = FUTEX_PRIVATE_FLAG;
+ if (nrequeue > nthreads)
+ nrequeue = nthreads;
+
printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), "
"%d at a time.\n\n", getpid(), nthreads,
fshared ? "shared":"private", &futex1, &futex2, nrequeue);
@@ -161,20 +164,18 @@ int bench_futex_requeue(int argc, const char **argv,
/* Ok, all threads are patiently blocked, start requeueing */
gettimeofday(&start, NULL);
- for (nrequeued = 0; nrequeued < nthreads; nrequeued += nrequeue) {
+ while (nrequeued < nthreads) {
/*
* Do not wakeup any tasks blocked on futex1, allowing
* us to really measure futex_wait functionality.
*/
- futex_cmp_requeue(&futex1, 0, &futex2, 0,
- nrequeue, futex_flag);
+ nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0,
+ nrequeue, futex_flag);
}
+
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
- if (nrequeued > nthreads)
- nrequeued = nthreads;
-
update_stats(&requeued_stats, nrequeued);
update_stats(&requeuetime_stats, runtime.tv_usec);
@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv,
}
/* everybody should be blocked on futex2, wake'em up */
- nrequeued = futex_wake(&futex2, nthreads, futex_flag);
+ nrequeued = futex_wake(&futex2, nrequeued, futex_flag);
if (nthreads != nrequeued)
warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing
2015-04-24 17:00 [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing Davidlohr Bueso
@ 2015-04-24 17:50 ` David Ahern
2015-04-24 17:57 ` Davidlohr Bueso
2015-05-01 10:15 ` [tip:perf/urgent] perf bench futex: " tip-bot for Davidlohr Bueso
1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2015-04-24 17:50 UTC (permalink / raw)
To: Davidlohr Bueso, Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Mel Gorman, linux-kernel
On 4/24/15 11:00 AM, Davidlohr Bueso wrote:
> 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.
Did you submit an update to fix the crappy man page?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing
2015-04-24 17:50 ` David Ahern
@ 2015-04-24 17:57 ` Davidlohr Bueso
0 siblings, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2015-04-24 17:57 UTC (permalink / raw)
To: David Ahern
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Mel Gorman, linux-kernel
On Fri, 2015-04-24 at 11:50 -0600, David Ahern wrote:
> On 4/24/15 11:00 AM, Davidlohr Bueso wrote:
> > 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.
>
> Did you submit an update to fix the crappy man page?
There is a major manpage rewrite going on. Hopefully Michael will merge
it soon.
Thanks,
Davidlohr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf bench futex: Fix hung wakeup tasks after requeueing
2015-04-24 17:00 [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing Davidlohr Bueso
2015-04-24 17:50 ` David Ahern
@ 2015-05-01 10:15 ` tip-bot for Davidlohr Bueso
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Davidlohr Bueso @ 2015-05-01 10:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, mgorman, dave, acme, dbueso, hpa, linux-kernel, tglx
Commit-ID: 052b0f6eaf8b1f02669884a177bc3ce463133a42
Gitweb: http://git.kernel.org/tip/052b0f6eaf8b1f02669884a177bc3ce463133a42
Author: Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Fri, 24 Apr 2015 10:00:48 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 27 Apr 2015 13:57:49 -0300
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>
---
tools/perf/bench/futex-requeue.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
index bedff6b..ad0d9b5 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,
if (!fshared)
futex_flag = FUTEX_PRIVATE_FLAG;
+ if (nrequeue > nthreads)
+ nrequeue = nthreads;
+
printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), "
"%d at a time.\n\n", getpid(), nthreads,
fshared ? "shared":"private", &futex1, &futex2, nrequeue);
@@ -161,20 +164,18 @@ int bench_futex_requeue(int argc, const char **argv,
/* Ok, all threads are patiently blocked, start requeueing */
gettimeofday(&start, NULL);
- for (nrequeued = 0; nrequeued < nthreads; nrequeued += nrequeue) {
+ while (nrequeued < nthreads) {
/*
* Do not wakeup any tasks blocked on futex1, allowing
* us to really measure futex_wait functionality.
*/
- futex_cmp_requeue(&futex1, 0, &futex2, 0,
- nrequeue, futex_flag);
+ nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0,
+ nrequeue, futex_flag);
}
+
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
- if (nrequeued > nthreads)
- nrequeued = nthreads;
-
update_stats(&requeued_stats, nrequeued);
update_stats(&requeuetime_stats, runtime.tv_usec);
@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv,
}
/* everybody should be blocked on futex2, wake'em up */
- nrequeued = futex_wake(&futex2, nthreads, futex_flag);
+ nrequeued = futex_wake(&futex2, nrequeued, futex_flag);
if (nthreads != nrequeued)
warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-05-01 10:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24 17:00 [PATCH] perf-bench/futex: Fix hung wakeup tasks after requeueing Davidlohr Bueso
2015-04-24 17:50 ` David Ahern
2015-04-24 17:57 ` Davidlohr Bueso
2015-05-01 10:15 ` [tip:perf/urgent] perf bench futex: " tip-bot for Davidlohr Bueso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.