Skip to content

Commit

Permalink
perf bench futex: Sanitize -q option in requeue
Browse files Browse the repository at this point in the history
When given the number of threads to requeue at once by user input,
there's always the risk of this value being larger than the total number
of threads.  This doesn't make any sense, and the kernel can easily deal
with such sort of situations, hence no big deal. We should however
prevent bogus output such as:

./perf bench --repeat 2 futex requeue -q 10
Run summary [PID 22210]: Requeuing 4 threads (from [private] 0x99ef3c to 0x99ef38), 10 at a time.

[Run 1]: Requeued 10 of 4 threads in 0.0040 ms
[Run 2]: Requeued 10 of 4 threads in 0.0030 ms
Requeued 10 of 4 threads in 0.0035 ms (+-14.29%)

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Davidlohr Bueso <dbueso@suse.de>
Link: http://lkml.kernel.org/r/1412008868-22328-2-git-send-email-dave@stgolabs.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Davidlohr Bueso authored and Arnaldo Carvalho de Melo committed Sep 29, 2014
1 parent 86c87e1 commit e19685e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/perf/bench/futex-requeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ int bench_futex_requeue(int argc, const char **argv,
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);

if (nrequeued > nthreads)
nrequeued = nthreads;

update_stats(&requeued_stats, nrequeued);
update_stats(&requeuetime_stats, runtime.tv_usec);

Expand All @@ -190,7 +193,6 @@ int bench_futex_requeue(int argc, const char **argv,
if (ret)
err(EXIT_FAILURE, "pthread_join");
}

}

/* cleanup & report results */
Expand Down

0 comments on commit e19685e

Please sign in to comment.