summaryrefslogtreecommitdiff
path: root/tools/perf/bench/futex-wake.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2021-08-08 21:32:58 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-08-09 12:00:04 -0300
commit9f9a3ffe94f263388b99cb75e4ec374e31aaeb0f (patch)
treebc35c452426a5763e94488dc91377a2683f4ef1b /tools/perf/bench/futex-wake.c
parentb2105a75703ebe098710beedc7a1685f67010675 (diff)
perf bench futex: Add --mlockall parameter
This adds, across all futex benchmarks, the -m/--mlockall option which is a common operation for realtime workloads by not incurring in page faults in paths that want determinism. As such, threads started after a call to mlockall(2) will generate page faults immediately since the new stack is immediately forced to memory, due to the MCL_FUTURE flag. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Cc: Davidlohr Bueso <dbueso@suse.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lore.kernel.org/lkml/20210809043301.66002-5-dave@stgolabs.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/futex-wake.c')
-rw-r--r--tools/perf/bench/futex-wake.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
index 9ed4d65416f3..77f058a47790 100644
--- a/tools/perf/bench/futex-wake.c
+++ b/tools/perf/bench/futex-wake.c
@@ -27,6 +27,7 @@
#include <err.h>
#include <stdlib.h>
#include <sys/time.h>
+#include <sys/mman.h>
/* all threads will block on the same futex */
static u_int32_t futex1 = 0;
@@ -52,6 +53,8 @@ static const struct option options[] = {
OPT_UINTEGER('w', "nwakes", &params.nwakes, "Specify amount of threads to wake at once"),
OPT_BOOLEAN( 's', "silent", &params.silent, "Silent mode: do not display data/details"),
OPT_BOOLEAN( 'S', "shared", &params.fshared, "Use shared futexes instead of private ones"),
+ OPT_BOOLEAN( 'm', "mlockall", &params.mlockall, "Lock all current and future memory"),
+
OPT_END()
};
@@ -142,6 +145,11 @@ int bench_futex_wake(int argc, const char **argv)
act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL);
+ if (params.mlockall) {
+ if (mlockall(MCL_CURRENT | MCL_FUTURE))
+ err(EXIT_FAILURE, "mlockall");
+ }
+
if (!params.nthreads)
params.nthreads = cpu->nr;