From nobody Mon Apr 6 10:43:26 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AE0341325A for ; Thu, 19 Mar 2026 23:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962693; cv=none; b=e3GMKNyWzt7uL37wLcKadnKe/iNJ9D1Evo62OEMp/55UDpc79fU1056dl0/kaelrF8yfHpeWaSp553kFs1EMv5pjg4q+ByxJWZbbemd5OWQ2Rp9lLZ+nMQXgAWlTxNL+/58hysPb2tmpsDSPNvfbuAwJfXbrvpUpFgGJcwTj1eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962693; c=relaxed/simple; bh=nQKlfJP7iPPRZwHgkfibxtIFOBIy32Z3EoTWSHNa2g4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rgp6X3WJPu4gNN+W9y3JMXD237BzsHx7qFmCttOP2wc/X94tsEObfCwrqE8jsv5u1f11Bp334Sa5ZyaZ67T1QCcMo3cRTBVlncSqFRikgnmLetdQZjFvfEAzDkq8zb3RXBB8Ppnm3TjkKk5I1t6SKXCt4x3W8Xd8jEyB+1zlC4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bbB+PiVG; arc=none smtp.client-ip=74.125.82.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bbB+PiVG" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0fb39b41aso2237392eec.0 for ; Thu, 19 Mar 2026 16:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962692; x=1774567492; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M9pkC5P8S36AmhD0fZGvAVfRmdPNACn5tpVw32aG+t0=; b=bbB+PiVGpqyluVoAilICVjx6zvZ5vslZJUuSBfoxnyruQuOJrZj1szIOcKIvZ4jAHE dMzw+7nNHoD8xlq1/TepyKJ2VICe/UEdrhtSyZlQzV9C2K0OI65SgPoGmGBgj7c6qtfl 8n0RSWJO42XDKNDWdJdTTbcMdLbD1JNH1efeiMbukazAzP3/BaOuKEXBV9sgroyTHQAK iKmQFMKjoHAcpXqT2VCd1X443BWMqXciQO4fgygQHUZ18HOSm3m5FPwq1khP1ktjtOcZ eM0rTvYTh/non9ePk3hBuLH+tg0fRWybaYpMY4Pd4ApFuHTUn/KSrMVPclBf7nW47Ydk gL7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962692; x=1774567492; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M9pkC5P8S36AmhD0fZGvAVfRmdPNACn5tpVw32aG+t0=; b=ZI/O69smGM9Sxwid90bi3M36DVcOJjKcMHGuFGCsSzXKlUVtKGWvBnxNcfv28+cD8N acziuaBhBB4ZWmTa12Cl9SJ86lGT+rEPwCv9YPiqmMShJy+OVL6gZV0Iwu9m4lsKC/0p xaaUSSUPFk4xTpKjIm13/bU86imHdi9T0vWMJB9PPXF2GhpQumXWoeoR5daa80eiYvO3 ywgL1LKDNq8rrwWvYpQ6YJiaxvwWJGSRJAcZ35uyoVo3W+zT2WzZmdB6QxyrdwtJJ0F1 qDoh7sfd5rNMiOkjxIk14RneEPu3ZPsBAKcO4MazaqabohQuJ1LjjbvYgJKRLJ/Huw5o g+ug== X-Forwarded-Encrypted: i=1; AJvYcCVTRn+fO3n0M0FTtDRTjskr0unKR4YUndeJJvFqwPUARuf2jGtkjsUpPC6WYjUJfAvgZo17GwcvmcCTSBc=@vger.kernel.org X-Gm-Message-State: AOJu0YygRjyqOYzw+h4uDMtSBwcmr4EVqHBSqg9O7adzymxiJ3RoO9W4 sslTG+ePhfLeAM5zH+eu/kYDBntXHf9jXiPFufpIuB2b7FVgR9eRQmR/A/3isT0fBvMYUMId0CQ s3va0zH69mg== X-Received: from dybso14.prod.google.com ([2002:a05:7301:690e:b0:2c0:b988:33bc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:2216:b0:2be:2cfe:68b7 with SMTP id 5a478bee46e88-2c109622b94mr560778eec.11.1773962691319; Thu, 19 Mar 2026 16:24:51 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:31 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-23-irogers@google.com> Subject: [PATCH v2 22/25] perf evlist: Try to avoid computing evsel from sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the sample has an evsel, don't recompute using the sample.id. Signed-off-by: Ian Rogers --- 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 6e265b66a551..9ea082bccbe6 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -1693,11 +1693,12 @@ static int guest_session__fetch(struct guest_sessio= n *gs) static int evlist__append_id_sample(struct evlist *evlist, union perf_even= t *ev, const struct perf_sample *sample) { - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; void *array; int ret; =20 - evsel =3D evlist__id2evsel(evlist, sample->id); + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample->id); array =3D ev; =20 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; } =20 - evsel =3D evlist__id2evsel(session->evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(session->evlist, sample.id); assert(evsel !=3D NULL); =20 if (event->header.type =3D=3D 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 __m= aybe_unused, int subtest } =20 err =3D -1; - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); perf_sample__exit(&sample); if (evsel =3D=3D NULL) { pr_debug("event with id %" PRIu64 diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.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; } =20 - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); + if (evsel =3D=3D switch_tracking->switch_evsel) { next_tid =3D perf_sample__intval(&sample, "next_pid"); prev_tid =3D 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 =3D evlist__id2evsel(pt->session->evlist, sample->id); + struct evsel *evsel =3D sample->evsel; + + if (!evsel) + evsel =3D evlist__id2evsel(pt->session->evlist, sample->id); =20 if (evsel !=3D 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 =3D event->aux_output_hw_id.hw_id; struct auxtrace_queue *queue; struct intel_pt_queue *ptq; - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; =20 queue =3D auxtrace_queues__sample_queue(&pt->queues, sample, pt->session); - evsel =3D evlist__id2evsel_strict(pt->session->evlist, sample->id); + if (!evsel) + evsel =3D 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; --=20 2.53.0.959.g497ff81fa9-goog