Skip to content

Commit f649bd9

Browse files
rantalaacmel
authored andcommitted
perf bench futex-wake: Restore thread count default to online CPU count
Since commit 3b2323c ("perf bench futex: Use cpumaps") the default number of threads the benchmark uses got changed from number of online CPUs to zero: $ perf bench futex wake # Running 'futex/wake' benchmark: Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time. [Run 1]: Wokeup 0 of 0 threads in 0.0000 ms [...] [Run 10]: Wokeup 0 of 0 threads in 0.0000 ms Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%) Restore the old behavior by grabbing the number of online CPUs via cpu->nr: $ perf bench futex wake # Running 'futex/wake' benchmark: Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time. [Run 1]: Wokeup 8 of 8 threads in 0.0260 ms [...] [Run 10]: Wokeup 8 of 8 threads in 0.0270 ms Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%) Fixes: 3b2323c ("perf bench futex: Use cpumaps") Signed-off-by: Tommi Rantala <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Darren Hart <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 29b4f5f commit f649bd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/perf/bench/futex-wake.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false;
4343
static pthread_mutex_t thread_lock;
4444
static pthread_cond_t thread_parent, thread_worker;
4545
static struct stats waketime_stats, wakeup_stats;
46-
static unsigned int ncpus, threads_starting, nthreads = 0;
46+
static unsigned int threads_starting, nthreads = 0;
4747
static int futex_flag = 0;
4848

4949
static const struct option options[] = {
@@ -141,7 +141,7 @@ int bench_futex_wake(int argc, const char **argv)
141141
sigaction(SIGINT, &act, NULL);
142142

143143
if (!nthreads)
144-
nthreads = ncpus;
144+
nthreads = cpu->nr;
145145

146146
worker = calloc(nthreads, sizeof(*worker));
147147
if (!worker)

0 commit comments

Comments
 (0)