From: Ian Rogers <irogers@google.com>
To: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, acme@kernel.org, namhyung@kernel.org,
jolsa@kernel.org, adrian.hunter@intel.com,
james.clark@linaro.org, dsahern@gmail.com, andrii@kernel.org,
Ian Rogers <irogers@google.com>
Subject: [PATCH v4 6/7] perf bench synthesize: Add --procmap-query option
Date: Fri, 4 Dec 2026 12:58:52 -0800 [thread overview]
Message-ID: <20261204205854.3973609-7-irogers@google.com> (raw)
In-Reply-To: <20261204205854.3973609-1-irogers@google.com>
Add a --[no-]procmap-query option to 'perf bench internals synthesize'
so that synthesizing mmap events using the PROCMAP_QUERY ioctl can be
compared with parsing the text of /proc/<pid>/maps. The mode used is
printed at the start of the benchmark. As the text parser may be
wanted for debugging or comparison when recording, also add a
core.procmap-query perf config option that, when false, disables the
use of PROCMAP_QUERY. Export perf_event__procmap_query_supported() so
the benchmark (and tests) can query whether the running kernel supports
PROCMAP_QUERY synthesis.
$ perf bench internals synthesize --no-procmap-query
# Running 'internals/synthesize' benchmark:
Reading mmaps using /proc/pid/maps text
Computing performance of single threaded perf event synthesis by
synthesizing events on the perf process itself:
Average synthesis took: 273.436 usec (+- 2.084 usec)
Average num. events: 62.000 (+- 0.000)
Average time per event 4.410 usec
Average data synthesis took: 1680.164 usec (+- 12.119 usec)
Average num. events: 333.000 (+- 0.000)
Average time per event 5.046 usec
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/Documentation/perf-bench.txt | 4 +++-
tools/perf/Documentation/perf-config.txt | 6 ++++++
tools/perf/bench/synthesize.c | 7 +++++++
tools/perf/util/config.c | 4 ++++
tools/perf/util/synthetic-events.c | 5 +++--
tools/perf/util/synthetic-events.h | 7 +++++++
6 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt
index c65dd8f4131f..ca53d6de2851 100644
--- a/tools/perf/Documentation/perf-bench.txt
+++ b/tools/perf/Documentation/perf-bench.txt
@@ -349,7 +349,9 @@ Suite for evaluating multiple epoll_ctl calls.
SUITES FOR 'internals'
~~~~~~~~~~~~~~~~~~~~~~
*synthesize*::
-Suite for evaluating perf's event synthesis performance.
+Suite for evaluating perf's event synthesis performance. The
+--no-procmap-query option reads mmaps by parsing the text of
+/proc/<pid>/maps rather than with the PROCMAP_QUERY ioctl.
*symbols*::
Suite for evaluating ELF symbol loading, sorting, and lookup performance.
diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index 6cff6f26af8d..e68d6bfa32c3 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -210,6 +210,12 @@ core.*::
Sets a timeout (in milliseconds) for parsing /proc/<pid>/maps files.
Can be overridden by the --proc-map-timeout option on supported
subcommands. The default timeout is 500ms.
+ procmap-query::
+ When 'true' (the default) mmap events for existing processes
+ are synthesized using the PROCMAP_QUERY ioctl on Linux 6.19+,
+ if supported by the kernel, which also provides the build ID
+ of the mapped file. When 'false' the text of /proc/<pid>/maps
+ is parsed.
addr2line-disable-warn::
When set to 'true' disable all warnings from 'addr2line' output.
Default setting is 'false' to show these warnings.
diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c
index fdc5465db3f0..db2747fd4e09 100644
--- a/tools/perf/bench/synthesize.c
+++ b/tools/perf/bench/synthesize.c
@@ -41,6 +41,8 @@ static const struct option options[] = {
"Number of iterations used to compute single-threaded average"),
OPT_UINTEGER('I', "multi-iterations", &multi_iterations,
"Number of iterations used to compute multi-threaded average"),
+ OPT_BOOLEAN(0, "procmap-query", &synthesize_procmap_query,
+ "Use PROCMAP_QUERY, if supported, rather than /proc/pid/maps text"),
OPT_END()
};
@@ -268,6 +270,11 @@ int bench_synthesize(int argc, const char **argv)
return err;
}
+ printf("Reading mmaps using %s\n",
+ synthesize_procmap_query && perf_event__procmap_query_supported()
+ ? "the PROCMAP_QUERY ioctl"
+ : "/proc/pid/maps text");
+
if (run_st)
err = run_single_threaded(&host_env);
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 0e6b77a0a5e7..83963e607506 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -39,6 +39,7 @@
#include "util/evsel.h" /* evsel__hw_names, evsel__use_bpf_counters */
#include "util/hist.h" /* perf_hist_config */
#include "util/stat.h" /* perf_stat__set_big_num */
+#include "util/synthetic-events.h" /* synthesize_procmap_query */
#define MAXNAME (256)
@@ -483,6 +484,9 @@ static int perf_default_core_config(const char *var, const char *value)
if (!strcmp(var, "core.proc-map-timeout"))
proc_map_timeout = strtoul(value, NULL, 10);
+ if (!strcmp(var, "core.procmap-query"))
+ synthesize_procmap_query = perf_config_bool(var, value);
+
if (!strcmp(var, "core.addr2line-timeout"))
symbol_conf.addr2line_timeout_ms = strtoul(value, NULL, 10);
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 4152d0ae5270..b4ec38bfa547 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -54,6 +54,7 @@
#define DEFAULT_PROC_MAP_PARSE_TIMEOUT 500
unsigned int proc_map_timeout = DEFAULT_PROC_MAP_PARSE_TIMEOUT;
+bool synthesize_procmap_query = true;
int perf_tool__process_synth_event(const struct perf_tool *tool,
union perf_event *event,
@@ -716,7 +717,7 @@ static void procmap_query__probe(void)
pr_debug("PROCMAP_QUERY not supported, reading maps files as text\n");
}
-static bool procmap_query__supported(void)
+bool perf_event__procmap_query_supported(void)
{
static pthread_once_t once = PTHREAD_ONCE_INIT;
@@ -1016,7 +1017,7 @@ int perf_event__synthesize_mmap_events(const struct perf_tool *tool,
event->header.type = PERF_RECORD_MMAP2;
state.t = rdclock();
- if (procmap_query__supported())
+ if (synthesize_procmap_query && perf_event__procmap_query_supported())
rc = synth_mmap2_state__procmap_query(&state, fd);
if (rc > 0)
diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic-events.h
index 243115ea61ae..bb9e691e3c4c 100644
--- a/tools/perf/util/synthetic-events.h
+++ b/tools/perf/util/synthetic-events.h
@@ -41,6 +41,13 @@ enum perf_record_synth {
int parse_synth_opt(char *str);
+/*
+ * Synthesize mmap events using the PROCMAP_QUERY ioctl, when supported by the
+ * kernel, rather than parsing the text of /proc/<pid>/maps. Defaults to true.
+ */
+extern bool synthesize_procmap_query;
+bool perf_event__procmap_query_supported(void);
+
typedef int (*perf_event__handler_t)(const struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct machine *machine);
--
2.56.1.915.g69d5ec7298-goog
next prev parent reply other threads:[~2026-12-04 20:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:58 [PATCH v4 0/7] perf synthetic-events: Use PROCMAP_QUERY for mmap synthesis Ian Rogers
2026-12-04 20:58 ` [PATCH v4 1/7] perf machine: Fix leak when creating host kernel maps fails Ian Rogers
2026-12-04 20:58 ` [PATCH v4 2/7] perf synthetic-events: Fix race on DSO build IDs when synthesizing Ian Rogers
2026-12-04 20:58 ` [PATCH v4 3/7] perf bench synthesize: Initialize symbols so build IDs can be read Ian Rogers
2026-12-04 20:58 ` [PATCH v4 4/7] tools headers UAPI: Synchronize linux/fs.h with the kernel sources Ian Rogers
2026-12-04 20:58 ` [PATCH v4 5/7] perf synthetic-events: Use PROCMAP_QUERY to synthesize mmap events Ian Rogers
2026-12-04 20:58 ` Ian Rogers [this message]
2026-12-04 20:58 ` [PATCH v4 7/7] perf test: Add test comparing PROCMAP_QUERY and /proc/pid/maps synthesis Ian Rogers
2026-12-04 21:16 ` sashiko-bot
2026-12-04 21:16 ` [PATCH v4 0/7] perf synthetic-events: Use PROCMAP_QUERY for mmap synthesis sashiko-bot
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=20261204205854.3973609-7-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=andrii@kernel.org \
--cc=dsahern@gmail.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.