Re: [PATCH v5 1/5] perf sched: Add missing mmap2 handler in timehist

From: Arnaldo Carvalho de Melo

Date: Wed May 06 2026 - 09:26:17 EST


On Tue, May 05, 2026 at 05:45:42PM -0700, Ian Rogers wrote:
> perf_sched__timehist() registers event handlers for options using the
> sched->tool struct. It registers handlers for MMAP, COMM, EXIT, FORK, etc.
> but completely omits registering a handler for MMAP2 events.
>
> Failing to register both MMAP and MMAP2 handlers causes modern systems
> (which primarily output MMAP2 records) to silently drop VMA map mappings.
> This results in uninitialized machine/thread mapping structures, making it
> impossible to resolve shared library instruction pointers (IPs) to dynamic
> symbols/DSOs during timehist callchain analysis.
>
> Fix this by correctly registering perf_event__process_mmap2 in
> sched->tool inside perf_sched__timehist().
>
> Assisted-by: Gemini-CLI:Google Gemini 3
> Fixes: 5bbfec0ad93c ("perf sched: Implement timehist option")

I'm picking patches 1 and 2 as they're simple and passed sashiko review,
but:

⬢ [acme@toolbx perf-tools-next2]$ git show 5bbfec0ad93c
fatal: ambiguous argument '5bbfec0ad93c': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
⬢ [acme@toolbx perf-tools-next2]$

The right one is:

Fixes: 49394a2a24c78ce0 ("perf sched timehist: Introduce timehist command")

I checked and at the time, mmap2 was already present and it missed
adding this handler.

I fixed it, in case I'm missing something, lemme know,

- Arnaldo

> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/builtin-sched.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 555247568e7a..241c2f808f7b 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -3299,6 +3299,7 @@ static int perf_sched__timehist(struct perf_sched *sched)
> */
> sched->tool.sample = perf_timehist__process_sample;
> sched->tool.mmap = perf_event__process_mmap;
> + sched->tool.mmap2 = perf_event__process_mmap2;
> sched->tool.comm = perf_event__process_comm;
> sched->tool.exit = perf_event__process_exit;
> sched->tool.fork = perf_event__process_fork;
> --
> 2.54.0.545.g6539524ca2-goog