From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 4/7] perf/bench-futex: Add --mlockall parameter
Date: Mon, 9 Aug 2021 11:56:22 -0300 [thread overview]
Message-ID: <YRFCFqM9QBoUrl18@kernel.org> (raw)
In-Reply-To: <20210809043301.66002-5-dave@stgolabs.net>
Em Sun, Aug 08, 2021 at 09:32:58PM -0700, Davidlohr Bueso escreveu:
> 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.
Applied.
At some point these options could be handled in a common
futex_parse_options() function that would consume argv[] and then the
specific futex benchmarks would continue from where the common function
left off.
- Arnaldo
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
> ---
> tools/perf/bench/futex-hash.c | 7 +++++++
> tools/perf/bench/futex-lock-pi.c | 7 +++++++
> tools/perf/bench/futex-requeue.c | 7 +++++++
> tools/perf/bench/futex-wake-parallel.c | 8 ++++++++
> tools/perf/bench/futex-wake.c | 8 ++++++++
> tools/perf/bench/futex.h | 1 +
> 6 files changed, 38 insertions(+)
>
> diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
> index b71a34204b79..af9fbb409472 100644
> --- a/tools/perf/bench/futex-hash.c
> +++ b/tools/perf/bench/futex-hash.c
> @@ -20,6 +20,7 @@
> #include <linux/kernel.h>
> #include <linux/zalloc.h>
> #include <sys/time.h>
> +#include <sys/mman.h>
> #include <perf/cpumap.h>
>
> #include "../util/stat.h"
> @@ -55,6 +56,7 @@ static const struct option options[] = {
> OPT_UINTEGER('f', "futexes", ¶ms.nfutexes, "Specify amount of futexes per threads"),
> OPT_BOOLEAN( 's', "silent", ¶ms.silent, "Silent mode: do not display data/details"),
> OPT_BOOLEAN( 'S', "shared", ¶ms.fshared, "Use shared futexes instead of private ones"),
> + OPT_BOOLEAN( 'm', "mlockall", ¶ms.mlockall, "Lock all current and future memory"),
> OPT_END()
> };
>
> @@ -141,6 +143,11 @@ int bench_futex_hash(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) /* default to the number of CPUs */
> params.nthreads = cpu->nr;
>
> diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
> index bc208edf3de3..d2927d2eb3f7 100644
> --- a/tools/perf/bench/futex-lock-pi.c
> +++ b/tools/perf/bench/futex-lock-pi.c
> @@ -21,6 +21,7 @@
> #include <err.h>
> #include <stdlib.h>
> #include <sys/time.h>
> +#include <sys/mman.h>
>
> struct worker {
> int tid;
> @@ -47,6 +48,7 @@ static const struct option options[] = {
> OPT_BOOLEAN( 'M', "multi", ¶ms.multi, "Use multiple futexes"),
> OPT_BOOLEAN( 's', "silent", ¶ms.silent, "Silent mode: do not display data/details"),
> OPT_BOOLEAN( 'S', "shared", ¶ms.fshared, "Use shared futexes instead of private ones"),
> + OPT_BOOLEAN( 'm', "mlockall", ¶ms.mlockall, "Lock all current and future memory"),
> OPT_END()
> };
>
> @@ -164,6 +166,11 @@ int bench_futex_lock_pi(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;
>
> diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
> index 4001312122be..88cb7e2a6729 100644
> --- a/tools/perf/bench/futex-requeue.c
> +++ b/tools/perf/bench/futex-requeue.c
> @@ -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;
>
> @@ -50,6 +51,7 @@ static const struct option options[] = {
> OPT_UINTEGER('q', "nrequeue", ¶ms.nrequeue, "Specify amount of threads to requeue at once"),
> OPT_BOOLEAN( 's', "silent", ¶ms.silent, "Silent mode: do not display data/details"),
> OPT_BOOLEAN( 'S', "shared", ¶ms.fshared, "Use shared futexes instead of private ones"),
> + OPT_BOOLEAN( 'm', "mlockall", ¶ms.mlockall, "Lock all current and future memory"),
> OPT_END()
> };
>
> @@ -133,6 +135,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;
>
> diff --git a/tools/perf/bench/futex-wake-parallel.c b/tools/perf/bench/futex-wake-parallel.c
> index ea4fdea6e2f3..ef1f8237fd81 100644
> --- a/tools/perf/bench/futex-wake-parallel.c
> +++ b/tools/perf/bench/futex-wake-parallel.c
> @@ -34,6 +34,7 @@ int bench_futex_wake_parallel(int argc __maybe_unused, const char **argv __maybe
> #include <err.h>
> #include <stdlib.h>
> #include <sys/time.h>
> +#include <sys/mman.h>
>
> struct thread_data {
> pthread_t worker;
> @@ -61,6 +62,8 @@ static const struct option options[] = {
> OPT_UINTEGER('w', "nwakers", ¶ms.nwakes, "Specify amount of waking threads"),
> OPT_BOOLEAN( 's', "silent", ¶ms.silent, "Silent mode: do not display data/details"),
> OPT_BOOLEAN( 'S', "shared", ¶ms.fshared, "Use shared futexes instead of private ones"),
> + OPT_BOOLEAN( 'm', "mlockall", ¶ms.mlockall, "Lock all current and future memory"),
> +
> OPT_END()
> };
>
> @@ -238,6 +241,11 @@ int bench_futex_wake_parallel(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");
> + }
> +
> cpu = perf_cpu_map__new(NULL);
> if (!cpu)
> err(EXIT_FAILURE, "calloc");
> diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
> index 1cf651c8ee5c..40e492c7996a 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;
> @@ -51,6 +52,8 @@ static const struct option options[] = {
> OPT_UINTEGER('w', "nwakes", ¶ms.nwakes, "Specify amount of threads to wake at once"),
> OPT_BOOLEAN( 's', "silent", ¶ms.silent, "Silent mode: do not display data/details"),
> OPT_BOOLEAN( 'S', "shared", ¶ms.fshared, "Use shared futexes instead of private ones"),
> + OPT_BOOLEAN( 'm', "mlockall", ¶ms.mlockall, "Lock all current and future memory"),
> +
> OPT_END()
> };
>
> @@ -141,6 +144,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;
>
> diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
> index f7cd22bbd677..1c8fa469993f 100644
> --- a/tools/perf/bench/futex.h
> +++ b/tools/perf/bench/futex.h
> @@ -19,6 +19,7 @@ static int futex_flag = 0;
> struct bench_futex_parameters {
> bool silent;
> bool fshared;
> + bool mlockall;
> bool multi; /* lock-pi */
> unsigned int runtime; /* seconds*/
> unsigned int nthreads;
> --
> 2.26.2
>
--
- Arnaldo
next prev parent reply other threads:[~2021-08-09 14:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 4:32 [PATCH -tip v2 0/7] perf/bench-futex: Misc updates Davidlohr Bueso
2021-08-09 4:32 ` [PATCH 1/7] perf/bench-futex: Group test parameters cleanup Davidlohr Bueso
2021-08-09 4:32 ` [PATCH 2/7] perf/bench-futex: Remove bogus backslash from comment Davidlohr Bueso
2021-08-09 4:32 ` [PATCH 3/7] perf/bench-futex: Factor out futex_flag Davidlohr Bueso
2021-08-09 14:54 ` Arnaldo Carvalho de Melo
2021-08-09 16:30 ` Davidlohr Bueso
2021-08-09 4:32 ` [PATCH 4/7] perf/bench-futex: Add --mlockall parameter Davidlohr Bueso
2021-08-09 14:56 ` Arnaldo Carvalho de Melo [this message]
2021-08-09 16:11 ` Davidlohr Bueso
2021-08-09 4:32 ` [PATCH 5/7] perf/bench-futex, requeue: Add --broadcast option Davidlohr Bueso
2021-08-09 14:57 ` Arnaldo Carvalho de Melo
2021-08-09 4:33 ` [PATCH 6/7] perf/bench-futex, requeue: Robustify futex_wait() handling Davidlohr Bueso
2021-08-09 14:58 ` Arnaldo Carvalho de Melo
2021-08-09 4:33 ` [PATCH 7/7] perf/bench-futex, requeue: Add --pi parameter Davidlohr Bueso
2021-08-09 15:01 ` Arnaldo Carvalho de Melo
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=YRFCFqM9QBoUrl18@kernel.org \
--to=acme@kernel.org \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).