Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2743914pxt; Mon, 9 Aug 2021 07:57:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk1sYmBma+L1N24XbLQ6RJSYO5nU7Yc/xuw0G1Gwqw/QqH4vKXDKqIUuY30y2Ux+Ow+ZUe X-Received: by 2002:a05:6638:95:: with SMTP id v21mr23289248jao.80.1628521071456; Mon, 09 Aug 2021 07:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628521071; cv=none; d=google.com; s=arc-20160816; b=KCozFirbtRSbyQ2iaKHJ1V9JAZkJS5AG1GlLzbcSgknV+5IW74jbhbzUogA05Rp+Kc t4lWa4JK1NlMMYvd63u2QEbqZ6L25fnHwUjOdtsWykQ6gmqZ8Q61V1E1iY9SQHUPCR// qSaZe49fEgV6k7/8bh7ToVldC7hJsyqAIU0vAoHhUzB/l2Wt4t5a2kae1JnoOM5/2pc6 hNRdpdFjtTSHZk4/eFzbFA60Go1C0CsqNZX/l8ufhjIGdpyYE+W4PVTJwQofTzy3HWWD io8py93asrEc+sw0QdpM75KbfqmPjoc6SNwnLeWwAfoqve5+X//VCosPU0Vka/Ev/QMz FSBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Fwg5CD/4weo8Bm+gAIjAeSKo9c8pjQyvUUn1pfb150A=; b=q73Ivt/cjOJSMR8VNmec915UrBHLD0/TarKrFy38/aI7fqm3cpmd50GBAZF5sOfUaN r/d9ycQvKw/VOIlZPnBIXo7bHtub8ocxMLHyWJ5hfufPwLdQU/c9MvSdE308OI/abzyl /9X1Dvda7rKr2T9oZ4OSi/oVCP4oe/PXMPTBN6LaScRZqnFGH9xAB3JNMBYqgXD6Dhjp 32giqFxnb0RcQd/JHZsFM0upK2ug8HUY/MGd1CzVl8PdRTnYe9LamyVwUieBO1rIi8JA BeeKaLCaBbTh5mYD2L3lwpmD/Rn+8J5svoBQKBR/FCmDNi921r25zvlURrzeqkcLUcXc A5Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dm9JuJNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si17069765jan.6.2021.08.09.07.57.40; Mon, 09 Aug 2021 07:57:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dm9JuJNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234454AbhHIO4q (ORCPT + 99 others); Mon, 9 Aug 2021 10:56:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234054AbhHIO4p (ORCPT ); Mon, 9 Aug 2021 10:56:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A35C060E97; Mon, 9 Aug 2021 14:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628520984; bh=+oMVH2KSsU3LfIJY4UlhBzUXGbJvNmJ2lQEqg9/XfCY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dm9JuJNP1KeSOglqUrhRBmt2/kwrgOqJYsJ23UMQVGzy6bnHf4S68WnZT9W0atHco oEg7EzbaknjTbVNIpGHxD1GjWxJccr5IbGkzRqV3l15f8vtm0hNjB0pJropb0DOWHx 0VFtPA5J4pjG3cwcub/8kinz/gQDknQAqAfZc9Y9xfse2CrpPnge+JM3HLdMRuRnI+ k76aDPHfjoPVqui1l9G9Qcrl+U4k9lZy4RU6hJeQmQl+Rmd2gfQ6qashXwd36QkIKA dIQ0X3kwUU6TpuZiqAwVmuja8H7tGw13aqgdDgcbAOUc9Bu/yjl/SMMz3nflF0GYUo ZVQzQiJ1z5j7Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 470A6403F2; Mon, 9 Aug 2021 11:56:22 -0300 (-03) Date: Mon, 9 Aug 2021 11:56:22 -0300 From: Arnaldo Carvalho de Melo To: Davidlohr Bueso Cc: mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 4/7] perf/bench-futex: Add --mlockall parameter Message-ID: References: <20210809043301.66002-1-dave@stgolabs.net> <20210809043301.66002-5-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210809043301.66002-5-dave@stgolabs.net> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 > #include > #include > +#include > #include > > #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 > #include > #include > +#include > > 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 > #include > #include > +#include > > 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 > #include > #include > +#include > > 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 > #include > #include > +#include > > /* 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