lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260209174032.4142096-23-irogers@google.com>
Date: Mon,  9 Feb 2026 09:40:29 -0800
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>, 
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, 
	Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>, 
	James Clark <james.clark@...aro.org>, Paul Walmsley <pjw@...nel.org>, 
	Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>, 
	Alexandre Ghiti <alex@...ti.fr>, Leo Yan <leo.yan@....com>, Tianyou Li <tianyou.li@...el.com>, 
	Athira Rajeev <atrajeev@...ux.ibm.com>, Derek Foreman <derek.foreman@...labora.com>, 
	Thomas Falcon <thomas.falcon@...el.com>, Howard Chu <howardchu95@...il.com>, 
	Dmitry Vyukov <dvyukov@...gle.com>, Andi Kleen <ak@...ux.intel.com>, tanze <tanze@...inos.cn>, 
	Hrishikesh Suresh <hrishikesh123s@...il.com>, Quan Zhou <zhouquan@...as.ac.cn>, 
	Andrew Jones <ajones@...tanamicro.com>, Anup Patel <anup@...infault.org>, 
	Dapeng Mi <dapeng1.mi@...ux.intel.com>, "Dr. David Alan Gilbert" <linux@...blig.org>, 
	"Krzysztof Ɓopatowski" <krzysztof.m.lopatowski@...il.com>, Chun-Tse Shao <ctshao@...gle.com>, 
	Ravi Bangoria <ravi.bangoria@....com>, Swapnil Sapkal <swapnil.sapkal@....com>, 
	Chen Ni <nichen@...as.ac.cn>, Blake Jones <blakejones@...gle.com>, 
	Yujie Liu <yujie.liu@...el.com>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: [PATCH v1 22/25] perf evlist: Try to avoid computing evsel from sample

If the sample has an evsel, don't recompute using the sample.id.

Signed-off-by: Ian Rogers <irogers@...gle.com>
---
 tools/perf/builtin-inject.c        |  5 +++--
 tools/perf/builtin-top.c           |  4 +++-
 tools/perf/tests/mmap-basic.c      |  4 +++-
 tools/perf/tests/switch-tracking.c |  5 ++++-
 tools/perf/util/intel-pt.c         | 10 +++++++---
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 66038d68277e..fd3934a7281e 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -1695,11 +1695,12 @@ static int guest_session__fetch(struct guest_session *gs)
 static int evlist__append_id_sample(struct evlist *evlist, union perf_event *ev,
 				    const struct perf_sample *sample)
 {
-	struct evsel *evsel;
+	struct evsel *evsel = sample->evsel;
 	void *array;
 	int ret;
 
-	evsel = evlist__id2evsel(evlist, sample->id);
+	if (!evsel)
+		evsel = evlist__id2evsel(evlist, sample->id);
 	array = ev;
 
 	if (!evsel) {
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b89ca48e5d02..faa422e35166 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1163,7 +1163,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) {
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 3313c236104e..a18d84d858aa 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -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
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index a7ea4b7874be..ed17c3be71c4 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -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");
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index dab23a96b1d8..3d759546a7c0 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -3421,7 +3421,10 @@ static int intel_pt_process_switch(struct intel_pt *pt,
 {
 	pid_t tid;
 	int cpu, ret;
-	struct evsel *evsel = evlist__id2evsel(pt->session->evlist, sample->id);
+	struct evsel *evsel = sample->evsel;
+
+	if (!evsel)
+		evsel = evlist__id2evsel(pt->session->evlist, sample->id);
 
 	if (evsel != pt->switch_evsel)
 		return 0;
@@ -3611,10 +3614,11 @@ static int intel_pt_process_aux_output_hw_id(struct intel_pt *pt,
 	u64 hw_id = event->aux_output_hw_id.hw_id;
 	struct auxtrace_queue *queue;
 	struct intel_pt_queue *ptq;
-	struct evsel *evsel;
+	struct evsel *evsel = sample->evsel;
 
 	queue = auxtrace_queues__sample_queue(&pt->queues, sample, pt->session);
-	evsel = evlist__id2evsel_strict(pt->session->evlist, sample->id);
+	if (!evsel)
+		evsel = evlist__id2evsel_strict(pt->session->evlist, sample->id);
 	if (!queue || !queue->priv || !evsel || hw_id > INTEL_PT_MAX_PEBS) {
 		pr_err("Bad AUX output hardware ID\n");
 		return -EINVAL;
-- 
2.53.0.239.g8d8fc8a987-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ