Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941230AbcJXTH4 (ORCPT ); Mon, 24 Oct 2016 15:07:56 -0400 Received: from terminus.zytor.com ([198.137.202.10]:47170 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938741AbcJXTHB (ORCPT ); Mon, 24 Oct 2016 15:07:01 -0400 Date: Mon, 24 Oct 2016 12:06:24 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: acme@redhat.com, peterz@infradead.org, tglx@linutronix.de, dbueso@suse.de, hpa@zytor.com, mingo@kernel.org, bigeasy@linutronix.de, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, dbueso@suse.de, hpa@zytor.com, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, peterz@infradead.org In-Reply-To: <20161016190803.3392-1-bigeasy@linutronix.de> References: <20161016190803.3392-1-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf bench futex: Cache align the worker struct Git-Commit-ID: 34b753007d646482a4125a7095e1d1986d395f95 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1787 Lines: 47 Commit-ID: 34b753007d646482a4125a7095e1d1986d395f95 Gitweb: http://git.kernel.org/tip/34b753007d646482a4125a7095e1d1986d395f95 Author: Sebastian Andrzej Siewior AuthorDate: Sun, 16 Oct 2016 21:08:02 +0200 Committer: Arnaldo Carvalho de Melo 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 Cc: Davidlohr Bueso Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161016190803.3392-1-bigeasy@linutronix.de Signed-off-by: Arnaldo Carvalho de Melo --- 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"),