Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1507608

[tip:perf/core] perf bench futex: Cache align the worker struct

From tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf bench futex: Cache align the worker struct
Date 2016-10-24 21:10 +0200
Message-ID <svSNb-3nI-7@gated-at.bofh.it> (permalink)
References <ssYYN-1qy-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  34b753007d646482a4125a7095e1d1986d395f95
Gitweb:     http://git.kernel.org/tip/34b753007d646482a4125a7095e1d1986d395f95
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Sun, 16 Oct 2016 21:08:02 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 24 Oct 2016 11:07:45 -0300

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>
---
 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 8024cd5..d9e5e80 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"),

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] perf bench futex: cache align the worer struct Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-16 21:10 +0200
  [PATCH 2/2] perf bench futex: add NUMA support Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-16 21:10 +0200
    Re: [PATCH 2/2] perf bench futex: add NUMA support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-17 16:40 +0200
      Re: [PATCH 2/2] perf bench futex: add NUMA support Jiri Olsa <jolsa@redhat.com> - 2016-10-17 17:10 +0200
        Re: [PATCH 2/2] perf bench futex: add NUMA support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-17 17:10 +0200
          [PATCH 2/2 v2] perf bench futex: add NUMA support Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-17 17:40 +0200
            Re: [PATCH 2/2 v2] perf bench futex: add NUMA support Davidlohr Bueso <dave@stgolabs.net> - 2016-10-19 20:20 +0200
              Re: [PATCH 2/2 v2] perf bench futex: add NUMA support Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-19 20:40 +0200
                Re: [PATCH 2/2 v2] perf bench futex: add NUMA support Davidlohr Bueso <dave@stgolabs.net> - 2016-10-21 04:40 +0200
            Re: [PATCH 2/2 v2] perf bench futex: add NUMA support Davidlohr Bueso <dave@stgolabs.net> - 2016-10-21 05:10 +0200
  Re: [PATCH 1/2] perf bench futex: cache align the worer struct Davidlohr Bueso <dave@stgolabs.net> - 2016-10-18 03:20 +0200
    Re: [PATCH 1/2] perf bench futex: cache align the worer struct Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-19 16:40 +0200
      [PATCH] perf/bench-futex: Avoid worker cacheline bouncing Davidlohr Bueso <dave@stgolabs.net> - 2016-10-19 20:10 +0200
        Re: [PATCH] perf/bench-futex: Avoid worker cacheline bouncing Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-19 20:20 +0200
          Re: [PATCH] perf/bench-futex: Avoid worker cacheline bouncing Davidlohr Bueso <dave@stgolabs.net> - 2016-10-19 20:50 +0200
  [tip:perf/core] perf bench futex: Cache align the worker struct tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com> - 2016-10-24 21:10 +0200

csiph-web