aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/futex-requeue.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2014-09-29 12:41:08 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-09-29 14:43:26 -0400
commite19685ed24b518440c0717719ff02e74c0e6d2cb (patch)
tree8753b39b7d2ca95b45304b14cc6e4e87f84fd0a4 /tools/perf/bench/futex-requeue.c
parent86c87e13f8a5dffc6cc7b0f37340f815dc172945 (diff)
perf bench futex: Sanitize -q option in requeue
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>
Diffstat (limited to 'tools/perf/bench/futex-requeue.c')
-rw-r--r--tools/perf/bench/futex-requeue.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
index 9837a8831406..bedff6b5b3cf 100644
--- a/tools/perf/bench/futex-requeue.c
+++ b/tools/perf/bench/futex-requeue.c
@@ -172,6 +172,9 @@ int bench_futex_requeue(int argc, const char **argv,
172 gettimeofday(&end, NULL); 172 gettimeofday(&end, NULL);
173 timersub(&end, &start, &runtime); 173 timersub(&end, &start, &runtime);
174 174
175 if (nrequeued > nthreads)
176 nrequeued = nthreads;
177
175 update_stats(&requeued_stats, nrequeued); 178 update_stats(&requeued_stats, nrequeued);
176 update_stats(&requeuetime_stats, runtime.tv_usec); 179 update_stats(&requeuetime_stats, runtime.tv_usec);
177 180
@@ -190,7 +193,6 @@ int bench_futex_requeue(int argc, const char **argv,
190 if (ret) 193 if (ret)
191 err(EXIT_FAILURE, "pthread_join"); 194 err(EXIT_FAILURE, "pthread_join");
192 } 195 }
193
194 } 196 }
195 197
196 /* cleanup & report results */ 198 /* cleanup & report results */