From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796346317; b=VvpQE/yFtScygsI7JylnYJowgGKzol4x3CiNz1KLdQhD+8NYf0HFuptIaqk5LNq1WbdC iQuPGzruI1zyR6TEECbLJsla1lEMdF0QhP6gWuv+ozkRjjxPABfIbjjb11RbTkWsQXMXz rD580fmPkHz7V0/HbZfRB6RVarsyda4dtCkqSUqK0FzRBvNUU9BZhbOyz6NqjXwKro11X KGkvGADu0ZtqC6xlkB2YVtxQKpPlmz0gLJQ/WhgDfpHcgNxVVHzypyQEV2kuQqkyVu6lu 8XI0E/dPUgCf1aSArHMzsSrWm2Y7xogtrjbnxva0+wsRV07XYxjIIv0KGdDwxAM27jA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796346317; 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=pNRzuOld8S7Zj9CzdQPAd8+i0ocA+GwN0BelyKxr0eM=; b=DlViYlAAD9SKfnpjJyYIHke9LQruMePB/9htyJAJt0YwQTHzChe7tsE/cC+GiYJuqmQP 97iitIGV73bCtvp8sVtQp0CwO7qNg2AUS733u+HAHZJBpC0vcEMM5291AktrO2zLChkd/ r9lrtf1+IqbaGiyfQjovis28EYLoNJe3xRZa8G7u9MQZ7wPLjd+VMUmm5GYhd65ON4i2a SQ2OMSeBu1HeVLSBZJDsMg7jKMkp26xFE3XdjCpTSVtNuewrUWSt2wjZ0Sq+ickcTDHLB 2fHqHYx4lbBhtqBtl3Lc1QVwfPIuSJXpY7I6LvqvQ9XOhaF51HBJGSDHP/BpiiVMhWA== 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=ZKJJre9z; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (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 B0754606A693 for ; Fri, 4 Dec 2026 01:05:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0754606A693 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=ZKJJre9z Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-38751f8cc15so672091eec.1 for ; Thu, 03 Dec 2026 17:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796346316; x=1796951116; 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=pNRzuOld8S7Zj9CzdQPAd8+i0ocA+GwN0BelyKxr0eM=; b=ZKJJre9zQLXaFAYilljFUyW6M4IlHqbG+RYKsg/UYaJwSWv92fCAOXIXNLCzY1DFI+ rEPlWGNeXeM3SZV0FGMP53s013EPmokoYCdX9bjWpZ/L5oTkQPoDoo0LqX9j6t6W8OpT 23bqdGuBc77IeWBJucnvmz9NplP4S24pxwCQWDvo2tNbrFvQrkusJuGxDrFYbY5I7RQX tEiqHXF18b1S/fOPOiZuSKvhhdJO1528DmgMu31reqAJsnuRV4XkJt2E1foLLxpTk1+8 cFFnOlb5Td41JBEEIFMCXbwJvFgR3RWRNVTDWU4Lwo+GT8sRBqyaanpvimgzCvbH8R8N NbZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796346316; x=1796951116; 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=pNRzuOld8S7Zj9CzdQPAd8+i0ocA+GwN0BelyKxr0eM=; b=QKQPvVFPZxzzQVaPCtHpVz5IXnbyNRdoORNmCP8H46Y7TGpe8yUQq8bQCd27MHJck9 /YZ062Zqwe1lGwQpjvWvgTCtZ+4RqHItYf5zlO/C9zr9mRhMHrwckB3CVLsersr6M7NC MVQr//8g5fy3Mm67az6husAOnF4DSqYNsHV/tO8VnIB88x7SxNfSxSr0bxvuMU1fVUOg hEAM85j3+qQYclWqSc9cVu8d3T74q1cVKWB/RXPBnpsAiW7oa4SMl+waEj0lEAZdRrHz onch1L7CB3RWG/V7mF0HJ0fiUOg96EF0jS68I2Kuy1/c3UZJxOEmJiK+hLGVAWaaJckz 3hWQ== X-Gm-Message-State: APuU4Z/l2zYP9kyPN9mSeBtr4V3jVr2w29aec+rM8q2kMaI9xkxVxEZX MkFuoE77Vg9jmdl20eY8LuRklSAgKa9kfRIVSP/oFgfbgbXW4raJDSwEo/gu4hR/KKiUMHOW9PF E5IZMS9wJO35UdHMPwryIIbV9WNwEIZBxdZth4nFR2NqhE+shSAsnhwo9+Vyp+LYhnZSy4rpNA6 c0Gv0DbBJkgYjiT6PG5QK5i0/IXmpiZIfNgU90/hEaIJlGprZzeWLryxY= X-Received: from dylq9.prod.google.com ([2002:a05:7300:5989:b0:387:4468:72c7]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:42ce:b0:387:51d9:4b39 with SMTP id 5a478bee46e88-3875200df34mr472465eec.3.1796346315253; Thu, 03 Dec 2026 17:05:15 -0800 (PST) Date: Thu, 3 Dec 2026 17:04:50 -0800 In-Reply-To: <20261204010452.1937224-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: <20261204010452.1937224-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204010452.1937224-6-irogers@google.com> Subject: [PATCH 5/6] 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. $ 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 --- Notes: This change was developed with the help of an AI coding assistant (Gemini in Jetski), which wrote the initial code, tests and changelog; it was reviewed, built and tested by the author. tools/perf/Documentation/perf-bench.txt | 4 +++- tools/perf/Documentation/perf-config.txt | 5 +++++ tools/perf/bench/synthesize.c | 6 ++++++ tools/perf/util/config.c | 4 ++++ tools/perf/util/synthetic-events.c | 3 ++- tools/perf/util/synthetic-events.h | 6 ++++++ 6 files changed, 26 insertions(+), 2 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..aad31a33ce56 100644 --- a/tools/perf/Documentation/perf-config.txt +++ b/tools/perf/Documentation/perf-config.txt @@ -210,6 +210,11 @@ 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, 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..c1217f5c1fb3 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,10 @@ int bench_synthesize(int argc, const char **argv) return err; } + printf("Reading mmaps using %s\n", + synthesize_procmap_query ? "the PROCMAP_QUERY ioctl, if supported" + : "/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 3ad482f9115a..9db1084f25b0 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -53,6 +53,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, @@ -945,7 +946,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 && 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..2f018c51b98e 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -41,6 +41,12 @@ 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; + 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