From nobody Mon Apr 6 10:43:23 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 7A83F345CBF for ; Sat, 4 Apr 2026 03:44:27 +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=1775274268; cv=none; b=Ogq+aRFmHDAe46sNKDEdcFHayuFkNJ0001q7yRJyH/JpoSnEuDwzJLMcV8zeLZWI7yxcUbDGduw25FrSFqCqnZD8ErHeO5nAqXmdek/5XhcXt0bG9egAnLQfFyA+VaVH6GFOxPFCwu2Rb7B0U5b/LaJ8LYRBFFpmuDcwO2pR/64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775274268; c=relaxed/simple; bh=k5i5sAO0y8qY7nlvkKW946Esrzoa6VEd6G/7Q2q0J3k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fwAVpFo2mzImjtOVV4TBcqTDK3ohF1VtPW50n4G42gqL/Y6XoCJ0Fc9qVwC10AQoCwlJ4DdfT6LZuF+ht20w1SE1RmzTtakgSM5L7DGDIWixe18jG0vu0yifvD4BV7Jm1yW/f3PIHEFrQJAhFxjiD9fw1G2cFxFMjr+9Ja4f4yY= 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=tXgzwzds; 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="tXgzwzds" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2ba8013a9e3so2999512eec.0 for ; Fri, 03 Apr 2026 20:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775274267; x=1775879067; 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=2WKw7C0m5tQyiuT/6uQYS0H5P1XoW1hNm0eAI6Ck/fE=; b=tXgzwzds4CWMa3k3xK+Edu0dTenCKSSm9paMo6xbmThTXH0Wk2pwJSiOO9Sqms35vK OOD6DEg1PKJ25fAVqqvdSOpOOBRlBsc07gjmPwri2kSVdiwRD9YFgZimQrZQmm0Ggwzi Q1wQVqCMnIVB2eRjKavDOaGb9cu7Jkv0dCOr1Le62deGBQGl4S61lNUyuhHnKSTaevx+ 40Ii3/PeZjDcLyefoZBsEBB5QmkzSIt1b1JBbZEzecuSt2vJkZAEwuV2UYiMpyBfdSLl SgAqVn4WdA2pv/uR7h8dwKSbMwOpe0rNym9sGrGAxHfzitA0su8GoJl9OjRHa89g/stU jYbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775274267; x=1775879067; 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=2WKw7C0m5tQyiuT/6uQYS0H5P1XoW1hNm0eAI6Ck/fE=; b=YmWSxLstENU6kLQNMXWELj4WDlJwlgXvzGo9q+RgSDi8Kg4eUVAnxkZVeyiJosrkfH alP+dqhZc8NrXf4r0r69m6V32kE9UYoEw/GWbQNg8kKagLHY3qyIEmz+X4exvjG9cQMt j1lup/XHGj0JEH4cPGfVmfteNwEUA7PRp8or652OSj5CfYc96bfRLP7vgkyqHL1G8u2l whYfStIlKWzv1vagLgKjI/2Ifl10+rWnTStyfm/mnm9aVt35eI1OI0zBL34Pxq/9EcUb KD9TOtufd7t2bCv/yKqUXkrGUlmt999O+/ZNsl//J9Z+8w7GPut4xVBImgqmSNX6ePOK S24A== X-Forwarded-Encrypted: i=1; AJvYcCX+oMtCjE1wAhbpujFGNCrwcVwENZQcuyfNpyUTQZ3H+fiZG89Ig0OxARMtr4no8knWVYnpjJIjW3XR04o=@vger.kernel.org X-Gm-Message-State: AOJu0YxHpNpw3/2FNDliBsBa6eM5q0gR0TP5RmK8Q2QWScasVD/fR1n3 FUAmLtC5wKfJ8ZuY6LDM5TQSsMq2BR0qb7foHLj72Y/5lyiInWTCVtx/QJiGWe8j2tcSqdrREQf 7tAhQcosdMQ== X-Received: from dlbtd4.prod.google.com ([2002:a05:7022:1a84:b0:12a:7e51:8986]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6713:b0:12b:ec15:69d3 with SMTP id a92af1059eb24-12bfb74944dmr2130196c88.19.1775274266384; Fri, 03 Apr 2026 20:44:26 -0700 (PDT) Date: Fri, 3 Apr 2026 20:43:21 -0700 In-Reply-To: <20260404034325.3172592-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> <20260404034325.3172592-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260404034325.3172592-22-irogers@google.com> Subject: [PATCH v6 21/25] perf trace: Don't pass evsel with 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" 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 | 51 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index b694e1219807..4d9459c0cce5 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2584,7 +2584,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 @@ -2779,10 +2779,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; @@ -2925,10 +2926,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; @@ -3063,7 +3065,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) { @@ -3124,7 +3126,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) { @@ -3146,7 +3148,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, @@ -3257,10 +3259,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 @@ -3366,7 +3369,6 @@ static void print_location(FILE *f, struct perf_sampl= e *sample, } =20 static int trace__pgfault(struct trace *trace, - struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3395,7 +3397,7 @@ static int trace__pgfault(struct trace *trace, if (ttrace =3D=3D NULL) goto out_put; =20 - if (evsel->core.attr.config =3D=3D PERF_COUNT_SW_PAGE_FAULTS_MAJ) { + if (sample->evsel->core.attr.config =3D=3D PERF_COUNT_SW_PAGE_FAULTS_MAJ)= { ttrace->pfmaj++; trace->pfmaj++; } else { @@ -3411,7 +3413,7 @@ static int trace__pgfault(struct trace *trace, trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->ou= tput); =20 fprintf(trace->output, "%sfault [", - evsel->core.attr.config =3D=3D PERF_COUNT_SW_PAGE_FAULTS_MAJ ? + sample->evsel->core.attr.config =3D=3D PERF_COUNT_SW_PAGE_FAULTS_MAJ ? "maj" : "min"); =20 print_location(trace->output, sample, &al, false, true); @@ -3436,7 +3438,8 @@ static int trace__pgfault(struct trace *trace, if (callchain_ret > 0) trace__fprintf_callchain(trace, sample); else if (callchain_ret < 0) - pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evs= el)); + pr_err("Problem processing %s callchain, skipping...\n", + evsel__name(sample->evsel)); =20 ++trace->nr_events_printed; out: @@ -3448,7 +3451,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) { /* @@ -3460,7 +3462,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 @@ -3480,11 +3482,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); @@ -3626,32 +3628,33 @@ 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; =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) { + if (sample->evsel =3D=3D NULL) + sample->evsel =3D evlist__id2evsel(trace->evlist, sample->id); + + if (sample->evsel =3D=3D NULL) { fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sampl= e->id); return; } =20 - if (evswitch__discard(&trace->evswitch, evsel)) + if (evswitch__discard(&trace->evswitch, sample->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 && + if (sample->evsel->core.attr.type =3D=3D PERF_TYPE_TRACEPOINT && sample->raw_data =3D=3D NULL) { fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, r= aw_size=3D%d, skipping...\n", - evsel__name(evsel), sample->tid, + evsel__name(sample->evsel), sample->tid, sample->cpu, sample->raw_size); } else { - tracepoint_handler handler =3D evsel->handler; - handler(trace, evsel, event, sample); + tracepoint_handler handler =3D sample->evsel->handler; + handler(trace, event, sample); } =20 if (trace->nr_events_printed >=3D trace->max_events && trace->max_events = !=3D ULONG_MAX) --=20 2.53.0.1213.gd9a14994de-goog