diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-10-16 15:08:02 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-10-24 10:07:45 -0400 |
commit | 34b753007d646482a4125a7095e1d1986d395f95 (patch) | |
tree | 266d4c9ebb091a9bcc6f7b2268ef13abf0125ed3 /tools/perf | |
parent | 899735066a8d945b7ae56a34847298fd0dd2104b (diff) |
perf bench futex: Cache align the worker struct
It popped up in perf testing that the worker consumes some amount of
CPU. It boils down to the increment of `ops` which causes cache line
bouncing between the individual threads.
This patch aligns the struct by 256 bytes to ensure that not a cache
line is shared among CPUs. 128 byte is the x86 worst case and grep says
that L1_CACHE_SHIFT is set to 8 on s390.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20161016190803.3392-1-bigeasy@linutronix.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/bench/futex-hash.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c index 8024cd5febd2..d9e5e80bb4d0 100644 --- a/tools/perf/bench/futex-hash.c +++ b/tools/perf/bench/futex-hash.c | |||
@@ -39,12 +39,15 @@ static unsigned int threads_starting; | |||
39 | static struct stats throughput_stats; | 39 | static struct stats throughput_stats; |
40 | static pthread_cond_t thread_parent, thread_worker; | 40 | static pthread_cond_t thread_parent, thread_worker; |
41 | 41 | ||
42 | #define SMP_CACHE_BYTES 256 | ||
43 | #define __cacheline_aligned __attribute__ ((aligned (SMP_CACHE_BYTES))) | ||
44 | |||
42 | struct worker { | 45 | struct worker { |
43 | int tid; | 46 | int tid; |
44 | u_int32_t *futex; | 47 | u_int32_t *futex; |
45 | pthread_t thread; | 48 | pthread_t thread; |
46 | unsigned long ops; | 49 | unsigned long ops; |
47 | }; | 50 | } __cacheline_aligned; |
48 | 51 | ||
49 | static const struct option options[] = { | 52 | static const struct option options[] = { |
50 | OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"), | 53 | OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"), |