[PATCH v12 11/33] perf report: Directly use sample->evsel to avoid computing from sample->id

Ian Rogers
2026-04-13T04:12:25Z

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@google.com>
---
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 ff7117c5470f..3deb21f4d781 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -788,9 +788,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.1213.gd9a14994de-goog