From nobody Mon Apr 6 10:42:06 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 D615341163F for ; Thu, 19 Mar 2026 23:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962691; cv=none; b=SzDhvQPkBvnYM4BxtE8FVK9L25y4tW8zOsvHed/25F1HmAesF3B6SFIcUBUbbB5HomHCtSobo+wc8PB9IzGZddso6QOXjgMEFahlDi3tson+l0Irqpv+f+i0z+VZ6ugoFckYlAMp9c2GkzgL4J2/xFrg4ZKVLbLRT9lhS5fR1rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962691; c=relaxed/simple; bh=3n96E9V/4QhhKs4hWAjfN7C8Br55p1AJ1VBaBO3fk2Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=g6kpiAuDoxCp/Ulb5Ne2iV2PaQCE1ym2lFac5fk9phXsrUUImmvmKMWXeJul7yteASX3ERGwllAWtFgX39nfUs8aZVDFTYaLvMarAybxqYA50E0ZT6xSewj8/nMXgq9vqhkJyBF/LjBusJL9pGHt8Hvqqc+dCbeeorJaCSl61gc= 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=U+iGpN7h; arc=none smtp.client-ip=74.125.82.73 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="U+iGpN7h" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1279caef718so1973529c88.1 for ; Thu, 19 Mar 2026 16:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962689; x=1774567489; 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=U+iGpN7h2qyyAmxey0iFQ6DNX58j3KvzAqWU4ttNO3B1Ov0V50q4D5XpBse5QLMWIf mLFqiisBsg3CkDMiTLbaqnPfT9vHFfRHiUZrmp1RYgcJQakimHeBzXLmDQL55U+BQceb PRmJoo+YX+YLBmtOMNoGCngtT03vt5/wzVVJzIFl+0QwOfRrWRQ2ilmWGJTioZmtsj16 xPZoIcrpEpee9y4WfGLWqWVDu+ql1nEiuls1XQMOXxzV9tDYO6bVxcyKQUUtn7HZLEir EuU4j80Xqq9H3NS67mG65bn3pfiY6X1m/1QR17gl1p55S1gDS5B8/Xbh1QMRyLp4voul uSYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962689; x=1774567489; 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=KFLWcODH1znStEBapdHf9deHENgYsOgBQzl0AwylYAlH3e83QtGe2rHePM+HIPQXiw r2XN3b8RTlYIvnxeTXDYcvduwAvxZYunA8/Hx4inN89hAl/TgFKN7slFrv8pV/RtIyvq Tcxd6Idf26+71kKSmJS0iwxO0mPyD91ZYZWrOr7UkjGxJeuv1F8f4ezKiEwR+FO2Vev0 rlvaWnSGUjQvaIIxqNGlwn+0se+hk235hOUlGM04ywvWM2PN+7EjTpM4kb+UkmFqPiKa 1Hj2HbO0mFr3QCvxtL2hN0LSihthfTCXJYXkzkt1VX2xWFWCdi9FS6V/vUSv9+WoBv1L Peuw== X-Forwarded-Encrypted: i=1; AJvYcCVXsGGHLCaHuTqmH9gXmEYf5k3J+AzhlRR059iFno9J1poQE/9yQa/HKtsO6RUSUHwgqSPaDHrL9A3pY4M=@vger.kernel.org X-Gm-Message-State: AOJu0YzVxsny0mn6mw4GWvVLPdossdJI8WSIFqrQxROuK8Z1iOHpHhgF l2B2xu063JcEwpLkS7q41J+fMhjKgc82PZR9hnbS0o5yaHSH8CVpq1aod6/RghApAexz0zNp7UG vDiOoHTT8CQ== X-Received: from dyblf40.prod.google.com ([2002:a05:7301:a28:b0:2c0:e2b8:48ba]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:3b0b:b0:2c0:be45:6811 with SMTP id 5a478bee46e88-2c1097ae93bmr534509eec.32.1773962688847; Thu, 19 Mar 2026 16:24:48 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:30 -0700 In-Reply-To: <20260319232334.287517-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> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-22-irogers@google.com> Subject: [PATCH v2 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 | 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