From nobody Mon Apr 6 10:42:14 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 D50D03DC4AA for ; Fri, 3 Apr 2026 20:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775248878; cv=none; b=UOwujyPSCJ6iqCmVmmtZtoS+fK1yyUZg2DAdIHp9CbzUkUUdL8eLcSPuL/M7W/Y3WEUjwaWhQqv+3dxDUecCy+dy+j2QxVZpuHKHbue/zJmV5XXRudq45LTCCBfftzXWepEa8MkY6szOjgiAjtRfJGUmLYMft3aycw4dAY28roI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775248878; c=relaxed/simple; bh=0Keft5t7OBXgX7YaxEhWnWuQSKMAek/Moq2pD9h81W8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kjOr/9FzhTlNm6THfaq18n5Afk9UQZ9ENc5qj3Ste2Uy2aNYNM51JOFnZJn7ObIvNnOeECtxgV59BrXdbUzrokyqqMI8PYPLUGg6TELHsCDRX6APVOryzwTx9Ac9q6iCSP+iL1+Gb41aKryhNypzRBg/nN+mNY5vQCs/NmL16vk= 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=CZyep7Zu; arc=none smtp.client-ip=74.125.82.74 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="CZyep7Zu" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1279caef718so3684385c88.1 for ; Fri, 03 Apr 2026 13:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775248876; x=1775853676; 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=DD9DzZmqkeGtfBm/333ve8pZcjoUvLLGIPaFR8uqSWs=; b=CZyep7ZuoiyRsz9hroi7nbo6pv9x9ArKLhMADVMseqOemggOs5YtCmEu24xYmoTGZp +o8cECOoizce6MVutEl5/rVQc40zzIpUMG3JidUV/8pCE2tvYyy/LxHZv4/CjjukVya7 Co/hFFdzvfRe7HSfjGxYQp82nTtRkEXaMvCeVLS6aQfigof8732xHFE7WdLuZqpohl56 67UPbFwIbsHSX0qysuhLOkTjqtK5EvahlBQ0u9Kc17x7tW4iamkHnDhArmM3kxF4JSll bf/gLxBUGPrfAqx3RhOZYNa2CdGSWe6iz93aH+PPTAgXBB4BsQTH+IoEW9l0U3Jbd5xN PO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775248876; x=1775853676; 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=DD9DzZmqkeGtfBm/333ve8pZcjoUvLLGIPaFR8uqSWs=; b=klgs2tDAfqikUWVn6KmYDARs4pIKr03y/c/sDZBPNvSqCeNMSiWIU9Iq+RIVoMh8bK rfne3EJt9/ZVM9Br2Km4MUd64lxzcKi/huRinfqqVAVAa6zV+VgjeOsvPnTd0CAIHnbr 8zDBPM3/vlnDGNuXc/jnL6fylkfF6yxPMzCnehNiC3g58u3PrCzKCDE/KLdcKUvWKHF0 TZ8dRU+iRYM58WjM/j7lVpcqTKrP3lRzjpdtLnDEqS/I2MdwmpcPtlEg2jIzjWzDu0ca vbNebazpGhCTcnnKOzZ9PbPYYkNCjdyIEzaqE18FMjB6PBvZQoPYMu8603mnFmbb8mAY Amcw== X-Forwarded-Encrypted: i=1; AJvYcCUa9hrz7R5sh3Zo+9K+WZay8rfIOmXSGEfj+SnHKPDtn76N6bgzD2CEQbZ32C+ZS884CLK3mXojXBb7Ez0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywj0eAnpEcPyFBzGtYkLw+Hlj3QfT1BBxYA/HrQvbdapM6xB2na bz2IVObMg4Ksa2NPZvPWFbqwBLf2CXJTvtthRMziC+3yLrpvkT/XvXWQ+Uar9H+LZmVOUKW+2c2 GkYjejkosdg== X-Received: from dycpq3.prod.google.com ([2002:a05:7301:fd03:b0:2c7:1a46:6250]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6629:b0:12a:6b99:1ad4 with SMTP id a92af1059eb24-12bfb6fb392mr2091620c88.11.1775248875900; Fri, 03 Apr 2026 13:41:15 -0700 (PDT) Date: Fri, 3 Apr 2026 13:40:14 -0700 In-Reply-To: <20260403204017.2919994-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: <20260403204017.2919994-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260403204017.2919994-23-irogers@google.com> Subject: [PATCH v5 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-top.c | 4 +++- tools/perf/tests/mmap-basic.c | 4 +++- tools/perf/tests/switch-tracking.c | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a66666e89f67..f8bca1cb5769 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1164,7 +1164,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 22b0302252db..e32331fee277 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"); --=20 2.53.0.1213.gd9a14994de-goog