From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Darren Hart <darren@dvhart.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Michael Kerrisk <mtk.manpages@googlemail.com>,
Davidlohr Bueso <dave@stgolabs.net>, Chris Mason <clm@fb.com>,
"Carlos O'Donell" <carlos@redhat.com>,
Torvald Riegel <triegel@redhat.com>,
Eric Dumazet <edumazet@google.com>
Subject: [patch V2 6/7] perf/bench/futex-hash: Support preallocate hash table
Date: Thu, 05 May 2016 20:44:07 -0000 [thread overview]
Message-ID: <20160505204354.302814521@linutronix.de> (raw)
In-Reply-To: 20160505204230.932454245@linutronix.de
[-- Attachment #1: perf-bench-futex-hash-Support-preallocate-hash-table.patch --]
[-- Type: text/plain, Size: 2578 bytes --]
Instead of using the default hash size on the first allocation it is
possible to allocate a specific number of slots upfront.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
tools/perf/bench/futex-hash.c | 16 ++++++++++++++--
tools/perf/bench/futex.h | 5 +++++
2 files changed, 19 insertions(+), 2 deletions(-)
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -30,6 +30,7 @@ static unsigned int nsecs = 10;
static unsigned int nfutexes = 1024;
static bool fshared = false, done = false, silent = false;
static int futex_flag = 0;
+static unsigned int prealloc;
static int numa_node = -1;
struct timeval start, end, runtime;
@@ -51,6 +52,7 @@ static const struct option options[] = {
OPT_UINTEGER('f', "futexes", &nfutexes, "Specify amount of futexes per threads"),
OPT_BOOLEAN( 's', "silent", &silent, "Silent mode: do not display data/details"),
OPT_BOOLEAN( 'S', "shared", &fshared, "Use shared futexes instead of private ones"),
+ OPT_UINTEGER('p', "prealloc",&prealloc, "Specify number of preallocated hash slots"),
#ifdef CONFIG_NUMA
OPT_INTEGER( 'n', "numa", &numa_node, "Specify the NUMA node"),
#endif
@@ -138,6 +140,7 @@ int bench_futex_hash(int argc, const cha
unsigned int i, ncpus;
pthread_attr_t thread_attr;
struct worker *worker = NULL;
+ char *prealloc_str = NULL;
char *node_str = NULL;
unsigned int cpunum;
@@ -192,11 +195,20 @@ int bench_futex_hash(int argc, const cha
if (!fshared)
futex_flag = FUTEX_PRIVATE_FLAG;
- printf("Run summary [PID %d]: %d threads%s, each operating on %d [%s] futexes for %d secs.\n\n",
+ if (prealloc) {
+ ret = futex_preallocate(prealloc);
+ if (ret < 0)
+ err(EXIT_FAILURE, "futex_prealloate");
+ ret = asprintf(&prealloc_str, " P %u %d", prealloc, ret);
+ if (ret < 0)
+ err(EXIT_FAILURE, "futex_preallocate, asprintf");
+ }
+
+ printf("Run summary [PID %d]: %d threads%s, each operating on %d [%s%s] futexes for %d secs.\n\n",
getpid(), nthreads,
node_str ? : "",
nfutexes, fshared ? "shared":"private",
- nsecs);
+ prealloc_str ? : "", nsecs);
init_stats(&throughput_stats);
pthread_mutex_init(&thread_lock, NULL);
--- a/tools/perf/bench/futex.h
+++ b/tools/perf/bench/futex.h
@@ -101,4 +101,9 @@ static inline int pthread_attr_setaffini
}
#endif
+static inline int futex_preallocate(u_int32_t hash_size)
+{
+ return futex(0, FUTEX_PREALLOC_HASH, hash_size, NULL, NULL, 0, 0);
+}
+
#endif /* _FUTEX_H */
next prev parent reply other threads:[~2016-05-05 20:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 20:44 [patch V2 0/7] futex: Add support for process private hashing Thomas Gleixner
2016-05-05 20:44 ` [patch V2 1/7] futex: Add some more function commentry Thomas Gleixner
2016-05-06 17:37 ` Darren Hart
2016-05-05 20:44 ` [patch V2 2/7] futex: Hash private futexes per process Thomas Gleixner
2016-05-06 18:09 ` Darren Hart
2016-05-06 21:56 ` Darren Hart
2016-05-07 8:45 ` Thomas Gleixner
2016-05-11 21:08 ` Darren Hart
2016-05-07 8:44 ` Thomas Gleixner
2016-05-11 21:07 ` Darren Hart
2016-05-27 16:36 ` Sebastian Andrzej Siewior
2016-05-19 12:21 ` Peter Zijlstra
2016-05-27 16:52 ` Sebastian Andrzej Siewior
2016-05-30 8:43 ` Peter Zijlstra
2016-05-19 12:24 ` Peter Zijlstra
2016-05-27 17:10 ` Sebastian Andrzej Siewior
2016-05-30 8:58 ` Peter Zijlstra
2016-05-30 11:08 ` Sebastian Andrzej Siewior
2016-05-30 12:06 ` Peter Zijlstra
2016-05-30 13:37 ` Sebastian Andrzej Siewior
2016-05-30 13:49 ` Peter Zijlstra
2016-05-30 13:59 ` Sebastian Andrzej Siewior
2016-05-30 14:02 ` Peter Zijlstra
2016-05-05 20:44 ` [patch V2 4/7] futex: Add sysctl knobs for process private hash Thomas Gleixner
2016-05-06 18:22 ` Darren Hart
2016-05-27 17:33 ` Sebastian Andrzej Siewior
2016-05-05 20:44 ` [patch V2 3/7] futex: Add op for hash preallocation Thomas Gleixner
2016-05-06 18:18 ` Darren Hart
2016-05-07 8:47 ` Thomas Gleixner
2016-05-07 11:40 ` Thomas Gleixner
2016-05-19 12:28 ` Peter Zijlstra
2016-05-19 19:36 ` Darren Hart
2016-05-19 12:24 ` Peter Zijlstra
2016-05-19 19:38 ` Darren Hart
2016-05-20 4:50 ` Peter Zijlstra
2016-05-19 12:25 ` Peter Zijlstra
2016-05-27 17:27 ` Sebastian Andrzej Siewior
2016-05-30 8:59 ` Peter Zijlstra
2016-05-05 20:44 ` [patch V2 5/7] perf/bench/futex-hash: Support NUMA Thomas Gleixner
2016-05-05 20:44 ` Thomas Gleixner [this message]
2016-05-05 20:44 ` [patch V2 7/7] futex.2: Document hash preallocation opcode Thomas Gleixner
-- strict thread matches above, loose matches on Subject: below --
2016-05-05 19:03 [patch V2 0/7] Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Linus Torvalds <torvalds@linux-foundation.org>, Darren Hart <darren@dvhart.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>, Michael Kerrisk <mtk.manpages@googlemail.com>, Davidlohr Bueso <dave@stgolabs.net>, Chris Mason <clm@fb.com>, Carlos O'Donell <carlos@redhat.com>, Torvald Riegel <triegel@redhat.com>, Eric Dumazet <edumazet@google.com> Thomas Gleixner
2016-05-05 19:03 ` [patch V2 6/7] perf/bench/futex-hash: Support preallocate hash table Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160505204354.302814521@linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=carlos@redhat.com \
--cc=clm@fb.com \
--cc=darren@dvhart.com \
--cc=dave@stgolabs.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mtk.manpages@googlemail.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=triegel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).