[PATCH v1 14/25] perf report: Directly use sample->evsel to avoid computing from sample->id

From: Ian Rogers

Date: Mon Feb 09 2026 - 12:49:24 EST


In count_lost_samples_events try to avoid searching for the evsel for
the sample, just use the variable within the sample.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/builtin-report.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index ae7985ec2bd8..c088c7f94fac 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -793,9 +793,11 @@ static int count_lost_samples_event(const struct perf_tool *tool,
struct machine *machine __maybe_unused)
{
struct report *rep = container_of(tool, struct report, tool);
- struct evsel *evsel;
+ struct evsel *evsel = sample->evsel;
+
+ if (!evsel)
+ evsel = evlist__id2evsel(rep->session->evlist, sample->id);

- evsel = evlist__id2evsel(rep->session->evlist, sample->id);
if (evsel) {
struct hists *hists = evsel__hists(evsel);
u32 count = event->lost_samples.lost;
--
2.53.0.239.g8d8fc8a987-goog