diff options
author | Jiri Kosina <jkosina@suse.cz> | 2020-04-01 13:32:45 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2020-04-01 13:32:45 +0200 |
commit | 4c805fb704fc7890ec6615b286f09aeb5e2603d4 (patch) | |
tree | 24f79be444c9dd3df7116037fd3bd3e17b01ebd3 /tools/perf/bench/futex-hash.c | |
parent | f454d9a378a1ccb676adfa6e2449ef17e66696b5 (diff) | |
parent | 77a36a3ab4ff17fad23831192e3694a3c5a1750d (diff) | |
download | linux-4c805fb704fc7890ec6615b286f09aeb5e2603d4.tar.bz2 |
Merge branch 'for-5.7/glorious' into for-linus
- report descriptor fix for Glorious PC Gaming Race device from Samuel Čavoj
Diffstat (limited to 'tools/perf/bench/futex-hash.c')
-rw-r--r-- | tools/perf/bench/futex-hash.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c index 8ba0c3330a9a..65eebe06c04d 100644 --- a/tools/perf/bench/futex-hash.c +++ b/tools/perf/bench/futex-hash.c @@ -37,7 +37,7 @@ static unsigned int nfutexes = 1024; static bool fshared = false, done = false, silent = false; static int futex_flag = 0; -struct timeval start, end, runtime; +struct timeval bench__start, bench__end, bench__runtime; static pthread_mutex_t thread_lock; static unsigned int threads_starting; static struct stats throughput_stats; @@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_unused, { /* inform all threads that we're done for the day */ done = true; - gettimeofday(&end, NULL); - timersub(&end, &start, &runtime); + gettimeofday(&bench__end, NULL); + timersub(&bench__end, &bench__start, &bench__runtime); } static void print_summary(void) @@ -114,7 +114,7 @@ static void print_summary(void) printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), - (int) runtime.tv_sec); + (int)bench__runtime.tv_sec); } int bench_futex_hash(int argc, const char **argv) @@ -137,6 +137,7 @@ int bench_futex_hash(int argc, const char **argv) if (!cpu) goto errmem; + memset(&act, 0, sizeof(act)); sigfillset(&act.sa_mask); act.sa_sigaction = toggle_done; sigaction(SIGINT, &act, NULL); @@ -161,7 +162,7 @@ int bench_futex_hash(int argc, const char **argv) threads_starting = nthreads; pthread_attr_init(&thread_attr); - gettimeofday(&start, NULL); + gettimeofday(&bench__start, NULL); for (i = 0; i < nthreads; i++) { worker[i].tid = i; worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex)); @@ -204,7 +205,7 @@ int bench_futex_hash(int argc, const char **argv) pthread_mutex_destroy(&thread_lock); for (i = 0; i < nthreads; i++) { - unsigned long t = worker[i].ops/runtime.tv_sec; + unsigned long t = worker[i].ops / bench__runtime.tv_sec; update_stats(&throughput_stats, t); if (!silent) { if (nfutexes == 1) |