perf-bench-futex: Add lock_pi stresser
Subsystems (2)
Davidlohr Bueso
reviewerPATCH 1/1 perf-bench-futex: Add lock_pi stresser
Allows a way of measuring low level kernel implementation of FUTEX_LOCK_PI and FUTEX_UNLOCK_PI. The program comes in two flavors: (i) single futex (default), all threads contend on the same uaddr. For the sake of the benchmark, we call into kernel space even when the lock is uncontended. The kernel will set it to TID, any waters that come in and contend for the pi futex will be handled respectively by the kernel. (ii) -M option for multiple futexes, each thread deals with its own futex. This is a trivial scenario and only measures kernel handling of 0->TID transition.
--- tools/perf/Documentation/perf-bench.txt | 4 + tools/perf/bench/Build | 1 + tools/perf/bench/bench.h | 2 + tools/perf/bench/futex-lock-pi.c | 219 ++++++++++++++++++++++++++++++++ tools/perf/bench/futex.h | 20 +++ tools/perf/builtin-bench.c | 2 + 6 files changed, 248 insertions(+) create mode 100644 tools/perf/bench/futex-lock-pi.c
tools/perf/Documentation/perf-bench.txt +4 -0
@@ -216,6 +216,10 @@ Suite for evaluating parallel wake calls. *requeue*:: Suite for evaluating requeue calls. +*lock-pi*:: +Suite for evaluating futex lock_pi calls. + + SEE ALSO -------- linkperf:perf[1]
tools/perf/bench/Build +1 -0
@@ -5,6 +5,7 @@ perf-y += futex-hash.o perf-y += futex-wake.o perf-y += futex-wake-parallel.o perf-y += futex-requeue.o +perf-y += futex-lock-pi.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
tools/perf/bench/bench.h +2 -0
@@ -36,6 +36,8 @@ extern int bench_futex_wake(int argc, const char **argv, const char *prefix);extern int bench_futex_wake_parallel (int argc,const char **argv,const char *prefix);extern int bench_futex_requeue (int argc,const char **argv,const char *prefix); +/* pi futexes */ +extern int bench_futex_lock_pi (int argc,const char **argv,const char *prefix);#define BENCH_FORMAT_DEFAULT_STR "default"#define BENCH_FORMAT_DEFAULT 0
tools/perf/bench/futex-lock-pi.c new file +219 -0
219 lines not on this page · raw message
tools/perf/bench/futex.h +20 -0
@@ -56,6 +56,26 @@ futex_wake(u_int32_t *uaddr, int nr_wake, int opflags) }/** +* futex_lock_pi() - block on uaddr as a PI mutex +* @detect: whether (1) or not (0) to perform deadlock detection +*/ +static inline int +futex_lock_pi (u_int32_t *uaddr,struct timespec *timeout,int detect, +int opflags) +{ +return futex (uaddr,FUTEX_LOCK_PI , detect, timeout,NULL ,0 , opflags); +} + +/** +* futex_unlock_pi() - release uaddr as a PI mutex, waking the top waiter +*/ +static inline int +futex_unlock_pi (u_int32_t *uaddr,int opflags) +{ +return futex (uaddr,FUTEX_UNLOCK_PI ,0 ,NULL ,NULL ,0 , opflags); +} + +/** * futex_cmp_requeue() - requeue tasks from uaddr to uaddr2 * @nr_wake: wake up to this many tasks * @nr_requeue: requeue up to this many tasks
tools/perf/builtin-bench.c +2 -0
@@ -60,6 +60,8 @@ static struct bench futex_benchmarks[] = { { "wake", "Benchmark for futex wake calls", bench_futex_wake }, { "wake-parallel", "Benchmark for parallel futex wake calls", bench_futex_wake_parallel }, { "requeue", "Benchmark for futex requeue calls", bench_futex_requeue }, +/* pi-futexes */ + { "lock-pi", "Benchmark for futex lock_pi calls", bench_futex_lock_pi }, { "all", "Test all futex benchmarks", NULL }, { NULL, NULL, NULL } };
Signature · 1 line
2.1.4
tip-bot for Davidlohr Bueso
merge bot[tip:perf/core] perf bench futex: Add lock_pi stresser
perf bench futex: Add lock_pi stresser
Commit-ID: d2f3f5d2e9cae6e73f9642a5ddc8c8a07c35e79b Gitweb: http://git.kernel.org/tip/d2f3f5d2e9cae6e73f9642a5ddc8c8a07c35e79b Author: Davidlohr Bueso <[email protected]> AuthorDate: Tue, 7 Jul 2015 01:55:53 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 20 Jul 2015 17:49:51 -0300
perf bench futex: Add lock_pi stresser
Allows a way of measuring low level kernel implementation of FUTEX_LOCK_PI and FUTEX_UNLOCK_PI.
The program comes in two flavors:
(i) single futex (default), all threads contend on the same uaddr. For the sake of the benchmark, we call into kernel space even when the lock is uncontended. The kernel will set it to TID, any waters that come in and contend for the pi futex will be handled respectively by the kernel.
(ii) -M option for multiple futexes, each thread deals with its own futex. This is a trivial scenario and only measures kernel handling of 0->TID transition.
---
tools/perf/Documentation/perf-bench.txt | 4 +
tools/perf/bench/Build | 1 +
tools/perf/bench/bench.h | 2 +
tools/perf/bench/{futex-hash.c => futex-lock-pi.c} | 202 +++++++++++----------
tools/perf/bench/futex.h | 20 ++
tools/perf/builtin-bench.c | 2 +
6 files changed, 132 insertions(+), 99 deletions(-)tools/perf/Documentation/perf-bench.txt +4 -0
@@ -216,6 +216,10 @@ Suite for evaluating parallel wake calls. *requeue*:: Suite for evaluating requeue calls. +*lock-pi*:: +Suite for evaluating futex lock_pi calls. + + SEE ALSO -------- linkperf:perf[1]
tools/perf/bench/Build +1 -0
@@ -5,6 +5,7 @@ perf-y += futex-hash.o perf-y += futex-wake.o perf-y += futex-wake-parallel.o perf-y += futex-requeue.o +perf-y += futex-lock-pi.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
tools/perf/bench/bench.h +2 -0
@@ -36,6 +36,8 @@ extern int bench_futex_wake(int argc, const char **argv, const char *prefix);extern int bench_futex_wake_parallel (int argc,const char **argv,const char *prefix);extern int bench_futex_requeue (int argc,const char **argv,const char *prefix); +/* pi futexes */ +extern int bench_futex_lock_pi (int argc,const char **argv,const char *prefix);#define BENCH_FORMAT_DEFAULT_STR "default"#define BENCH_FORMAT_DEFAULT 0
tools/perf/bench/futex-lock-pi.c renamed from tools/perf/bench/futex-hash.c +103 -99
282 lines not on this page · raw message
tools/perf/bench/futex.h +20 -0
@@ -56,6 +56,26 @@ futex_wake(u_int32_t *uaddr, int nr_wake, int opflags) }/** +* futex_lock_pi() - block on uaddr as a PI mutex +* @detect: whether (1) or not (0) to perform deadlock detection +*/ +static inline int +futex_lock_pi (u_int32_t *uaddr,struct timespec *timeout,int detect, +int opflags) +{ +return futex (uaddr,FUTEX_LOCK_PI , detect, timeout,NULL ,0 , opflags); +} + +/** +* futex_unlock_pi() - release uaddr as a PI mutex, waking the top waiter +*/ +static inline int +futex_unlock_pi (u_int32_t *uaddr,int opflags) +{ +return futex (uaddr,FUTEX_UNLOCK_PI ,0 ,NULL ,NULL ,0 , opflags); +} + +/** * futex_cmp_requeue() - requeue tasks from uaddr to uaddr2 * @nr_wake: wake up to this many tasks * @nr_requeue: requeue up to this many tasks
tools/perf/builtin-bench.c +2 -0
@@ -60,6 +60,8 @@ static struct bench futex_benchmarks[] = { { "wake", "Benchmark for futex wake calls", bench_futex_wake }, { "wake-parallel", "Benchmark for parallel futex wake calls", bench_futex_wake_parallel }, { "requeue", "Benchmark for futex requeue calls", bench_futex_requeue }, +/* pi-futexes */ + { "lock-pi", "Benchmark for futex lock_pi calls", bench_futex_lock_pi }, { "all", "Test all futex benchmarks", NULL }, { NULL, NULL, NULL } };