From nobody Sat Apr 4 07:47:56 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 ECA093D813D for ; Fri, 3 Apr 2026 20:41:14 +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=1775248876; cv=none; b=jI/8SEXECvpcspwEYvyYVq43iBEQ5YUX2yqAvFarJKlQrXYJicq9ns6TAu0kWJNn7zJm62PNu/XKK++7/EiI4+wQ7tv3S6AT29myGx5zC0uYlM4dO4XbFkSrY4OrjK0fCOYGI6sm3mvUIsXxvZQNTCJm2s9nmc/4iuL/60hzj78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775248876; c=relaxed/simple; bh=DMva335Co4SJ5T4aexBmgvFAwe5lZa5RgB/TZ0G1IzE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rI/q8Z+Snd+Fxctd8PULiN8RNGMuE3raBvx8N3qtuzXDp6jXoQqCLrS6jv38eHzaiiNWqc5q8ylBZkYMlh4pKi44jm8SrLxOOq6TaThmakpwwK35VgXAHRK2wZ3W1xTqsHexTiZE2XirB1lrf3AunUD0s6247VX0q/F9ksoU5Ic= 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=TcnZpSG9; 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="TcnZpSG9" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2bdd327d970so1609087eec.1 for ; Fri, 03 Apr 2026 13:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775248874; x=1775853674; 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=LWh26oU1nkbVHiu8Aju0MEDFTjaq7PVSE7AultiAh+U=; b=TcnZpSG9/3yePh52mWy4ERbDKjUHRMtVq0OJwsrskPTzXz7KHCxK4R67ILBq+UQJ+i wjHg5cvrj25QkXSIwBhMclOg8xyirEUzJlP7N0kuPf0GX7JDK0Jc/orJdJSfb6D/Q2e2 0NU7mvQNPgM94LEtOoVuRej4YfnI6PxkEAqj2GlrkXTr+BuDdrW0t9dQaMh5PcKfyR0j psP/ymleY9me7PIwQGTKA9YLRIuU87jULXajz12mbkpJJkh+gFeht+uXLqXXoSYvMeSP wzQ2Mys9ljfyuDX9FORIDb9u0N7yzVHu9FYuVfJKfMAV17gcZg0xTUW9RbA+F/TLKMf7 7w3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775248874; x=1775853674; 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=LWh26oU1nkbVHiu8Aju0MEDFTjaq7PVSE7AultiAh+U=; b=UgasoJ+ZKi2VdOwUB4z2rZj926qMmXz9JPR+fE9SRcZtmd+jKxupl3cHpKIryThOpm c8d2AzDInpeZDMsxTlG5Q8clO5orOoPc+XdgZFUY+9kgV7wUTIau13uSIZlo3ucwCg+h l6c4yJFrviwgUw6bDpuFo53Wtypp4L9V9EHjiPu8WIWRvMus1htEPBIvuh2zehUwntA1 tp0O5U5bZ2s+uPjmqulqzHVYvCalzznNe4Whm0/hQAZUJ7NPO1+S2oT7tB+zV7c5XC2J bXbsW9kHWhkcjEby96IDYMxSx3J32XYe2NKH7rYw+pig6KI56mUY9A2q7ZvqW+1cWXqT Y54A== X-Forwarded-Encrypted: i=1; AJvYcCVklBrA+xRyKPz1vlp1OkZ8vyqFtaz7WA83eI9nsWz9m4uPE7zmggTSQ065JtnvkWj51Qww25LCagYKAuc=@vger.kernel.org X-Gm-Message-State: AOJu0YwzyG2FCp/v5I+k4WGaWjjpYjxffPcSQNAN1fADhytnE9mvrEkj G0Jp/+KBQgwMiELDxUo1jlQV99gZxACxLclTVfY+yo7WJO1KgHjzNZt9WUGj3xOSUM5cnwQEE81 fHGFQBzD3eQ== X-Received: from dlah11.prod.google.com ([2002:a05:701b:260b:b0:127:82fc:dd48]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:1609:b0:123:3301:a718 with SMTP id a92af1059eb24-12bfac01230mr1754668c88.1.1775248873796; Fri, 03 Apr 2026 13:41:13 -0700 (PDT) Date: Fri, 3 Apr 2026 13:40:13 -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-22-irogers@google.com> Subject: [PATCH v5 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 161e2e62bf1e..d97d0b1b3762 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2580,7 +2580,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 @@ -2775,10 +2775,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; @@ -2921,10 +2922,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; @@ -3059,7 +3061,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) { @@ -3120,7 +3122,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) { @@ -3142,7 +3144,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, @@ -3253,10 +3255,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 @@ -3362,7 +3365,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) { @@ -3391,7 +3393,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 { @@ -3407,7 +3409,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); @@ -3432,7 +3434,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: @@ -3444,7 +3447,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) { /* @@ -3456,7 +3458,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 @@ -3476,11 +3478,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); @@ -3622,32 +3624,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