aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/futex-hash.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2014-09-29 09:41:07 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-09-29 15:43:21 -0300
commit86c87e13f8a5dffc6cc7b0f37340f815dc172945 (patch)
tree4f391df8bf01d696425805dac591696ea9f4471a /tools/perf/bench/futex-hash.c
parentperf trace: Fix mmap return address truncation to 32-bit (diff)
downloadlinux-dev-86c87e13f8a5dffc6cc7b0f37340f815dc172945.tar.xz
linux-dev-86c87e13f8a5dffc6cc7b0f37340f815dc172945.zip
perf bench futex: Support operations for shared futexes
Unlike futex-hash, requeuing and wakeup benchmarks do not support shared futexes, limiting the usefulness of the programs. Correct this, and allow using the local -S parameter. The default remains using private futexes. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Cc: Davidlohr Bueso <dbueso@suse.de> Link: http://lkml.kernel.org/r/1412008868-22328-1-git-send-email-dave@stgolabs.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/futex-hash.c')
-rw-r--r--tools/perf/bench/futex-hash.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
index a84206e9c4aa..fc9bebd2cca0 100644
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -26,6 +26,7 @@ static unsigned int nsecs = 10;
/* amount of futexes per thread */
static unsigned int nfutexes = 1024;
static bool fshared = false, done = false, silent = false;
+static int futex_flag = 0;
struct timeval start, end, runtime;
static pthread_mutex_t thread_lock;
@@ -75,8 +76,7 @@ static void *workerfn(void *arg)
* such as internal waitqueue handling, thus enlarging
* the critical region protected by hb->lock.
*/
- ret = futex_wait(&w->futex[i], 1234, NULL,
- fshared ? 0 : FUTEX_PRIVATE_FLAG);
+ ret = futex_wait(&w->futex[i], 1234, NULL, futex_flag);
if (!silent &&
(!ret || errno != EAGAIN || errno != EWOULDBLOCK))
warn("Non-expected futex return call");
@@ -135,6 +135,9 @@ int bench_futex_hash(int argc, const char **argv,
if (!worker)
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);