File perf-bench-futex-wake-restore-thread-count-default-to-online-cpu-count.patch of Package perf
73
1
From: Tommi Rantala <tommi.t.rantala@nokia.com>
2
Date: Thu, 5 Mar 2020 10:37:13 +0200
3
Subject: perf bench futex-wake: Restore thread count default to online CPU
4
count
5
Git-commit: f649bd9dd5d5004543bbc3c50b829577b49f5d75
6
Patch-mainline: v5.6-rc6
7
References: git-fixes
8
9
Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the default
10
number of threads the benchmark uses got changed from number of online
11
CPUs to zero:
12
13
$ perf bench futex wake
14
# Running 'futex/wake' benchmark:
15
Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time.
16
[Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
17
[...]
18
[Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
19
Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)
20
21
Restore the old behavior by grabbing the number of online CPUs via
22
cpu->nr:
23
24
$ perf bench futex wake
25
# Running 'futex/wake' benchmark:
26
Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time.
27
[Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
28
[...]
29
[Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
30
Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)
31
32
Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")
33
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
34
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
35
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
36
Cc: Darren Hart <dvhart@infradead.org>
37
Cc: Davidlohr Bueso <dave@stgolabs.net>
38
Cc: Jiri Olsa <jolsa@redhat.com>
39
Cc: Mark Rutland <mark.rutland@arm.com>
40
Cc: Namhyung Kim <namhyung@kernel.org>
41
Cc: Peter Zijlstra <peterz@infradead.org>
42
Cc: Thomas Gleixner <tglx@linutronix.de>
43
Link: http://lore.kernel.org/lkml/20200305083714.9381-3-tommi.t.rantala@nokia.com
44
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
45
Signed-off-by: Tony Jones <tonyj@suse.de>
46
---
47
tools/perf/bench/futex-wake.c | 4 ++--
48
1 file changed, 2 insertions(+), 2 deletions(-)
49
50
diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
51
index df810096abfe..58906e9499bb 100644
52
--- a/tools/perf/bench/futex-wake.c
53
+++ b/tools/perf/bench/futex-wake.c
54
55
static pthread_mutex_t thread_lock;
56
static pthread_cond_t thread_parent, thread_worker;
57
static struct stats waketime_stats, wakeup_stats;
58
-static unsigned int ncpus, threads_starting, nthreads = 0;
59
+static unsigned int threads_starting, nthreads = 0;
60
static int futex_flag = 0;
61
62
static const struct option options[] = {
63
64
sigaction(SIGINT, &act, NULL);
65
66
if (!nthreads)
67
- nthreads = ncpus;
68
+ nthreads = cpu->nr;
69
70
worker = calloc(nthreads, sizeof(*worker));
71
if (!worker)
72
73