]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf tool: Fix missing schedstat delegates and dont_split_sample_group in delegate_tool
authorIan Rogers <irogers@google.com>
Wed, 6 May 2026 00:45:43 +0000 (17:45 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 May 2026 18:26:04 +0000 (15:26 -0300)
delegate_tool was missing the delegate overrides for schedstat_cpu
and schedstat_domain. As a result, when allocated with zalloc, these
callbacks defaulted to NULL, causing a segmentation fault crash if
any schedstat events were delivered during event processing.
Fix this by adding delegate_schedstat_cpu and delegate_schedstat_domain
via the CREATE_DELEGATE_OP2 macro, and ensuring delegate_tool__init
correctly registers them.

Additionally, delegate_tool__init completely omitted copying the
dont_split_sample_group property from the delegate. This would cause
wrapper tools to default the flag to false, which corrupts piped event
processing (e.g., in perf inject) by triggering duplicate event
deliveries on split sample values in deliver_sample_group().

Similarly, perf_tool__init() omitted the initialization of this
boolean field. On stack-allocated tools that rely on this initializer
(like intel-tpebs or __cmd_evlist), this could result in uninitialized
stack garbage evaluating to true—silently dropping non-leader event
members in deliver_sample_group().

Fix both issues by properly copying the field in delegate_tool__init
and initializing it to false in perf_tool__init.

Fixes: 6331b266935916bf ("perf tool: Add a delegate_tool that just delegates actions to another tool")
Fixes: 79bcd34e0f3da39f ("perf inject: Fix leader sampling inserting additional samples")
Assisted-by: Gemini-CLI:Google Gemini 3
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Gabriel Marin <gmx@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/tool.c

index 013c7839e2cfd29da64d0ca429022aa57797e34d..ff2150517b75587a4a804c15900ce4ce1ab753e7 100644 (file)
@@ -285,6 +285,7 @@ void perf_tool__init(struct perf_tool *tool, bool ordered_events)
        tool->no_warn = false;
        tool->show_feat_hdr = SHOW_FEAT_NO_HEADER;
        tool->merge_deferred_callchains = true;
+       tool->dont_split_sample_group = false;
 
        tool->sample = process_event_sample_stub;
        tool->mmap = process_event_stub;
@@ -433,6 +434,8 @@ CREATE_DELEGATE_OP2(stat_config);
 CREATE_DELEGATE_OP2(stat_round);
 CREATE_DELEGATE_OP2(thread_map);
 CREATE_DELEGATE_OP2(time_conv);
+CREATE_DELEGATE_OP2(schedstat_cpu);
+CREATE_DELEGATE_OP2(schedstat_domain);
 CREATE_DELEGATE_OP2(tracing_data);
 
 #define CREATE_DELEGATE_OP3(name)                                      \
@@ -470,6 +473,7 @@ void delegate_tool__init(struct delegate_tool *tool, struct perf_tool *delegate)
        tool->tool.no_warn = delegate->no_warn;
        tool->tool.show_feat_hdr = delegate->show_feat_hdr;
        tool->tool.merge_deferred_callchains = delegate->merge_deferred_callchains;
+       tool->tool.dont_split_sample_group = delegate->dont_split_sample_group;
 
        tool->tool.sample = delegate_sample;
        tool->tool.read = delegate_read;
@@ -516,4 +520,6 @@ void delegate_tool__init(struct delegate_tool *tool, struct perf_tool *delegate)
        tool->tool.bpf_metadata = delegate_bpf_metadata;
        tool->tool.compressed = delegate_compressed;
        tool->tool.auxtrace = delegate_auxtrace;
+       tool->tool.schedstat_cpu = delegate_schedstat_cpu;
+       tool->tool.schedstat_domain = delegate_schedstat_domain;
 }