From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796524497; b=CZtgBCPT3gJLgKm/+NFxGYeMaQLua673oJAJHufF+TDs7BbyJxzHQ9GBANHRrjkSFrkN MLpVVRfB5rf8dD/mlUfvAV1OO/egqqQw21ZDC/fVWePCFxLtBaJwnHVssTSeY0yvT9I1A as9n+wnlKYUyxB3bHmY4uYLpcklwAbBnr6NNt3cpmjiQtzGrzs+Ghxca3x16riFI4JhH0 /lGAw5DN7b+jx9O35KPPbVzAUE7vXXGjvkYB4OMsuK/8A6zwbvBpIahyND2CQrfdYjX99 +hEGJKjyWXfPiBjnZbLHu0/pPbrw66WcLLHSTZC2Or00JyBUgxtEg8gCiwvGgP2Incw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796524497; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=eXfoTf4/8iCbowt5v8t6oZ4Zkr8eLuq0IiY/Ncp/9eU=; b=XyYzdLqIYx0r4p4HuRBrBSTAMv8ZhjyaVEqaN4qOWnuJVjnECSwHdYkVj3qBXmgCXSxR 7aWZ/nh1YXlM6DQMVOum2PRprRd3rdwsDckAgkDdn4cUlc6vrqNb3KqauR9S2YBduIPu9 xz0y9Ptp2lOTuuJxkAJo0KImoYd13R8anhKARWLYeT+iT/x2zGqDDRS59VzwdaNPmNUFW KxnYKexLZMvPXEsTfZeNKv5oGYzo5lSWFNfOglc9USpQU7nHRLxizlJ36aLpUGORinq5C clfjwvMrzF/fGqAUdup5F+f/nt3/I5rPJ3HxBy0uYGENNUcLXXwup79jg8LUuq7NnSg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WqRh+DEX; arc=none smtp.remote-ip=74.125.82.70 Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2CB7606A335 for ; Sun, 6 Dec 2026 02:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F2CB7606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WqRh+DEX Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b5d5fa8e99so7248687c88.1 for ; Sat, 05 Dec 2026 18:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796524496; x=1797129296; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eXfoTf4/8iCbowt5v8t6oZ4Zkr8eLuq0IiY/Ncp/9eU=; b=WqRh+DEXejR5AluR1EkVrMMu9CDGaR8cH/G5RrNUDoYrQRL4kSC3PTkxjc1gpNch+8 9kRdqwWwfOfnpEu5pftagSRpMpAjgJKAsYHP0fjcTOY0VJmhD54YNAsrqpEjm3Amm2Iw 94LCQhFX+Pf+wrNMHD6bqPphYrJ89h/AobEHrC0SPGedCPLfDiydbbXAroT5aFwhxBI+ Du4RSuI1JPXsV1x20e9esQCl81pmB9D/9x8oO4ZH4bfn9FR4PvNSNrx+L5+eh6Dt4reZ VnABoOYjZYeVaWrYCkALjHSoEmRK7kOMIxEaerp20Wuh744wXCnMOfEorNbqxnQroks0 nQSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796524496; x=1797129296; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eXfoTf4/8iCbowt5v8t6oZ4Zkr8eLuq0IiY/Ncp/9eU=; b=X6x+LF6h5bIUBrs+kuNGKbgxcKY62SOQlVD8yiPn62p5G9aCLzIZoJClmjILylmUuo xayMxKvmS0QiTtLegZXVoLEt5HO31PpwapjuN1/La36xqQBSjARkqkzML5JCWFCzGBub pP2x9I+TqJyKdIYLD/RO4/PzLOD+SDKcItC3CY4h9tCTuhIqNLDI8Pm5WTf+4PxVmf3b r6buZ+Y5jPN+C2bcUHQGiMXmhZxsWyMillAVMpUJ/KYqpHTYFStsgMbuR5hvM+lDFIj9 u5mBUZE/LIh/K2EuYteJVhIwS47CCMDzauWyUSeno/ScywudgLduz9B7gD+uSbX9AmBv SGug== X-Gm-Message-State: APuU4Z/d+nQYMOsSSZnEHcDq/t+CjbT4ENPyWUx6REZoz6ClkSlLIVlf dpn14VGjvKer1w0YbYnVcCg1ok0CiCoBkxfHyhbWG5MqiT3HiFw01kbyg15EVljl/BOGGZq3nP8 Kjs6jfTp/pqawuy8qAE4wqMc9reoux4nt8TxeP73zIPLEO49gO2gH4uhEOLoYZdQbqZN7Deci8u db8NlfoGxotARpx8HgQkhl85kQAtriz8tGdwVwXVhaoBwsuwWjmDHGDh8= X-Received: from dldz20-n1.prod.google.com ([2002:a05:701b:4194:10b0:1b3:befc:72bc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701a:cc87:20b0:1ac:9da7:e881 with SMTP id a92af1059eb24-1b5d7118158mr6523819c88.36.1796524495768; Sat, 05 Dec 2026 18:34:55 -0800 (PST) Date: Sat, 5 Dec 2026 18:34:12 -0800 In-Reply-To: <20261206023413.3078292-1-irogers@google.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261206023413.3078292-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261206023413.3078292-7-irogers@google.com> Subject: [PATCH v5 6/7] perf bench synthesize: Add --procmap-query option From: Ian Rogers To: linux-perf-users@vger.kernel.org, acme@kernel.org, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, jolsa@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org, dsahern@gmail.com, andrii@kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" 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//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 --- 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//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//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//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//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