From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
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: [RFC patch 5/7] perf/bench/futex-hash: Support for attached futexes
Date: Sat, 02 Apr 2016 11:09:19 -0000 [thread overview]
Message-ID: <20160402110035.894706642@linutronix.de> (raw)
In-Reply-To: 20160402095108.894519835@linutronix.de
[-- Attachment #1: perf-bench-futex-hash--Support-for-attached-futexes.patch --]
[-- Type: text/plain, Size: 3737 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
tools/perf/bench/futex-hash.c | 40 ++++++++++++++++++++++++++++++----------
tools/perf/bench/futex.h | 14 ++++++++++++++
2 files changed, 44 insertions(+), 10 deletions(-)
Index: b/tools/perf/bench/futex-hash.c
===================================================================
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -25,7 +25,7 @@ static unsigned int nthreads = 0;
static unsigned int nsecs = 10;
/* amount of futexes per thread */
static unsigned int nfutexes = 1024;
-static bool fshared = false, done = false, silent = false;
+static bool fshared = false, done = false, silent = false, attached = false;
static int futex_flag = 0;
struct timeval start, end, runtime;
@@ -42,11 +42,12 @@ struct worker {
};
static const struct option options[] = {
- OPT_UINTEGER('t', "threads", &nthreads, "Specify amount of threads"),
- OPT_UINTEGER('r', "runtime", &nsecs, "Specify runtime (in seconds)"),
- 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('t', "threads", &nthreads, "Specify amount of threads"),
+ OPT_UINTEGER('r', "runtime", &nsecs, "Specify runtime (in seconds)"),
+ 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_BOOLEAN( 'a', "attached", &attached, "Use attached futexes"),
OPT_END()
};
@@ -61,6 +62,14 @@ static void *workerfn(void *arg)
unsigned int i;
struct worker *w = (struct worker *) arg;
+ if (attached) {
+ for (i = 0; i < nfutexes; i++) {
+ ret = futex_attach(&w->futex[i], futex_flag);
+ if (ret < 0)
+ err(EXIT_FAILURE, "Attach futex failed\n");
+ }
+ }
+
pthread_mutex_lock(&thread_lock);
threads_starting--;
if (!threads_starting)
@@ -83,6 +92,14 @@ static void *workerfn(void *arg)
}
} while (!done);
+ if (attached) {
+ for (i = 0; i < nfutexes; i++) {
+ ret = futex_detach(&w->futex[i], futex_flag);
+ if (ret < 0)
+ err(EXIT_FAILURE, "Detach futex failed");
+ }
+ }
+
return NULL;
}
@@ -136,10 +153,13 @@ int bench_futex_hash(int argc, const cha
goto errmem;
if (!fshared)
- futex_flag = FUTEX_PRIVATE_FLAG;
-
- printf("Run summary [PID %d]: %d threads, each operating on %d [%s] futexes for %d secs.\n\n",
- getpid(), nthreads, nfutexes, fshared ? "shared":"private", nsecs);
+ futex_flag |= FUTEX_PRIVATE_FLAG;
+ if (attached)
+ futex_flag |= FUTEX_ATTACHED;
+
+ printf("Run summary [PID %d]: %d threads, each operating on %d [%s %s] futexes for %d secs.\n\n",
+ getpid(), nthreads, nfutexes, fshared ? "shared":"private",
+ attached ? "attached" : "", nsecs);
init_stats(&throughput_stats);
pthread_mutex_init(&thread_lock, NULL);
Index: b/tools/perf/bench/futex.h
===================================================================
--- a/tools/perf/bench/futex.h
+++ b/tools/perf/bench/futex.h
@@ -101,4 +101,18 @@ static inline int pthread_attr_setaffini
}
#endif
+#define FUTEX_ATTACH 13
+#define FUTEX_DETACH 14
+#define FUTEX_ATTACHED 512
+
+static inline int futex_attach(u_int32_t *uaddr, int opflags)
+{
+ return futex(uaddr, FUTEX_ATTACH, 0, NULL, NULL, 0, opflags);
+}
+
+static inline int futex_detach(u_int32_t *uaddr, int opflags)
+{
+ return futex(uaddr, FUTEX_DETACH, 0, NULL, NULL, 0, opflags);
+}
+
#endif /* _FUTEX_H */
next prev parent reply other threads:[~2016-04-02 11:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-02 11:09 [RFC patch 0/7] futex: Add support for attached futexes Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 1/7] futex: Provide helpers for hash bucket add/remove Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 2/7] futex: Add some more function commentry Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 3/7] futex: Make key init a helper function Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 4/7] futex: Add support for attached futexes Thomas Gleixner
2016-04-02 16:26 ` Peter Zijlstra
2016-04-02 18:01 ` Thomas Gleixner
2016-04-02 16:29 ` Peter Zijlstra
2016-04-03 9:59 ` Thomas Gleixner
2016-04-02 18:19 ` Andy Lutomirski
2016-04-03 9:57 ` Thomas Gleixner
2016-04-03 13:18 ` Andy Lutomirski
2016-04-03 15:56 ` Thomas Gleixner
2016-04-03 16:11 ` Andy Lutomirski
2016-04-02 23:48 ` Rasmus Villemoes
2016-04-03 10:05 ` Thomas Gleixner
2016-04-03 11:16 ` Ingo Molnar
2016-04-03 11:30 ` Linus Torvalds
2016-04-05 7:44 ` Torvald Riegel
2016-04-05 15:58 ` Carlos O'Donell
2016-04-02 11:09 ` Thomas Gleixner [this message]
2016-04-02 11:09 ` [RFC patch 7/7] [PATCH] glibc: nptl: Add support for attached pthread_mutexes Thomas Gleixner
2016-04-02 16:30 ` Peter Zijlstra
2016-04-02 16:32 ` Peter Zijlstra
2016-04-03 10:08 ` Thomas Gleixner
2016-04-02 11:09 ` [RFC patch 6/7] futex.2: Document attached mode 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=20160402110035.894706642@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=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