* [PATCH] perf bench mem: Add a populate-only mmap function
@ 2026-12-01 12:20 Pierre-Clément Tosi
0 siblings, 0 replies; only message in thread
From: Pierre-Clément Tosi @ 2026-12-01 12:20 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, James Clark
Cc: Ankur Arora, linux-perf-users, linux-kernel, Pierre-Clément Tosi
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>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 12:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 12:20 [PATCH] perf bench mem: Add a populate-only mmap function Pierre-Clément Tosi
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®