[PATCH v1 25/25] perf evsel: Don't pass evsel with sample

Ian Rogers
2026-02-09T17:41:37Z

Arrange for the sample to contain the evsel and so it is unnecessary
to pass the evsel as well. This is done for uniformity, although
parsing of the sample is arguably a special case.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/evsel.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 041766d39ec3..21602d121260 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2997,10 +2997,10 @@ int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads)
return ret;
}

-static int perf_evsel__parse_id_sample(const struct evsel *evsel,
- const union perf_event *event,
+static int perf_evsel__parse_id_sample(const union perf_event *event,
struct perf_sample *sample)
{
+ const struct evsel *evsel = sample->evsel;
u64 type = evsel->core.attr.sample_type;
const __u64 *array = event->sample.array;
bool swapped = evsel->needs_swap;
@@ -3239,14 +3239,14 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
data->deferred_cookie = event->callchain_deferred.cookie;

if (evsel->core.attr.sample_id_all)
- perf_evsel__parse_id_sample(evsel, event, data);
+ perf_evsel__parse_id_sample(event, data);

return 0;
}

if (event->header.type != PERF_RECORD_SAMPLE) {
if (evsel->core.attr.sample_id_all)
- perf_evsel__parse_id_sample(evsel, event, data);
+ perf_evsel__parse_id_sample(event, data);
return 0;
}

@@ -3606,12 +3606,13 @@ int evsel__parse_sample_timestamp(struct evsel *evsel, union perf_event *event,

if (event->header.type != PERF_RECORD_SAMPLE) {
struct perf_sample data = {
+ .evsel = evsel,
.time = -1ULL,
};

if (!evsel->core.attr.sample_id_all)
return -1;
- if (perf_evsel__parse_id_sample(evsel, event, &data))
+ if (perf_evsel__parse_id_sample(event, &data))
return -1;

*timestamp = data.time;
--
2.53.0.239.g8d8fc8a987-goog