]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf evlist: Try to avoid computing evsel from sample
authorIan Rogers <irogers@google.com>
Wed, 20 May 2026 19:05:24 +0000 (12:05 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 May 2026 19:39:40 +0000 (16:39 -0300)
As struct perf_sample now directly contains its own resolved evsel pointer,
passing the evsel separately is redundant and clutters the interface.

Remove the redundant evsel parameter from evlist-specific handlers and
structures, ensuring the tool always directly accesses the evsel bound to the
sample. This simplifies the API signatures and eliminates the risk of passing
an inconsistent evsel.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrew Jones <ajones@ventanamicro.com>
Cc: Anup Patel <anup@brainfault.org>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Blake Jones <blakejones@google.com>
Cc: Chen Ni <nichen@iscas.ac.cn>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Derek Foreman <derek.foreman@collabora.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Hrishikesh Suresh <hrishikesh123s@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Krzysztof Ɓopatowski <krzysztof.m.lopatowski@gmail.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quan Zhou <zhouquan@iscas.ac.cn>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Tianyou Li <tianyou.li@intel.com>
Cc: Yujie Liu <yujie.liu@intel.com>
Cc: tanze <tanze@kylinos.cn>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-top.c
tools/perf/tests/mmap-basic.c
tools/perf/tests/switch-tracking.c

index 6cf73bb0c7afec987e1383494ef036a3b35e3dd4..c8474f7ac65809a1c85297ebbcc17f453874f500 100644 (file)
@@ -1164,7 +1164,9 @@ static int deliver_event(struct ordered_events *qe,
                goto next_event;
        }
 
-       evsel = evlist__id2evsel(session->evlist, sample.id);
+       evsel = sample.evsel;
+       if (!evsel)
+               evsel = evlist__id2evsel(session->evlist, sample.id);
        assert(evsel != NULL);
 
        if (event->header.type == PERF_RECORD_SAMPLE) {
index 3313c236104ee706980fad94f07038b25aebef54..a18d84d858aa5d68bd0ad4370483c0961ce8922f 100644 (file)
@@ -142,7 +142,9 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
                }
 
                err = -1;
-               evsel = evlist__id2evsel(evlist, sample.id);
+               evsel = sample.evsel;
+               if (!evsel)
+                       evsel = evlist__id2evsel(evlist, sample.id);
                perf_sample__exit(&sample);
                if (evsel == NULL) {
                        pr_debug("event with id %" PRIu64
index 22b0302252db55cfb4e4f27453b5ffe70428f910..e32331fee2778c3ca49f86daa56a501b5fa89f87 100644 (file)
@@ -138,7 +138,10 @@ static int process_sample_event(struct evlist *evlist,
                goto out;
        }
 
-       evsel = evlist__id2evsel(evlist, sample.id);
+       evsel = sample.evsel;
+       if (!evsel)
+               evsel = evlist__id2evsel(evlist, sample.id);
+
        if (evsel == switch_tracking->switch_evsel) {
                next_tid = perf_sample__intval(&sample, "next_pid");
                prev_tid = perf_sample__intval(&sample, "prev_pid");