From nobody Mon Apr 6 09:10:45 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 042F0375AA6 for ; Fri, 20 Mar 2026 08:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773994169; cv=none; b=eWD4nhzQcjesbd3oWrvHhQkKVEJMnJ4DHPxlud6EV8Tvtr5liLVqWnGInARrCPolW5Cx3syGOJGXZUfF99fsqRcMFkp9TmxLoF85BOd1xNySMao6IUrFr6MfEn3UDO2HtvXpDlvXan+ipNKu6ss91DRPshh6B/jYQbDfULldjuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773994169; c=relaxed/simple; bh=3n96E9V/4QhhKs4hWAjfN7C8Br55p1AJ1VBaBO3fk2Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=G4qOlaDzPjlMW8cEYMp1Y6l06bcOlVKHPCjAAb5TcLAIkJxA41GOHaiQ9R+2CzbIYNOcMaKbwKBzjgl+tQEaX6GCBXxQpJ98ubBgAR0QSGfMukX7uVhEqU1q/QyS9iRonLLtWcINHnreq3VTMVD5i0qTIsnVZnwoR5WPXZ+bVoc= 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=GgQ+lcYG; arc=none smtp.client-ip=74.125.82.202 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="GgQ+lcYG" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so290582eec.1 for ; Fri, 20 Mar 2026 01:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773994167; x=1774598967; 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=imsNgYZdY1tqbGGPfOlwwoZDMdJ12rSBPWNrXkSgWrs=; b=GgQ+lcYG4OBM/IOY2NP+jTdxOCRh8YVAuZUHEmq53Ec8171LwkYyZRGQh48Lp8myiY Ro+X4xBs9YtE/mV5wfoHan5wD+aR7c1AV7UxcWU7i9vtR/VQmACdoMATaUkcb9jIKzUQ K3wV02Gi6ZCeyXlG/BUs9pOlS6KvKHNAGRUfemar9OVs5MEfZN3lyt6sEoR/UZ/Tf2pz 9CD9/mcbMmpewS4/azGvNbPAF50B107AQMZYBvsQFxBxdq9PkJKmech1j5FpLea+Pz5W aa8wnWrouEx6LUMdVT/Og+TTVBD6PCJk+1k2FfwDE4enbDdh+G1l1ku1FOV+QPv2UAQ5 Phag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773994167; x=1774598967; 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=imsNgYZdY1tqbGGPfOlwwoZDMdJ12rSBPWNrXkSgWrs=; b=cNQiZ5EOdZYRLrgRgImolHtxpQboc4UQF0dmDDcsk+VfliCWWHu3yHJPqYviXWp+ar VBKNLrgBCWO+YONIRtyNPMCen8DvbkUV3X0QjRB25UGDj/tbNNxzy3sFsybWQNs3ALOA /cM42+YFs/BfvRajw45EpXym6nRGcn2sbIPdNW+u+vbTc+iU1DMFvnspQsKiw/UKF4pQ q9gD5pdLZu4t6kXJtbm9x2lfKUvR6dBpfT1GgvKNxuxJhaXGOTR4iWRD5gBVE7MPI8OB /c/TqeEemeKEi2PmY4RATCC5Qgjb4uCZRYqp8gdZGXbdgXXowMn0RNF1A5WLI4ZzYC6c o9Yw== X-Forwarded-Encrypted: i=1; AJvYcCV2Qp8oxL0mGPj1AtWW+AddlhtKES+QoNGP3/nmJA9/ZUqKz1x4Z4N6srkB1nLsKU5W7A3GrHILaKsPJRE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxai5yMJx8rIltWE8hHkz66TNE0a84W5CeK/D7GBds87LJvXtS1 1i3vUaZg7sV6TW5gQOXdJ57+R5VtkcwJGdc8PBibhRFWnD1mSynnhodf+/T6Xod1yQA5Lfodvjj yb7z1CLEEag== X-Received: from dycol10.prod.google.com ([2002:a05:7301:db8a:b0:2c0:bd37:a753]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:ed06:b0:2c0:dae2:9c5f with SMTP id 5a478bee46e88-2c109563c3fmr1001101eec.2.1773994166967; Fri, 20 Mar 2026 01:09:26 -0700 (PDT) Date: Fri, 20 Mar 2026 01:08:30 -0700 In-Reply-To: <20260320080835.724836-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: <20260319232334.287517-1-irogers@google.com> <20260320080835.724836-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260320080835.724836-22-irogers@google.com> Subject: [PATCH v3 21/25] perf trace: Don't pass evsel with sample From: Ian Rogers To: namhyung@kernel.org Cc: irogers@google.com, acme@kernel.org, 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 | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 385a9ac2ae96..c4ec4f603d5f 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 @@ -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,14 +3624,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; @@ -3638,7 +3642,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) { @@ -3647,7 +3651,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.959.g497ff81fa9-goog