From nobody Wed Feb 11 02:06:20 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 7B02238A9B1 for ; Mon, 9 Feb 2026 17:41:29 +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=1770658889; cv=none; b=X8D02GIVAziRf1CZ1JLZconjaLPMMXZUH06S7uSjsWAAyWslcAk0+sjzsBritWEOPFf8ts/AsJdpDpl8ObF00xx9TXxzRah/BJLoU1+SkTqQf/D5oe5nbJeFVZkS5mw3aTFDvUXjuJbBsSrtlyaWLxygGnBB5POlZ/sqOo5/m50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770658889; c=relaxed/simple; bh=ocuQx4XZuiRO8GRHqqD7nSksu0emgzMFKlbAu1B4fIQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=t7qzD4SpFa2pw6lmy0g0yK6Hbh3bJD9OHFtMcW/+KnJ6baY+wmlSbLYtv1CWWayoyHxcArb3h5jJmd6zuixNEwOiv0QfhNKSPYBP7ZgKH91OJclMBoa2UeaeOKj0Wm0kYOGlBQYTmIIfCLwwC0v/tuCSs/USj4nib3oWNH+1XBI= 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=pTUZetdO; 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="pTUZetdO" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12711ec96fbso2109831c88.0 for ; Mon, 09 Feb 2026 09:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770658889; x=1771263689; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=KaiONckexinVenjREn7UXtQSsVVfjES5HZqD8w+j0WM=; b=pTUZetdO1WtPRHWuKALmlILxkfZiGNfXVmK1ykOWxcCMxMY7W8uL01lLa+Wq07aTJA PyNAlMbB0M/wxTNkIyc4ClDIGkpoRiYFnXUIqcXXUrUhDcwU4/FN8H+Vw6JjMHAVa/+p sU1rq0g3Vh8B21ndVWMc+AqBUREK2NI7I28PsgSk1OKgFHYB4H1Z9b88B6w6p8PTVdq4 5aFxImYFxhI4rjQqBRREcfgsqjIjhaRHlIr4hoCprJr9QX4MHVKICCss5oPEL2Vyuqp8 ynW4Iwn9xebdymoIBmSq5rigMtmp3afiPIM8+q16pPpWUFq+r+jypNXWqWzAx75g1iaw I4Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770658889; x=1771263689; h=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=KaiONckexinVenjREn7UXtQSsVVfjES5HZqD8w+j0WM=; b=D60wrAcxKeqzHD66cEnuDpiOWo0grXBxIRSKPi+Tk+mB8XDUwkCI5UMj/7RJH3Uab6 OTGWVCUM7ykoPqfjdrdhxJogsqa6+ObSlDFH3CfyPFajnGx62N1FetPnwYXPRTluuqKr yGgBBpVo+MQwHpT7455rqVUnuXNGaPYm9+bZonDKD0JBs6acf2WCfMmixBwia6gY8Xs6 tNg5Hrnm9tp9Fi2YuiKYBnOxuzhBUIOlQ76XdOOZQTwmPECeCQEjPVA8kR+q+WxIbZp7 f3BJiv+i6dnsVu14PAIwHxY7dtKde5jYNXg6W3KoFjyDBNF6MHqJtfL57o4xJvXjBL36 QQjQ== X-Forwarded-Encrypted: i=1; AJvYcCVcR1gkPsQ2nM9/eog9RmpKYPMPwduLAdGFWNOnlTistoXKRlxspGEM7zQ0u9CgZPQVim6SO2ctyxLYxDI=@vger.kernel.org X-Gm-Message-State: AOJu0Ywxzpysat7TeTKGDXFv4cp5rG5+pVtboTtnXVPj+la3VaSUKChB +pxa+hmJfc/QJFvdFlK3FC3Dc/D5v8W1NfUt2g/cXhnYY3QQM2Bgf6PfuzaauwEJdQ8ctwPjqSq eLAqyk+2rRw== X-Received: from dlbdx36.prod.google.com ([2002:a05:7022:e24:b0:11f:36a2:78d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:670d:b0:119:e569:f25f with SMTP id a92af1059eb24-12703fd961cmr6328080c88.8.1770658888326; Mon, 09 Feb 2026 09:41:28 -0800 (PST) Date: Mon, 9 Feb 2026 09:40:28 -0800 In-Reply-To: <20260209174032.4142096-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> X-Mailer: git-send-email 2.53.0.239.g8d8fc8a987-goog Message-ID: <20260209174032.4142096-22-irogers@google.com> Subject: [PATCH v1 21/25] perf trace: Don't pass evsel with sample From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Leo Yan , Tianyou Li , Athira Rajeev , Derek Foreman , Thomas Falcon , Howard Chu , Dmitry Vyukov , Andi Kleen , tanze , Hrishikesh Suresh , Quan Zhou , Andrew Jones , Anup Patel , Dapeng Mi , "Dr. David Alan Gilbert" , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , Chun-Tse Shao , Ravi Bangoria , Swapnil Sapkal , Chen Ni , Blake Jones , Yujie Liu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. In trace__handle_event try to use the evsel from the sample to avoid recomputation. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index b6e90ee53cbe..ff3c85144038 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2579,7 +2579,7 @@ static struct syscall *trace__find_syscall(struct tra= ce *trace, int e_machine, i return sc; } =20 -typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel, +typedef int (*tracepoint_handler)(struct trace *trace, union perf_event *event, struct perf_sample *sample); =20 @@ -2774,10 +2774,11 @@ static void *syscall__augmented_args(struct syscall= *sc, struct perf_sample *sam return NULL; } =20 -static int trace__sys_enter(struct trace *trace, struct evsel *evsel, +static int trace__sys_enter(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; char *msg; void *args; int printed =3D 0; @@ -2920,10 +2921,11 @@ static int trace__fprintf_callchain(struct trace *t= race, struct perf_sample *sam return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchai= n_cursor(), symbol_conf.bt_stop_list, trace->output); } =20 -static int trace__sys_exit(struct trace *trace, struct evsel *evsel, +static int trace__sys_exit(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; long ret; u64 duration =3D 0; bool duration_calculated =3D false; @@ -3058,7 +3060,7 @@ errno_print: { return err; } =20 -static int trace__vfs_getname(struct trace *trace, struct evsel *evsel __m= aybe_unused, +static int trace__vfs_getname(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3119,7 +3121,7 @@ static int trace__vfs_getname(struct trace *trace, st= ruct evsel *evsel __maybe_u return 0; } =20 -static int trace__sched_stat_runtime(struct trace *trace, struct evsel *ev= sel, +static int trace__sched_stat_runtime(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3141,7 +3143,7 @@ static int trace__sched_stat_runtime(struct trace *tr= ace, struct evsel *evsel, =20 out_dump: fprintf(trace->output, "%s: comm=3D%s,pid=3D%u,runtime=3D%" PRIu64 ",vrun= time=3D%" PRIu64 ")\n", - evsel->name, + sample->evsel->name, perf_sample__strval(sample, "comm"), (pid_t)perf_sample__intval(sample, "pid"), runtime, @@ -3252,10 +3254,11 @@ static size_t trace__fprintf_tp_fields(struct trace= *trace, struct perf_sample * return fprintf(trace->output, "%.*s", (int)printed, bf); } =20 -static int trace__event_handler(struct trace *trace, struct evsel *evsel, +static int trace__event_handler(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct thread *thread; int callchain_ret =3D 0; =20 @@ -3443,7 +3446,6 @@ static int trace__pgfault(struct trace *trace, } =20 static void trace__set_base_time(struct trace *trace, - struct evsel *evsel, struct perf_sample *sample) { /* @@ -3455,7 +3457,7 @@ static void trace__set_base_time(struct trace *trace, * appears in our event stream (vfs_getname comes to mind). */ if (trace->base_time =3D=3D 0 && !trace->full_time && - (evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) + (sample->evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) trace->base_time =3D sample->time; } =20 @@ -3475,11 +3477,11 @@ static int trace__process_sample(const struct perf_= tool *tool, if (thread && thread__is_filtered(thread)) goto out; =20 - trace__set_base_time(trace, evsel, sample); + trace__set_base_time(trace, sample); =20 if (handler) { ++trace->nr_events; - handler(trace, evsel, event, sample); + handler(trace, event, sample); } out: thread__put(thread); @@ -3621,14 +3623,16 @@ static void evlist__free_syscall_tp_fields(struct e= vlist *evlist) static void trace__handle_event(struct trace *trace, union perf_event *eve= nt, struct perf_sample *sample) { const u32 type =3D event->header.type; - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; =20 if (type !=3D PERF_RECORD_SAMPLE) { trace__process_event(trace, trace->host, event, sample); return; } =20 - evsel =3D evlist__id2evsel(trace->evlist, sample->id); + if (evsel =3D=3D NULL) + evsel =3D evlist__id2evsel(trace->evlist, sample->id); + if (evsel =3D=3D NULL) { fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sampl= e->id); return; @@ -3637,7 +3641,7 @@ static void trace__handle_event(struct trace *trace, = union perf_event *event, st if (evswitch__discard(&trace->evswitch, evsel)) return; =20 - trace__set_base_time(trace, evsel, sample); + trace__set_base_time(trace, sample); =20 if (evsel->core.attr.type =3D=3D PERF_TYPE_TRACEPOINT && sample->raw_data =3D=3D NULL) { @@ -3646,7 +3650,7 @@ static void trace__handle_event(struct trace *trace, = union perf_event *event, st sample->cpu, sample->raw_size); } else { tracepoint_handler handler =3D evsel->handler; - handler(trace, evsel, event, sample); + handler(trace, event, sample); } =20 if (trace->nr_events_printed >=3D trace->max_events && trace->max_events = !=3D ULONG_MAX) --=20 2.53.0.239.g8d8fc8a987-goog