perf bench futex: Add --mlockall parameter
[sfrench/cifs-2.6.git] / tools / perf / bench / futex-requeue.c
index 66747bfe22cfeba432bc6869cda51c104343f55a..73d4a6c3fe52f2749291e564c19f2ca9c854087a 100644 (file)
@@ -27,6 +27,7 @@
 #include <err.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#include <sys/mman.h>
 
 static u_int32_t futex1 = 0, futex2 = 0;
 
@@ -51,6 +52,7 @@ static const struct option options[] = {
        OPT_UINTEGER('q', "nrequeue", &params.nrequeue, "Specify amount of threads to requeue 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()
 };
 
@@ -134,6 +136,11 @@ int bench_futex_requeue(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;