From: "Pierre-Clément Tosi" <ptosi@google.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>
Cc: "Ankur Arora" <ankur.a.arora@oracle.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
"Pierre-Clément Tosi" <ptosi@google.com>
Subject: [PATCH] perf bench mem: Add a populate-only mmap function
Date: Tue, 01 Dec 2026 13:20:54 +0100 [thread overview]
Message-ID: <20261201-perf-populate-only-v1-1-5053b83e645c@google.com> (raw)
Currently, 'populate' instructs the kernel to MAP_POPULATE the buffer.
However, it then executes the fault-in loop of 'demand'. With HugeTLB
(the initial motivation for introducing 'populate'), these accesses were
likely negligible but with 4KB pages over larger ranges (e.g. THP), they
stop being and add unnecessary noise to the timing.
Instead of changing 'populate', which would alter results of invocations
across perf upgrades, introduce a separate function behaving exactly
like 'populate' except that it skips the accesses.
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
(Based on my previous refactors for PROT_MTE support [1])
[1]: https://lore.kernel.org/linux-perf-users/20261201-perf-prot-mte-v1-0-4dc4e1da7460@google.com
---
tools/perf/Documentation/perf-bench.txt | 7 ++++---
tools/perf/bench/mem-functions.c | 9 +++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt
index fd09f3fc206b..d4cb6f01acb3 100644
--- a/tools/perf/Documentation/perf-bench.txt
+++ b/tools/perf/Documentation/perf-bench.txt
@@ -273,9 +273,10 @@ Specify seed to randomize page access offset (default: 0, or not randomized).
-f::
--function::
Specify function to set (default: all).
-Available functions are 'demand' and 'populate', with the first
-demand faulting pages in the region and the second using an eager
-mapping.
+Available functions are 'demand', 'populate' and 'populate-only', with
+the first demand faulting pages in the region, the second using an eager
+mapping, and the third using an eager mapping without accessing it, to
+only time mmap() and the population.
-l::
--nr_loops::
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c
index 722aa4189737..c31fd786684b 100644
--- a/tools/perf/bench/mem-functions.c
+++ b/tools/perf/bench/mem-functions.c
@@ -601,7 +601,8 @@ static void *do_mmap_thread(void *arg)
if (!dst)
goto out;
- fn(dst, p);
+ if (fn)
+ fn(dst, p);
clock_get(&end);
diff = clock_diff(&start, &end);
clock_accum(&data->result, &diff);
@@ -628,7 +629,8 @@ static int do_mmap(const struct function *r, struct bench_params *p,
return -1;
}
- p->populate = !strcmp(r->name, "populate");
+ p->populate = !strcmp(r->name, "populate") ||
+ !strcmp(r->name, "populate-only");
for (unsigned int i = 0; i < nr_threads; i++) {
data[i].func = r;
@@ -674,6 +676,9 @@ static const struct function mmap_functions[] = {
.desc = "Eagerly populated mmap()",
.fn.mmap_op = mmap_page_touch },
+ { .name = "populate-only",
+ .desc = "Eagerly populated mmap(), without accesses" },
+
{ .name = NULL, }
};
---
base-commit: 4a7008f739a30ee4c22d9f21af362a5128f2628d
change-id: 20261201-perf-populate-only-52b223315c8d
prerequisite-change-id: 20261201-perf-prot-mte-0ffbf9bc2f7a:v1
prerequisite-patch-id: 062745cca4f3a319ae8ebacfa8a641d5cf02c472
prerequisite-patch-id: 301a5edcf22df58fc4fa9466a288bd0710660fea
prerequisite-patch-id: b986231ed3b59095b20a6659d9d2bf844c292a61
prerequisite-patch-id: 4c3a06d6ad0e71f658452d31d38dd5df4bbf417e
Best regards,
--
Pierre-Clément Tosi <ptosi@google.com>
reply other threads:[~2026-12-01 12:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201-perf-populate-only-v1-1-5053b83e645c@google.com \
--to=ptosi@google.com \
--cc=acme@kernel.org \
--cc=ankur.a.arora@oracle.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
/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
all inboxes | Powered by JetHome®