linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] perf bench futex: cache align the worer struct
@ 2016-10-16 19:08 Sebastian Andrzej Siewior
  2016-10-16 19:08 ` [PATCH 2/2] perf bench futex: add NUMA support Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-10-16 19:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, Davidlohr Bueso,
	Sebastian Andrzej Siewior

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.
The 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>
---
 tools/perf/bench/futex-hash.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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;
 static struct stats throughput_stats;
 static pthread_cond_t thread_parent, thread_worker;
 
+#define SMP_CACHE_BYTES 256
+#define __cacheline_aligned __attribute__ ((aligned (SMP_CACHE_BYTES)))
+
 struct worker {
 	int tid;
 	u_int32_t *futex;
 	pthread_t thread;
 	unsigned long ops;
-};
+} __cacheline_aligned;
 
 static const struct option options[] = {
 	OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"),
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-10-24 19:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-16 19:08 [PATCH 1/2] perf bench futex: cache align the worer struct Sebastian Andrzej Siewior
2016-10-16 19:08 ` [PATCH 2/2] perf bench futex: add NUMA support Sebastian Andrzej Siewior
2016-10-17 14:38   ` Arnaldo Carvalho de Melo
2016-10-17 15:01     ` Jiri Olsa
2016-10-17 15:04       ` Arnaldo Carvalho de Melo
2016-10-17 15:33         ` [PATCH 2/2 v2] " Sebastian Andrzej Siewior
2016-10-19 18:16           ` Davidlohr Bueso
2016-10-19 18:37             ` Sebastian Andrzej Siewior
2016-10-21  2:34               ` Davidlohr Bueso
2016-10-21  3:03           ` Davidlohr Bueso
2016-10-18  1:09 ` [PATCH 1/2] perf bench futex: cache align the worer struct Davidlohr Bueso
2016-10-19 13:07   ` Sebastian Andrzej Siewior
2016-10-19 17:59     ` [PATCH] perf/bench-futex: Avoid worker cacheline bouncing Davidlohr Bueso
2016-10-19 18:13       ` Sebastian Andrzej Siewior
2016-10-19 18:41         ` Davidlohr Bueso
2016-10-24 19:06 ` [tip:perf/core] perf bench futex: Cache align the worker struct tip-bot for Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).