From nobody Mon Jun 15 18:01:56 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 586171F099C for ; Mon, 13 Apr 2026 01:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043354; cv=none; b=is6dFVzUShgOwxMdaG3bxK1TBARQL1rIZSCT64Nl0A8Xq1jy/g5HOVk6MOxDPn/aO93a8DB3on/92pxpdY8Jq8DqHx8VHs4EO4sSksyFCAhIPNAVI1MkXwQF0iAH7wbCe1suzMJ2qF3thp0Sxfhtr2Bik4a1QPLxj8T88wt+0Ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043354; c=relaxed/simple; bh=n2JtyMg3dnFRI+CN9oMKk3aLsRiKCNqRLI02Htuc8WQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZNhakddUJToehkLr+KiUX4WGpCHe8lGgaglHAm5CytBihnWmjyFZCWUg2kztlWx3pHXkC6FcnvV06/Fns0ucimW/aNwUxXD5O3BWRsHseihCfw31+wzKwu+kC9x5TH2YY8qsr8oOsgqTKJ+t44PvFzhrWONMwKuTLAxSqZI55MU= 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=PaXdTP2d; arc=none smtp.client-ip=209.85.214.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="PaXdTP2d" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b2ec17dc21so8473955ad.2 for ; Sun, 12 Apr 2026 18:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043353; x=1776648153; 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=6s1x6GuiQBbflIgwRlrovSdwQa1IJTr9Kbd8z5gwHns=; b=PaXdTP2dFfpFkcqKDc4e0fEBlEEOwAn63rD/OaCM2ClfQ8ow8/ghM+OhBFRfT+WJsv 4PMLZMebrSIbELxKkbnBnoHy/muho5uISqm2lIYJiGstZNXn8KIAgdgWpEIEtkmg7xa1 aK0iH0cc7kfZA9NSyA4OEJcy7ceCyJNp7lPkGKHEoXYwoe/ondlRQiy5Q9lglcacr3N9 BzxFHu/LO8B4ubrBwDcU70SXW6haVkIc8Qb5VUgK7G1B0oAto3TWlNqaXDuVJyrTsHxJ c/5IIgd4eVjPifVoTQJln0U+ckFWjsZZqcsSpjxoz7i22G9bzST7BECQlXZ5SeOPyrvr iUIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043353; x=1776648153; 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=6s1x6GuiQBbflIgwRlrovSdwQa1IJTr9Kbd8z5gwHns=; b=JhT2rK+A9gc0BEX4pNER9tY33X6wlQNqJmB579fMkM7tICru6ixKxY5dtxhivwsPi/ KYXtT1qDMdq5ZqzjBK/TImhwQrhmQIQU6TGJZ0tPTlrVPYryYE4FTyRExLNY76nkdhUB n/iesF6MLnPuLEshZJHpB1VNg+7UcZvhopnHYOo6N2kocIxqDRFUa1/9vXnmxWB4Uws6 RP7w/4PtptdPTv4iV8zq+5iR32iLXKsCu+i+MwlBUHDdSRpdgSkRyQKWwTknSR5JOeJx rJjgk6VQbUDGa7zlAdF6D4UOV1yugi+MedDTfUyPJ7aGrjCHuuPrOUCWzxHsuNYW8DFa KUKA== X-Forwarded-Encrypted: i=1; AFNElJ8gscN0LB6dr4X+lwesx5Mq0xe+IskFNgXW/jbSgBfKfc+WtmMoq869OGMmogaCgEsK6olF5696eWUPyJo=@vger.kernel.org X-Gm-Message-State: AOJu0YzcCnnwlExk4VyerFN0i2UU4bsTDMkHqcxj3QnhyUzXQBqaaEWe 6FYN9PWDRC1/1bXyrFkZLvYf0l67zrcMSqU4kdJYTaZhj55Z7W2AP9qntpmzdOJuIxGNd73lhrq eYA0EZvEr4A== X-Received: from plbml3.prod.google.com ([2002:a17:903:34c3:b0:2b2:4fcd:ced2]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:fa7:b0:2b2:680c:2193 with SMTP id d9443c01a7336-2b2d5a52b4bmr112820495ad.31.1776043352315; Sun, 12 Apr 2026 18:22:32 -0700 (PDT) Date: Sun, 12 Apr 2026 18:21:55 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-2-irogers@google.com> Subject: [PATCH v11 01/33] perf sample: Fix documentation typo From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" s/PEF/PERF/ Signed-off-by: Ian Rogers --- tools/perf/util/sample.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/sample.h b/tools/perf/util/sample.h index ca0c407c4423..e556c9b656ea 100644 --- a/tools/perf/util/sample.h +++ b/tools/perf/util/sample.h @@ -126,7 +126,7 @@ struct perf_sample { u64 time; /** @addr: The sample event PERF_SAMPLE_ADDR value. */ u64 addr; - /** @id: The sample event PERF_SAMPLE_ID or PEF_SAMPLE_IDENTIFIER value. = */ + /** @id: The sample event PERF_SAMPLE_ID or PERF_SAMPLE_IDENTIFIER value.= */ u64 id; /** @stream_id: The sample event PERF_SAMPLE_STREAM_ID value. */ u64 stream_id; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 056AB212554 for ; Mon, 13 Apr 2026 01:22:35 +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=1776043358; cv=none; b=gpk0FPP2RxsXNlpnJwLF8fRSlrP65CqyaCqU/vGsTMaFmufREZmeVXFhnQCHdsnJDcKM4JBO3lOsvS5Qm2hq0Vmre840DRgJbTvcJPVaIbo2WnusRX3nymshElnQySkSMvdZ4VBw6iDJO2beiE92rA5Xh1ky/v6ablKH9QqcEg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043358; c=relaxed/simple; bh=Vb2j/URb3QO7BAssSKxkK5mAjrJs/pLZhsGaxkgHYgM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=omoEgs59lgtVHatHzrpl6Q15Vv8h1YhEUuSmDYZHjYE4gRU69ZeB2SE/6MuE/36ykKkXbYHwp/wUGZ5yv2e5nfgYu4ccgvEZX2XT5ImhmGI7rp5BEE+S1C087Js7+vSxkAqWOo5xQCV52yrmMCh23aeqdDbJ+L3JuQv2mFz59B4= 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=dUGKjxra; 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="dUGKjxra" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1275c6fc58aso4919891c88.0 for ; Sun, 12 Apr 2026 18:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043355; x=1776648155; 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=oAQ3kf9+7lnpDXcb3kNRnHyobYDSr9TH1cF4PamcK4M=; b=dUGKjxra7FgoS7erZ60p6ohnPRYNVBD/DSTzpqrNyvU3M5jiNIf+vpyN1r9oR6aRfd PCuOuFiiRVlQYOABiWgxGwHEDUjP0ZE4ofdhs+UW3sgrVGJjBciCJMBjnWh1Fnb/vU/2 Sjz9VlqtKkM+AwQwlfmEuhBypncby4taOoshzwsrKhIlnqZIgI8theopnfrqcKW3oouF 8LZkm5aKfLMXbvavcC9klmutdQXVx7cLGF7EE+2yufZh5uno0B9wKb8jDGZcn+Nt0CMJ Z6WlVULcKemalFaw2Z32sHl2yCxgKuih5f6GUHqqYC4D2HO0QpC26vGAkrupBvP0VCNk 3NxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043355; x=1776648155; 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=oAQ3kf9+7lnpDXcb3kNRnHyobYDSr9TH1cF4PamcK4M=; b=W++USp8fAo4OMzMxHkQsFlqBbxPe5U987pETnP8iRqkitTlw+NMdKVMsepPxYoEDU8 Q94AqMatvCrYyHZJQoUGTWjmyI3wGVBI/My6PSv3k+pf4xR1Qyb4M427NlsvNzKClnCc ZkfYVXP2Mn0L8GY29Q5fmAEGNR5jXC35rDDzbAxco+359rN3gaK4+zKvM/bwK6gc1h3/ yp4smjGSddAE1yuf3BhQwQ+pP2+FmiYe82D2IZfaNJ1D+lDOB5smx7bCcPCkUUH2X1xr yqoJod0nMcCWFn7ZG9xqiZKLfCsqkivTrTiNimf+UNrQz79y7w1xQaM2Hh7VqzR4NU3t E5sQ== X-Forwarded-Encrypted: i=1; AJvYcCUMINUm2OmRXfu73XXhkN0L6nDPJ45Trl3QR/oGkDaVUXdzsHa+RVJiYypwl3EMZFWT2O9dLh08U734rZQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5jx/FZMIIa4+CWQqWCJTFxp0Fty/REXxT9UqQGEki6EkJpOId epONAQhWB7IzXzZWdGoJykCFvqZlr0T2tTptSd+xQKEjl9AmiGXi9QWc18Dv7+EHced5tgs06Lu mIl+minuRDg== X-Received: from dlbur20.prod.google.com ([2002:a05:7022:ea54:b0:12a:c447:d6bf]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6725:b0:12a:6c4b:9d01 with SMTP id a92af1059eb24-12c34e714cdmr5555849c88.7.1776043354674; Sun, 12 Apr 2026 18:22:34 -0700 (PDT) Date: Sun, 12 Apr 2026 18:21:56 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-3-irogers@google.com> Subject: [PATCH v11 02/33] perf tool: Remove evsel from tool APIs that pass the sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Now struct perf_sample has the evsel within it there is no need to pass the evsel along with the sample. In the called functions read the sample's evsel in to a variable if there are multiple uses, or use directly if there is just one use - the goal being to leave the code with as little change as possible. Some functions only use the evsel to pass to another function which they also pass the sample, in those cases just pass the sample and get the evsel in the called function. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 3 +-- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 19 ++++++--------- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 5 ++-- tools/perf/builtin-kwork.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-mem.c | 1 - tools/perf/builtin-record.c | 3 +-- tools/perf/builtin-report.c | 10 +++----- tools/perf/builtin-sched.c | 4 +-- tools/perf/builtin-script.c | 4 +-- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-trace.c | 2 +- tools/perf/util/build-id.c | 3 +-- tools/perf/util/build-id.h | 7 +----- tools/perf/util/data-convert-bt.c | 2 +- tools/perf/util/data-convert-json.c | 5 ++-- tools/perf/util/intel-tpebs.c | 3 +-- tools/perf/util/jitdump.c | 2 +- tools/perf/util/session.c | 38 ++++++++++++++--------------- tools/perf/util/tool.c | 4 +-- tools/perf/util/tool.h | 4 +-- 24 files changed, 55 insertions(+), 76 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 5e57b78548f4..58e56f826367 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -283,7 +283,6 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_annotate *ann =3D container_of(tool, struct perf_annotate, to= ol); @@ -302,7 +301,7 @@ static int process_sample_event(const struct perf_tool = *tool, goto out_put; =20 if (!al.filtered && - evsel__add_sample(evsel, sample, &al, ann, machine)) { + evsel__add_sample(sample->evsel, sample, &al, ann, machine)) { pr_warning("problem incrementing symbol count, " "skipping event\n"); ret =3D -1; diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 72a7802775ee..7593e5908fcc 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -314,9 +314,9 @@ static void perf_c2c__evsel_hists_inc_stats(struct evse= l *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; struct c2c_hists *c2c_hists =3D &c2c.hists; struct c2c_hist_entry *c2c_he; struct c2c_stats stats =3D { .nr_entries =3D 0, }; diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 1b3df868849a..82e9e514922b 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -390,11 +390,11 @@ static struct hist_entry_ops block_hist_ops =3D { static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_diff *pdiff =3D container_of(tool, struct perf_diff, tool); struct addr_location al; + struct evsel *evsel =3D sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry_iter iter =3D { .evsel =3D evsel, diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index f174bc69cec4..6ba489452777 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -362,18 +362,17 @@ typedef int (*inject_handler)(const struct perf_tool = *tool, static int perf_event__repipe_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { - struct perf_inject *inject =3D container_of(tool, struct perf_inject, - tool); + struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; =20 if (evsel && evsel->handler) { inject_handler f =3D evsel->handler; return f(tool, event, sample, evsel, machine); } =20 - build_id__mark_dso_hit(tool, event, sample, evsel, machine); + build_id__mark_dso_hit(tool, event, sample, machine); =20 if (inject->itrace_synth_opts.set && sample->aux_sample.size) { event =3D perf_inject__cut_auxtrace_sample(inject, event, sample); @@ -387,10 +386,10 @@ static int perf_event__repipe_sample(const struct per= f_tool *tool, static int perf_event__convert_sample_callchain(const struct perf_tool *to= ol, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); union perf_event *event_copy =3D (void *)inject->event_copy; struct callchain_cursor_node *node; @@ -987,10 +986,8 @@ static int mark_dso_hit_callback(struct callchain_curs= or_node *node, void *data) args->mmap_evsel, map, /*sample_in_dso=3D*/false); } =20 -int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, - struct perf_sample *sample, - struct evsel *evsel __maybe_unused, - struct machine *machine) +static int perf_event__inject_buildid(const struct perf_tool *tool, union = perf_event *event, + struct perf_sample *sample, struct machine *machine) { struct addr_location al; struct thread *thread; @@ -1020,7 +1017,7 @@ int perf_event__inject_buildid(const struct perf_tool= *tool, union perf_event *e /*sample_in_dso=3D*/true); } =20 - sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEP= TH, + sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, &args); thread__put(thread); repipe: @@ -1101,7 +1098,7 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, sample_sw.time =3D sample->time; perf_event__synthesize_sample(event_sw, evsel->core.attr.sample_type, evsel->core.attr.read_format, &sample_sw); - build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); + build_id__mark_dso_hit(tool, event_sw, &sample_sw, machine); ret =3D perf_event__repipe(tool, event_sw, &sample_sw, machine); perf_sample__exit(&sample_sw); return ret; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 9c64a0d74823..45b383fa9ce9 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -960,9 +960,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct thread *thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 0c5e6b3aac74..5e8e6fde097a 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -941,9 +941,9 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, =20 static bool handle_kvm_event(struct perf_kvm_stat *kvm, struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct vcpu_event_record *vcpu_record; struct event_key key =3D { .key =3D INVALID_KEY, .exit_reasons =3D kvm->exit_reasons }; @@ -1133,7 +1133,6 @@ static bool skip_sample(struct perf_kvm_stat *kvm, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { int err =3D 0; @@ -1156,7 +1155,7 @@ static int process_sample_event(const struct perf_too= l *tool, return -1; } =20 - if (!handle_kvm_event(kvm, thread, evsel, sample)) + if (!handle_kvm_event(kvm, thread, sample)) err =3D -1; =20 thread__put(thread); diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 9d3a4c779a41..d4bb19ed91b5 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1955,9 +1955,9 @@ typedef int (*tracepoint_handler)(const struct perf_t= ool *tool, static int perf_kwork__process_tracepoint_sample(const struct perf_tool *t= ool, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; =20 if (evsel->handler !=3D NULL) { diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 5585aeb97684..4d8ddf6391e8 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1430,9 +1430,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct thread *thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index d43500b92a7b..6101a26b3a78 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -255,7 +255,6 @@ dump_raw_samples(const struct perf_tool *tool, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel __maybe_unused, struct machine *machine) { return dump_raw_samples(tool, event, sample, machine); diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4a5eba498c02..9ba787406919 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1489,7 +1489,6 @@ static void set_timestamp_boundary(struct record *rec= , u64 sample_time) static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct record *rec =3D container_of(tool, struct record, tool); @@ -1500,7 +1499,7 @@ static int process_sample_event(const struct perf_too= l *tool, return 0; =20 rec->samples++; - return build_id__mark_dso_hit(tool, event, sample, evsel, machine); + return build_id__mark_dso_hit(tool, event, sample, machine); } =20 static int process_buildids(struct record *rec) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 95c0bdba6b11..848e2ccb1420 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -264,10 +264,10 @@ static int process_feature_event(const struct perf_to= ol *tool, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct report *rep =3D container_of(tool, struct report, tool); + struct evsel *evsel =3D sample->evsel; struct addr_location al; struct hist_entry_iter iter =3D { .evsel =3D evsel, @@ -344,7 +344,6 @@ static int process_sample_event(const struct perf_tool = *tool, static int process_read_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct report *rep =3D container_of(tool, struct report, tool); @@ -352,7 +351,7 @@ static int process_read_event(const struct perf_tool *t= ool, if (rep->show_threads) { int err =3D perf_read_values_add_value(&rep->show_threads_values, event->read.pid, event->read.tid, - evsel, + sample->evsel, event->read.value); =20 if (err) @@ -778,11 +777,10 @@ static void report__output_resort(struct report *rep) =20 static int count_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel, + struct perf_sample *sample, struct machine *machine __maybe_unused) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); =20 hists__inc_nr_events(hists); return 0; diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 555247568e7a..0713e6b28f92 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1867,9 +1867,9 @@ typedef int (*tracepoint_handler)(const struct perf_t= ool *tool, static int perf_sched__process_tracepoint_sample(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; =20 if (evsel->handler !=3D NULL) { @@ -3184,10 +3184,10 @@ typedef int (*sched_handler)(const struct perf_tool= *tool, static int perf_timehist__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct perf_cpu this_cpu =3D { .cpu =3D sample->cpu, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c8ac9f01a36b..3ffb8baf40f6 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2645,10 +2645,10 @@ static bool filter_cpu(struct perf_sample *sample) static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); + struct evsel *evsel =3D sample->evsel; struct addr_location al; struct addr_location addr_al; int ret =3D 0; @@ -2729,10 +2729,10 @@ static int process_sample_event(const struct perf_t= ool *tool, static int process_deferred_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); + struct evsel *evsel =3D sample->evsel; struct perf_event_attr *attr =3D &evsel->core.attr; struct evsel_script *es =3D evsel->priv; unsigned int type =3D output_type(attr->type); diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 28f33e39895d..8692d11ccd29 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -574,10 +574,10 @@ typedef int (*tracepoint_handler)(struct timechart *t= chart, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct timechart *tchart =3D container_of(tool, struct timechart, tool); + struct evsel *evsel =3D sample->evsel; =20 if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) { if (!tchart->first_time || tchart->first_time > sample->time) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e58c49d047a2..d9e80740e9ac 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3464,10 +3464,10 @@ static void trace__set_base_time(struct trace *trac= e, static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct trace *trace =3D container_of(tool, struct trace, tool); + struct evsel *evsel =3D sample->evsel; struct thread *thread; int err =3D 0; =20 diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index fdb35133fde4..55b72235f891 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -55,7 +55,6 @@ static int mark_dso_hit_callback(struct callchain_cursor_= node *node, void *data int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct addr_location al; @@ -74,7 +73,7 @@ int build_id__mark_dso_hit(const struct perf_tool *tool _= _maybe_unused, =20 addr_location__exit(&al); =20 - sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEP= TH, + sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, /*data=3D*/NULL); =20 =20 diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 47e621cebe1b..73bad90b06f9 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -34,12 +34,7 @@ char *__dso__build_id_filename(const struct dso *dso, ch= ar *bf, size_t size, bool is_debug, bool is_kallsyms); =20 int build_id__mark_dso_hit(const struct perf_tool *tool, union perf_event = *event, - struct perf_sample *sample, struct evsel *evsel, - struct machine *machine); - -int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, - struct perf_sample *sample, struct evsel *evsel, - struct machine *machine); + struct perf_sample *sample, struct machine *machine); =20 bool perf_session__read_build_ids(struct perf_session *session, bool with_= hits); int perf_session__write_buildid_table(struct perf_session *session, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 3b8f2df823a9..b3f745cff2a7 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -803,10 +803,10 @@ static bool is_flush_needed(struct ctf_stream *cs) static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct convert *c =3D container_of(tool, struct convert, tool); + struct evsel *evsel =3D sample->evsel; struct evsel_priv *priv =3D evsel->priv; struct ctf_writer *cw =3D &c->writer; struct ctf_stream *cs; diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index d526c91312ed..a7da93a7ff0e 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -159,13 +159,12 @@ static void output_sample_callchain_entry(const struc= t perf_tool *tool, static int process_sample_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel __maybe_unused, struct machine *machine) { struct convert_json *c =3D container_of(tool, struct convert_json, tool); FILE *out =3D c->out; struct addr_location al; - u64 sample_type =3D __evlist__combined_sample_type(evsel->evlist); + u64 sample_type =3D __evlist__combined_sample_type(sample->evsel->evlist); u8 cpumode =3D PERF_RECORD_MISC_USER; =20 addr_location__init(&al); @@ -245,7 +244,7 @@ static int process_sample_event(const struct perf_tool = *tool, =20 #ifdef HAVE_LIBTRACEEVENT if (sample->raw_data) { - struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_event *tp_format =3D evsel__tp_format(sample->evsel); struct tep_format_field **fields =3D tp_format ? tep_event_fields(tp_for= mat) : NULL; =20 if (fields) { diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c index 8b615dc94e9e..ed8cfe2ba2fa 100644 --- a/tools/perf/util/intel-tpebs.c +++ b/tools/perf/util/intel-tpebs.c @@ -185,7 +185,6 @@ static bool should_ignore_sample(const struct perf_samp= le *sample, const struct static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct tpebs_retire_lat *t; @@ -196,7 +195,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, mutex_unlock(tpebs_mtx_get()); return 0; } - t =3D tpebs_retire_lat__find(evsel); + t =3D tpebs_retire_lat__find(sample->evsel); if (!t) { mutex_unlock(tpebs_mtx_get()); return -EINVAL; diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index e0ce8b904729..52e6ffac2b3e 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -642,7 +642,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd= , union jr_entry *jr) =20 ret =3D jit_inject_event(jd, event); if (!ret) - build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); + build_id__mark_dso_hit(tool, event, &sample, jd->machine); out: perf_sample__exit(&sample); return ret; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index fe0de2a0277f..1e25892963b7 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1117,9 +1117,10 @@ char *get_page_size_name(u64 size, char *str) return str; } =20 -static void dump_sample(struct machine *machine, struct evsel *evsel, unio= n perf_event *event, +static void dump_sample(struct machine *machine, union perf_event *event, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; u64 sample_type; char str[PAGE_SIZE_NAME_LEN]; uint16_t e_machine =3D EM_NONE; @@ -1183,9 +1184,10 @@ static void dump_sample(struct machine *machine, str= uct evsel *evsel, union perf sample_read__printf(sample, evsel->core.attr.read_format); } =20 -static void dump_deferred_callchain(struct evsel *evsel, union perf_event = *event, - struct perf_sample *sample) +static void dump_deferred_callchain(union perf_event *event, struct perf_s= ample *sample) { + struct evsel *evsel =3D sample->evsel; + if (!dump_trace) return; =20 @@ -1291,7 +1293,7 @@ static int deliver_sample_value(struct evlist *evlist, return 0; =20 sample->evsel =3D container_of(sid->evsel, struct evsel, core); - ret =3D tool->sample(tool, event, sample, sample->evsel, machine); + ret =3D tool->sample(tool, event, sample, machine); sample->evsel =3D saved_evsel; return ret; } @@ -1323,8 +1325,9 @@ static int deliver_sample_group(struct evlist *evlist, =20 static int evlist__deliver_sample(struct evlist *evlist, const struct perf= _tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) + struct machine *machine) { + struct evsel *evsel =3D sample->evsel; /* We know evsel !=3D NULL. */ u64 sample_type =3D evsel->core.attr.sample_type; u64 read_format =3D evsel->core.attr.read_format; @@ -1332,7 +1335,7 @@ static int evlist__deliver_sample(struct evlist *evli= st, const struct perf_tool =20 /* Standard sample delivery. */ if (!(sample_type & PERF_SAMPLE_READ)) - return tool->sample(tool, event, sample, evsel, machine); + return tool->sample(tool, event, sample, machine); =20 /* For PERF_SAMPLE_READ we have either single or group mode. */ if (read_format & PERF_FORMAT_GROUP) @@ -1371,8 +1374,7 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, struct evsel *saved_evsel =3D sample->evsel; =20 sample->evsel =3D evlist__id2evsel(evlist, sample->id); - ret =3D tool->callchain_deferred(tool, event, sample, - sample->evsel, machine); + ret =3D tool->callchain_deferred(tool, event, sample, machine); sample->evsel =3D saved_evsel; return ret; } @@ -1400,7 +1402,7 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, =20 orig_sample.evsel =3D evlist__id2evsel(evlist, orig_sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &orig_sample, orig_sample.evsel, machine); + &orig_sample, machine); =20 perf_sample__exit(&orig_sample); list_del(&de->list); @@ -1438,7 +1440,7 @@ static int session__flush_deferred_samples(struct per= f_session *session, =20 sample.evsel =3D evlist__id2evsel(evlist, sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &sample, sample.evsel, machine); + &sample, machine); =20 perf_sample__exit(&sample); list_del(&de->list); @@ -1458,7 +1460,6 @@ static int machines__deliver_event(struct machines *m= achines, const struct perf_tool *tool, u64 file_offset, const char *file_path) { - struct evsel *evsel; struct machine *machine; =20 dump_event(evlist, event, file_offset, sample, file_path); @@ -1468,21 +1469,20 @@ static int machines__deliver_event(struct machines = *machines, else assert(sample->evsel =3D=3D evlist__id2evsel(evlist, sample->id)); =20 - evsel =3D sample->evsel; machine =3D machines__find_for_cpumode(machines, event, sample); =20 switch (event->header.type) { case PERF_RECORD_SAMPLE: - if (evsel =3D=3D NULL) { + if (sample->evsel =3D=3D NULL) { ++evlist->stats.nr_unknown_id; return 0; } if (machine =3D=3D NULL) { ++evlist->stats.nr_unprocessable_samples; - dump_sample(machine, evsel, event, sample); + dump_sample(machine, event, sample); return 0; } - dump_sample(machine, evsel, event, sample); + dump_sample(machine, event, sample); if (sample->deferred_callchain && tool->merge_deferred_callchains) { struct deferred_event *de =3D malloc(sizeof(*de)); size_t sz =3D event->header.size; @@ -1499,7 +1499,7 @@ static int machines__deliver_event(struct machines *m= achines, list_add_tail(&de->list, &evlist->deferred_samples); return 0; } - return evlist__deliver_sample(evlist, tool, event, sample, evsel, machin= e); + return evlist__deliver_sample(evlist, tool, event, sample, machine); case PERF_RECORD_MMAP: return tool->mmap(tool, event, sample, machine); case PERF_RECORD_MMAP2: @@ -1527,8 +1527,8 @@ static int machines__deliver_event(struct machines *m= achines, evlist->stats.total_lost_samples +=3D event->lost_samples.lost; return tool->lost_samples(tool, event, sample, machine); case PERF_RECORD_READ: - dump_read(evsel, event); - return tool->read(tool, event, sample, evsel, machine); + dump_read(sample->evsel, event); + return tool->read(tool, event, sample, machine); case PERF_RECORD_THROTTLE: return tool->throttle(tool, event, sample, machine); case PERF_RECORD_UNTHROTTLE: @@ -1557,7 +1557,7 @@ static int machines__deliver_event(struct machines *m= achines, case PERF_RECORD_AUX_OUTPUT_HW_ID: return tool->aux_output_hw_id(tool, event, sample, machine); case PERF_RECORD_CALLCHAIN_DEFERRED: - dump_deferred_callchain(evsel, event, sample); + dump_deferred_callchain(event, sample); return evlist__deliver_deferred_callchain(evlist, tool, event, sample, machine); default: diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 013c7839e2cf..0f285a2574c8 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -110,7 +110,6 @@ static int process_event_synth_event_update_stub(const = struct perf_tool *tool __ int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, struct machine *machine __maybe_unused) { dump_printf(": unhandled!\n"); @@ -348,12 +347,11 @@ bool perf_tool__compressed_is_stub(const struct perf_= tool *tool) static int delegate_ ## name(const struct perf_tool *tool, \ union perf_event *event, \ struct perf_sample *sample, \ - struct evsel *evsel, \ struct machine *machine) \ { \ struct delegate_tool *del_tool =3D container_of(tool, struct delegate_to= ol, tool); \ struct perf_tool *delegate =3D del_tool->delegate; \ - return delegate->name(delegate, event, sample, evsel, machine); \ + return delegate->name(delegate, event, sample, machine); \ } CREATE_DELEGATE_SAMPLE(read); CREATE_DELEGATE_SAMPLE(sample); diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 2d9a4b1ca9d0..2a4f124ffd8d 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -9,7 +9,6 @@ struct perf_session; union perf_event; struct evlist; -struct evsel; struct perf_sample; struct perf_tool; struct machine; @@ -17,7 +16,7 @@ struct ordered_events; =20 typedef int (*event_sample)(const struct perf_tool *tool, union perf_event= *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine); + struct machine *machine); =20 typedef int (*event_op)(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample, struct machine *machine); @@ -103,7 +102,6 @@ bool perf_tool__compressed_is_stub(const struct perf_to= ol *tool); int process_event_sample_stub(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine); =20 struct delegate_tool { --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 26A6F1E32A2 for ; Mon, 13 Apr 2026 01:22:38 +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=1776043359; cv=none; b=nuc2zxv/2zAJlKFvCodoNW4LEhP05LA7D79eU+P4PsGxdDidivYgdEo16K89LViJ2PReueJeX4Bn9IRv/hlSw1IBKgZJeKUsVRdxX00iOJ+3aYq9Q14yTuikvPmNHDhSuaqG8aQXH/7FhFpHaEHiqAr4msX8zE54qV4AMewb4d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043359; c=relaxed/simple; bh=o+Xes5abuH+yASF/5nAM10kbXFW/dLHGpz6yw+ZAltA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SFQBN91hr3vWvr8JySpCUibMB1KEJmEJkXNdYG6kc4vPHdNoMSAqjPZGFtgE1btBFmLJs8vUSCscnDARcoKqYBflORkgbXxQf63HKj/826PwJWFQi1dr7CbyaN5lWVid4414jF+nf5uFuH7Je2H4YTww8pUJRcfq6WfpejbVqcw= 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=MJ6l/L06; 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="MJ6l/L06" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2d889997495so2294672eec.0 for ; Sun, 12 Apr 2026 18:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043357; x=1776648157; 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=oannBQ3qlAZji2iUnnBApQPMVduJ0gSlFJ8k8/hJ3qM=; b=MJ6l/L060+A8iRkepZ4yREaPjzxJPrGBUjSWey/iZMB1FIa320EduCdghHa1YdlKcP EZEHoLUqoeGgsh3z1DBI8RnqnVPsmDZvaDd7AYx4NN0wP7uXSV48wA6e8IcxTylWHyC4 auXzDw7P8AoQ4fxSsa9qtnGmw4eqM20gcpuZqVmAAy5EHRPR2B43YpELuHz0VP0qSGV/ iMDC/JOnPZTqOGB5+jAVrx3jODZ8HBuDGOIXi7UkaPMXxKIinMFpFm9YhyqT2q/nfEHi M5K5kLkT0F8USwgi+mVcd9gcondE2Qel2U15ESTEoNkVITjTRI50Ecknff17vMIYI6/D TUpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043357; x=1776648157; 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=oannBQ3qlAZji2iUnnBApQPMVduJ0gSlFJ8k8/hJ3qM=; b=TyThjOJ3gowUebQLYwqtirwyQRNcG38c0Xv7itpC9z0ngFK+DhJecsd1h8iXfg3Xod JbITtEy5vZXZ2FQzdf6tf0lJ+5L2c6l0kZQFwuM61IBgnd9xJfcmDO66A5WARKdftLk9 aSAnUUQ2beoMXkQHCbKlkCbrV+yMgPamRcpOkjKtyt5gQIzYO5z0p1kWZWh+EDsxRapj GR8yaQ3LP8EkhR5DL21zv+C9hLMJ0pNHNUD2hHOP4l+FDrn1UFWxcOWF3MwTf/MVasIc eF9J+v2g9s2K+MAgGGO4MTU5akUEUrt1jAU9Uq+WwGUR+7u+jes3mdqI7Fh4RG1LAiGM HPug== X-Forwarded-Encrypted: i=1; AFNElJ+Br7zKMOAwzzmxQoKdS7sMyFhbTBoHkQIcNtMlHtYMyBFMXQgeCp9VMSOi+uwyrBaXdxXPsu6UUDFunJE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2UrG6B1zNc6tF5c9spxm+f+NPZlBxGxkI5jeX/y6ULto40GGj JtzgoHGfAdiOpGcdApzVl68Zgn6MH5QJUhFkWrGXJ8qDceLVhzNWpPPcnQgjDt37XCAAuH4sB2N YENGkyTq2MQ== X-Received: from dybnj45.prod.google.com ([2002:a05:7300:d0ad:b0:2d7:b2e8:13fc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:d021:b0:2c5:b23e:48a9 with SMTP id 5a478bee46e88-2d588c8dec7mr6927094eec.25.1776043357126; Sun, 12 Apr 2026 18:22:37 -0700 (PDT) Date: Sun, 12 Apr 2026 18:21:57 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-4-irogers@google.com> Subject: [PATCH v11 03/33] perf kvm: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" As the sample now contains the evsel, read the evsel from the sample rather than passing them as a pair. Signed-off-by: Ian Rogers --- tools/perf/builtin-kvm.c | 19 +++-- .../perf/util/kvm-stat-arch/kvm-stat-arm64.c | 17 +++-- .../util/kvm-stat-arch/kvm-stat-loongarch.c | 17 ++--- .../util/kvm-stat-arch/kvm-stat-powerpc.c | 17 ++--- .../perf/util/kvm-stat-arch/kvm-stat-riscv.c | 18 +++-- tools/perf/util/kvm-stat-arch/kvm-stat-s390.c | 20 +++--- tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 70 ++++++++----------- tools/perf/util/kvm-stat.c | 19 +++-- tools/perf/util/kvm-stat.h | 18 ++--- 9 files changed, 89 insertions(+), 126 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 5e8e6fde097a..d9b9792894a8 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -806,7 +806,6 @@ static bool update_kvm_event(struct perf_kvm_stat *kvm, } =20 static bool is_child_event(struct perf_kvm_stat *kvm, - struct evsel *evsel, struct perf_sample *sample, struct event_key *key) { @@ -818,8 +817,8 @@ static bool is_child_event(struct perf_kvm_stat *kvm, return false; =20 for (; child_ops->name; child_ops++) { - if (evsel__name_is(evsel, child_ops->name)) { - child_ops->get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, child_ops->name)) { + child_ops->get_key(sample, key); return true; } } @@ -917,11 +916,10 @@ static bool handle_end_event(struct perf_kvm_stat *kv= m, =20 static struct vcpu_event_record *per_vcpu_record(struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { /* Only kvm_entry records vcpu id. */ - if (!thread__priv(thread) && kvm_entry_event(evsel)) { + if (!thread__priv(thread) && kvm_entry_event(sample->evsel)) { struct vcpu_event_record *vcpu_record; struct machine *machine =3D maps__machine(thread__maps(thread)); uint16_t e_machine =3D thread__e_machine(thread, machine, /*e_flags=3D*/= NULL); @@ -932,7 +930,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, return NULL; } =20 - vcpu_record->vcpu_id =3D evsel__intval(evsel, sample, vcpu_id_str(e_mach= ine)); + vcpu_record->vcpu_id =3D evsel__intval(sample->evsel, sample, vcpu_id_st= r(e_machine)); thread__set_priv(thread, vcpu_record); } =20 @@ -943,12 +941,11 @@ static bool handle_kvm_event(struct perf_kvm_stat *kv= m, struct thread *thread, struct perf_sample *sample) { - struct evsel *evsel =3D sample->evsel; struct vcpu_event_record *vcpu_record; struct event_key key =3D { .key =3D INVALID_KEY, .exit_reasons =3D kvm->exit_reasons }; =20 - vcpu_record =3D per_vcpu_record(thread, evsel, sample); + vcpu_record =3D per_vcpu_record(thread, sample); if (!vcpu_record) return true; =20 @@ -957,13 +954,13 @@ static bool handle_kvm_event(struct perf_kvm_stat *kv= m, (kvm->trace_vcpu !=3D vcpu_record->vcpu_id)) return true; =20 - if (kvm->events_ops->is_begin_event(evsel, sample, &key)) + if (kvm->events_ops->is_begin_event(sample, &key)) return handle_begin_event(kvm, vcpu_record, &key, sample); =20 - if (is_child_event(kvm, evsel, sample, &key)) + if (is_child_event(kvm, sample, &key)) return handle_child_event(kvm, vcpu_record, &key, sample); =20 - if (kvm->events_ops->is_end_event(evsel, sample, &key)) + if (kvm->events_ops->is_end_event(sample, &key)) return handle_end_event(kvm, vcpu_record, &key, sample); =20 return true; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-arm64.c index c640dcd8af7c..1e76906f719c 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c @@ -17,10 +17,11 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static void event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_get_key(struct perf_sample *sample, struct event_key *key) { + struct evsel *evsel =3D sample->evsel; + key->info =3D 0; key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_AARCH64)); key->exit_reasons =3D arm64_exit_reasons; @@ -36,19 +37,17 @@ static void event_get_key(struct evsel *evsel, } } =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_begin(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, kvm_entry_trace(EM_AARCH64)); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_AARCH64)); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample, +static bool event_end(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, kvm_exit_trace(EM_AARCH64))) { - event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, kvm_exit_trace(EM_AARCH64))) { + event_get_key(sample, key); return true; } return false; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c b/tools/per= f/util/kvm-stat-arch/kvm-stat-loongarch.c index b802e516b138..9d6265290f6d 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c @@ -53,14 +53,12 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool event_begin(struct perf_sample *sample, struct event_key *key) { - return exit_event_begin(evsel, sample, key); + return exit_event_begin(sample, key); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { /* @@ -71,17 +69,16 @@ static bool event_end(struct evsel *evsel, * kvm:kvm_enter means returning to vmm and then to guest * kvm:kvm_reenter means returning to guest immediately */ - return evsel__name_is(evsel, kvm_entry_trace(EM_LOONGARCH)) || - evsel__name_is(evsel, kvm_reenter_trace); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_LOONGARCH)) || + evsel__name_is(sample->evsel, kvm_reenter_trace); } =20 -static void event_gspr_get_key(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static void event_gspr_get_key(struct perf_sample *sample, struct event_ke= y *key) { unsigned int insn; =20 key->key =3D LOONGARCH_EXCEPTION_OTHERS; - insn =3D evsel__intval(evsel, sample, "inst_word"); + insn =3D evsel__intval(sample->evsel, sample, "inst_word"); =20 switch (insn >> 24) { case 0: diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c b/tools/perf/= util/kvm-stat-arch/kvm-stat-powerpc.c index 42182d70beb6..5158d7e88ee6 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c @@ -28,12 +28,11 @@ static const char * const ppc_book3s_hv_kvm_tp[] =3D { /* 1 extra placeholder for NULL */ static const char *__kvm_events_tp[NR_TPS + 1]; =20 -static void hcall_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void hcall_event_get_key(struct perf_sample *sample, struct event_key *key) { key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, "req"); + key->key =3D evsel__intval(sample->evsel, sample, "req"); } =20 static const char *get_hcall_exit_reason(u64 exit_code) @@ -51,18 +50,16 @@ static const char *get_hcall_exit_reason(u64 exit_code) return "UNKNOWN"; } =20 -static bool hcall_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool hcall_event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, __kvm_events_tp[3]); + return evsel__name_is(sample->evsel, __kvm_events_tp[3]); } =20 -static bool hcall_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool hcall_event_begin(struct perf_sample *sample, struct event_key= *key) { - if (evsel__name_is(evsel, __kvm_events_tp[2])) { - hcall_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, __kvm_events_tp[2])) { + hcall_event_get_key(sample, key); return true; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-riscv.c index 8d4d5d6ce720..e8db8b4f8e2e 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c @@ -20,30 +20,28 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static void event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_get_key(struct perf_sample *sample, struct event_key *key) { int xlen =3D 64; // TODO: 32-bit support. =20 key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_RISCV)) & ~C= AUSE_IRQ_FLAG(xlen); + key->key =3D evsel__intval(sample->evsel, sample, + kvm_exit_reason(EM_RISCV)) & ~CAUSE_IRQ_FLAG(xlen); key->exit_reasons =3D riscv_exit_reasons; } =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_begin(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, kvm_entry_trace(EM_RISCV)); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_RISCV)); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample, +static bool event_end(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, kvm_exit_trace(EM_RISCV))) { - event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, kvm_exit_trace(EM_RISCV))) { + event_get_key(sample, key); return true; } return false; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c b/tools/perf/uti= l/kvm-stat-arch/kvm-stat-s390.c index 7e29169f5bb0..158372ba0205 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c @@ -18,38 +18,34 @@ define_exit_reasons_table(sie_sigp_order_codes, sigp_or= der_codes); define_exit_reasons_table(sie_diagnose_codes, diagnose_codes); define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes); =20 -static void event_icpt_insn_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_icpt_insn_get_key(struct perf_sample *sample, struct event_key *key) { u64 insn; =20 - insn =3D evsel__intval(evsel, sample, "instruction"); + insn =3D evsel__intval(sample->evsel, sample, "instruction"); key->key =3D icpt_insn_decoder(insn); key->exit_reasons =3D sie_icpt_insn_codes; } =20 -static void event_sigp_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_sigp_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "order_code"); + key->key =3D evsel__intval(sample->evsel, sample, "order_code"); key->exit_reasons =3D sie_sigp_order_codes; } =20 -static void event_diag_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_diag_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "code"); + key->key =3D evsel__intval(sample->evsel, sample, "code"); key->exit_reasons =3D sie_diagnose_codes; } =20 -static void event_icpt_prog_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_icpt_prog_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "code"); + key->key =3D evsel__intval(sample->evsel, sample, "code"); key->exit_reasons =3D sie_icpt_prog_codes; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util= /kvm-stat-arch/kvm-stat-x86.c index 0f626db3a439..0ce543d82850 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c @@ -24,45 +24,43 @@ static const struct kvm_events_ops exit_events =3D { * the time of MMIO write: kvm_mmio(KVM_TRACE_MMIO_WRITE...) -> kvm_entry * the time of MMIO read: kvm_exit -> kvm_mmio(KVM_TRACE_MMIO_READ...). */ -static void mmio_event_get_key(struct evsel *evsel, struct perf_sample *sa= mple, +static void mmio_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "gpa"); - key->info =3D evsel__intval(evsel, sample, "type"); + key->key =3D evsel__intval(sample->evsel, sample, "gpa"); + key->info =3D evsel__intval(sample->evsel, sample, "type"); } =20 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 #define KVM_TRACE_MMIO_READ 1 #define KVM_TRACE_MMIO_WRITE 2 =20 -static bool mmio_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool mmio_event_begin(struct perf_sample *sample, struct event_key = *key) { /* MMIO read begin event in kernel. */ - if (kvm_exit_event(evsel)) + if (kvm_exit_event(sample->evsel)) return true; =20 /* MMIO write begin event in kernel. */ - if (evsel__name_is(evsel, "kvm:kvm_mmio") && - evsel__intval(evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WRITE) { - mmio_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && + evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WR= ITE) { + mmio_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool mmio_event_end(struct evsel *evsel, struct perf_sample *sample, - struct event_key *key) +static bool mmio_event_end(struct perf_sample *sample, struct event_key *k= ey) { /* MMIO write end event in kernel. */ - if (kvm_entry_event(evsel)) + if (kvm_entry_event(sample->evsel)) return true; =20 /* MMIO read end event in kernel.*/ - if (evsel__name_is(evsel, "kvm:kvm_mmio") && - evsel__intval(evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_READ) { - mmio_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && + evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_RE= AD) { + mmio_event_get_key(sample, key); return true; } =20 @@ -86,31 +84,27 @@ static const struct kvm_events_ops mmio_events =3D { }; =20 /* The time of emulation pio access is from kvm_pio to kvm_entry. */ -static void ioport_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void ioport_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "port"); - key->info =3D evsel__intval(evsel, sample, "rw"); + key->key =3D evsel__intval(sample->evsel, sample, "port"); + key->info =3D evsel__intval(sample->evsel, sample, "rw"); } =20 -static bool ioport_event_begin(struct evsel *evsel, - struct perf_sample *sample, +static bool ioport_event_begin(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, "kvm:kvm_pio")) { - ioport_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_pio")) { + ioport_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool ioport_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, - struct event_key *key __maybe_unused) +static bool ioport_event_end(struct perf_sample *sample, struct event_key = *key __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unus= ed, @@ -130,31 +124,25 @@ static const struct kvm_events_ops ioport_events =3D { }; =20 /* The time of emulation msr is from kvm_msr to kvm_entry. */ -static void msr_event_get_key(struct evsel *evsel, - struct perf_sample *sample, - struct event_key *key) +static void msr_event_get_key(struct perf_sample *sample, struct event_key= *key) { - key->key =3D evsel__intval(evsel, sample, "ecx"); - key->info =3D evsel__intval(evsel, sample, "write"); + key->key =3D evsel__intval(sample->evsel, sample, "ecx"); + key->info =3D evsel__intval(sample->evsel, sample, "write"); } =20 -static bool msr_event_begin(struct evsel *evsel, - struct perf_sample *sample, - struct event_key *key) +static bool msr_event_begin(struct perf_sample *sample, struct event_key *= key) { - if (evsel__name_is(evsel, "kvm:kvm_msr")) { - msr_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_msr")) { + msr_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool msr_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, - struct event_key *key __maybe_unused) +static bool msr_event_end(struct perf_sample *sample, struct event_key *ke= y __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static void msr_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, diff --git a/tools/perf/util/kvm-stat.c b/tools/perf/util/kvm-stat.c index 27f16810498c..f17a6132958d 100644 --- a/tools/perf/util/kvm-stat.c +++ b/tools/perf/util/kvm-stat.c @@ -11,22 +11,20 @@ bool kvm_exit_event(struct evsel *evsel) return evsel__name_is(evsel, kvm_exit_trace(e_machine)); } =20 -void exit_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +void exit_event_get_key(struct perf_sample *sample, struct event_key *key) { - uint16_t e_machine =3D evsel__e_machine(evsel, /*e_flags=3D*/NULL); + uint16_t e_machine =3D evsel__e_machine(sample->evsel, /*e_flags=3D*/NULL= ); =20 key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(e_machine)); + key->key =3D evsel__intval(sample->evsel, sample, kvm_exit_reason(e_mach= ine)); } =20 =20 -bool exit_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +bool exit_event_begin(struct perf_sample *sample, struct event_key *key) { - if (kvm_exit_event(evsel)) { - exit_event_get_key(evsel, sample, key); + if (kvm_exit_event(sample->evsel)) { + exit_event_get_key(sample, key); return true; } =20 @@ -40,11 +38,10 @@ bool kvm_entry_event(struct evsel *evsel) return evsel__name_is(evsel, kvm_entry_trace(e_machine)); } =20 -bool exit_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +bool exit_event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static const char *get_exit_reason(struct perf_kvm_stat *kvm, diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index 4a998aaece5d..cdbd921a555f 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -53,18 +53,15 @@ struct kvm_event { }; =20 struct child_event_ops { - void (*get_key)(struct evsel *evsel, - struct perf_sample *sample, + void (*get_key)(struct perf_sample *sample, struct event_key *key); const char *name; }; =20 struct kvm_events_ops { - bool (*is_begin_event)(struct evsel *evsel, - struct perf_sample *sample, + bool (*is_begin_event)(struct perf_sample *sample, struct event_key *key); - bool (*is_end_event)(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key); + bool (*is_end_event)(struct perf_sample *sample, struct event_key *key); const struct child_event_ops *child_ops; void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key, char *decode); @@ -116,14 +113,11 @@ struct kvm_reg_events_ops { =20 #ifdef HAVE_LIBTRACEEVENT =20 -void exit_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +void exit_event_get_key(struct perf_sample *sample, struct event_key *key); -bool exit_event_begin(struct evsel *evsel, - struct perf_sample *sample, +bool exit_event_begin(struct perf_sample *sample, struct event_key *key); -bool exit_event_end(struct evsel *evsel, - struct perf_sample *sample, +bool exit_event_end(struct perf_sample *sample, struct event_key *key); void exit_event_decode_key(struct perf_kvm_stat *kvm, struct event_key *key, --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 40E9E1DF248 for ; Mon, 13 Apr 2026 01:22:40 +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=1776043364; cv=none; b=I8x8+FBGNwldeIg1wQJT3z9C/0ag9X2AwqT8wLcudbtcjTQDszjwxJVl3sggYj9jDxuNq2ssU8RvnGEcdzLLHml2ajvalseiMISnnok9BjoBUltOZXDrKlSluTfGgi2C9bfB4/j7jsxdDg5vJgUasGBTeb9yMaDCmIpR+SQ9pk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043364; c=relaxed/simple; bh=xlvDgKu5oQ3XMYIc7ynAse8vT3c42v9R50LgmHzKztk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=h46P6vJZhkXJpMgsqOgFVfAUXdzRi70HKAInB+T3a6sPV6ZSKK8bEcyLNEkink6LmFt+XYrje5j5lHeIm0GmcEyTj3P8Pguaqks+s77pr0OaV+ULFlweZyYqKj4pJShNPKDT4+LlWo2eZ4VBIUIhCx6r8oykeU5wHiwS1uvyy7o= 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=vTWLeabi; 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="vTWLeabi" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d3a617ad90so11812840eec.0 for ; Sun, 12 Apr 2026 18:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043359; x=1776648159; 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=Tn94NKCDiQpzYhFgSogEtvNyA41dEuw7vaQIN1UluNg=; b=vTWLeabiR4/NK7HRIaTjabl1NJeFWw33FSTP6Lyn0QZl0sa7bjHdLIaqmk7cOyNN2o M7wIs0n9Dw5Z+ZvB/hqiitxGWUXPJ+p6YrNL06fG6JVmJ9InuPV+7o9PZ+MfB+IYiqOq TZn45KnwQ1CUTm4ydEyX90edJ4D38Pj2kT/T5X4ISwWy7Zu7WEdjrG2gbNYRIfIYY1oE NgwxsQRhuZfMMyIJiF/S1T0ny4Ufdn+pq22DXmeNIgaVW15oTpTsBpgjaRTwnP00Rd9t e8tVYS0aAS5Sc47XwFTux6DFupvmAWyangMAoJ7VwisTS4/I/4npvItKoi8LepefmFEr 08Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043359; x=1776648159; 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=Tn94NKCDiQpzYhFgSogEtvNyA41dEuw7vaQIN1UluNg=; b=nFYqMyAXRf3UiS5YaqNAPbP+U7quIVs2Azc4f3E0PEWqsw+RHjS/tUHWtFuB+q9qI+ wY/bIugRiHxPCS1h2ypntIaQNMz0NhG0/UeSvygDf2b6dPHt9ZonrDzyKsn+GHahuiag gS5MzomNVVS+RlwHW42o+xfv891b8DBEUPb902V6Um21sygSAfL+lb7gEwgAvva0Khn8 CqBVDMjQ2JImzMHYiDLh2jDQJZOBk8WZTA+G21cRewDTZScRjr8M8EB/0afX30MIy4WH P7A+rS9jR4QszGxiLfjtHy3V+xRgehuwMZjXrB/+RZXcr1S0akhhWpBn+5Ubah6Z6B2O M9mw== X-Forwarded-Encrypted: i=1; AFNElJ+Uqj7Eyokm7tt2qskncixnvUzzaKRllVwEEYsteEF1va2oDg155wYxoUnhDuNfmbELX2IPP8eZXamF87I=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu7AhY18kEqx96XByMLSqJmWLhvBPIKZ+s8L5TmwQPLSKLkW8J V3MJbFHmqy5YpuVEHrn69+14lYI/8+T/SuPxmgSuHvvomxXwzS7gXTHNCwI2v+E4BkJQf5lW9EX SaP2kLDuySw== X-Received: from dyaw3-n1.prod.google.com ([2002:a05:693c:4143:10b0:2c5:2b09:16ef]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:a14c:b0:2d9:fa9c:87a9 with SMTP id 5a478bee46e88-2d9fa9ca829mr72138eec.5.1776043359173; Sun, 12 Apr 2026 18:22:39 -0700 (PDT) Date: Sun, 12 Apr 2026 18:21:58 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-5-irogers@google.com> Subject: [PATCH v11 04/33] perf evsel: Refactor evsel tracepoint sample accessors perf_sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 evsel argument to evsel__intval, evsel__rawptr, and similar functions, is unnecessary as it can be read from the sample. Remove the evsel and rename the function to match that the data is coming from the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-kmem.c | 34 +++---- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-kwork.c | 29 +++--- tools/perf/builtin-lock.c | 32 +++---- tools/perf/builtin-sched.c | 92 +++++++++---------- tools/perf/builtin-timechart.c | 88 +++++++++--------- tools/perf/builtin-trace.c | 12 +-- tools/perf/tests/openat-syscall-tp-fields.c | 2 +- tools/perf/tests/switch-tracking.c | 4 +- tools/perf/util/evsel.c | 22 ++--- tools/perf/util/evsel.h | 12 +-- tools/perf/util/intel-pt.c | 2 +- .../perf/util/kvm-stat-arch/kvm-stat-arm64.c | 6 +- .../util/kvm-stat-arch/kvm-stat-loongarch.c | 2 +- .../util/kvm-stat-arch/kvm-stat-powerpc.c | 2 +- .../perf/util/kvm-stat-arch/kvm-stat-riscv.c | 3 +- tools/perf/util/kvm-stat-arch/kvm-stat-s390.c | 8 +- tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 16 ++-- tools/perf/util/kvm-stat.c | 2 +- 20 files changed, 183 insertions(+), 189 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 6ba489452777..3d3f3272918c 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -1081,7 +1081,7 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, union perf_event *event_sw; struct perf_sample sample_sw; struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); - u32 pid =3D evsel__intval(evsel, sample, "pid"); + u32 pid =3D perf_sample__intval(sample, "pid"); int ret; =20 list_for_each_entry(ent, &inject->samples, node) { diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 45b383fa9ce9..d7233a8b43be 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -173,10 +173,10 @@ static int insert_caller_stat(unsigned long call_site, =20 static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sam= ple *sample) { - unsigned long ptr =3D evsel__intval(evsel, sample, "ptr"), - call_site =3D evsel__intval(evsel, sample, "call_site"); - int bytes_req =3D evsel__intval(evsel, sample, "bytes_req"), - bytes_alloc =3D evsel__intval(evsel, sample, "bytes_alloc"); + unsigned long ptr =3D perf_sample__intval(sample, "ptr"), + call_site =3D perf_sample__intval(sample, "call_site"); + int bytes_req =3D perf_sample__intval(sample, "bytes_req"), + bytes_alloc =3D perf_sample__intval(sample, "bytes_alloc"); =20 if (insert_alloc_stat(call_site, ptr, bytes_req, bytes_alloc, sample->cpu= ) || insert_caller_stat(call_site, bytes_req, bytes_alloc)) @@ -202,7 +202,7 @@ static int evsel__process_alloc_event(struct evsel *evs= el, struct perf_sample *s int node1, node2; =20 node1 =3D cpu__get_node((struct perf_cpu){.cpu =3D sample->cpu}); - node2 =3D evsel__intval(evsel, sample, "node"); + node2 =3D perf_sample__intval(sample, "node"); =20 /* * If the field "node" is NUMA_NO_NODE (-1), we don't take it @@ -243,9 +243,9 @@ static struct alloc_stat *search_alloc_stat(unsigned lo= ng ptr, return NULL; } =20 -static int evsel__process_free_event(struct evsel *evsel, struct perf_samp= le *sample) +static int evsel__process_free_event(struct evsel *evsel __maybe_unused, s= truct perf_sample *sample) { - unsigned long ptr =3D evsel__intval(evsel, sample, "ptr"); + unsigned long ptr =3D perf_sample__intval(sample, "ptr"); struct alloc_stat *s_alloc, *s_caller; =20 s_alloc =3D search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); @@ -808,10 +808,9 @@ static int parse_gfp_flags(struct evsel *evsel, struct= perf_sample *sample, static int evsel__process_page_alloc_event(struct evsel *evsel, struct per= f_sample *sample) { u64 page; - unsigned int order =3D evsel__intval(evsel, sample, "order"); - unsigned int gfp_flags =3D evsel__intval(evsel, sample, "gfp_flags"); - unsigned int migrate_type =3D evsel__intval(evsel, sample, - "migratetype"); + unsigned int order =3D perf_sample__intval(sample, "order"); + unsigned int gfp_flags =3D perf_sample__intval(sample, "gfp_flags"); + unsigned int migrate_type =3D perf_sample__intval(sample, "migratetype"); u64 bytes =3D kmem_page_size << order; u64 callsite; struct page_stat *pstat; @@ -822,9 +821,9 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp }; =20 if (use_pfn) - page =3D evsel__intval(evsel, sample, "pfn"); + page =3D perf_sample__intval(sample, "pfn"); else - page =3D evsel__intval(evsel, sample, "page"); + page =3D perf_sample__intval(sample, "page"); =20 nr_page_allocs++; total_page_alloc_bytes +=3D bytes; @@ -877,10 +876,11 @@ static int evsel__process_page_alloc_event(struct evs= el *evsel, struct perf_samp return 0; } =20 -static int evsel__process_page_free_event(struct evsel *evsel, struct perf= _sample *sample) +static int evsel__process_page_free_event(struct evsel *evsel __maybe_unus= ed, + struct perf_sample *sample) { u64 page; - unsigned int order =3D evsel__intval(evsel, sample, "order"); + unsigned int order =3D perf_sample__intval(sample, "order"); u64 bytes =3D kmem_page_size << order; struct page_stat *pstat; struct page_stat this =3D { @@ -888,9 +888,9 @@ static int evsel__process_page_free_event(struct evsel = *evsel, struct perf_sampl }; =20 if (use_pfn) - page =3D evsel__intval(evsel, sample, "pfn"); + page =3D perf_sample__intval(sample, "pfn"); else - page =3D evsel__intval(evsel, sample, "page"); + page =3D perf_sample__intval(sample, "page"); =20 nr_page_frees++; total_page_free_bytes +=3D bytes; diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index d9b9792894a8..dd2ed21596aa 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -930,7 +930,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, return NULL; } =20 - vcpu_record->vcpu_id =3D evsel__intval(sample->evsel, sample, vcpu_id_st= r(e_machine)); + vcpu_record->vcpu_id =3D perf_sample__intval(sample, vcpu_id_str(e_machi= ne)); thread__set_priv(thread, vcpu_record); } =20 diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index d4bb19ed91b5..ab4519287f47 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1006,7 +1006,7 @@ static void irq_work_init(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1014,11 +1014,11 @@ static void irq_work_init(struct perf_kwork *kwork, work->cpu =3D sample->cpu; =20 if (kwork->report =3D=3D KWORK_REPORT_TOP) { - work->id =3D evsel__intval_common(evsel, sample, "common_pid"); + work->id =3D perf_sample__intval_common(sample, "common_pid"); work->name =3D NULL; } else { - work->id =3D evsel__intval(evsel, sample, "irq"); - work->name =3D evsel__strval(evsel, sample, "name"); + work->id =3D perf_sample__intval(sample, "irq"); + work->name =3D perf_sample__strval(sample, "name"); } } =20 @@ -1144,10 +1144,10 @@ static void softirq_work_init(struct perf_kwork *kw= ork, work->cpu =3D sample->cpu; =20 if (kwork->report =3D=3D KWORK_REPORT_TOP) { - work->id =3D evsel__intval_common(evsel, sample, "common_pid"); + work->id =3D perf_sample__intval_common(sample, "common_pid"); work->name =3D NULL; } else { - num =3D evsel__intval(evsel, sample, "vec"); + num =3D perf_sample__intval(sample, "vec"); work->id =3D num; work->name =3D evsel__softirq_name(evsel, num); } @@ -1234,17 +1234,16 @@ static void workqueue_work_init(struct perf_kwork *= kwork __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { char *modp =3D NULL; - unsigned long long function_addr =3D evsel__intval(evsel, - sample, "function"); + unsigned long long function_addr =3D perf_sample__intval(sample, "functio= n"); =20 work->class =3D class; work->cpu =3D sample->cpu; - work->id =3D evsel__intval(evsel, sample, "work"); + work->id =3D perf_sample__intval(sample, "work"); work->name =3D function_addr =3D=3D 0 ? NULL : machine__resolve_kernel_addr(machine, &function_addr, &modp); } @@ -1302,7 +1301,7 @@ static void sched_work_init(struct perf_kwork *kwork = __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1310,11 +1309,11 @@ static void sched_work_init(struct perf_kwork *kwor= k __maybe_unused, work->cpu =3D sample->cpu; =20 if (src_type =3D=3D KWORK_TRACE_EXIT) { - work->id =3D evsel__intval(evsel, sample, "prev_pid"); - work->name =3D strdup(evsel__strval(evsel, sample, "prev_comm")); + work->id =3D perf_sample__intval(sample, "prev_pid"); + work->name =3D strdup(perf_sample__strval(sample, "prev_comm")); } else if (src_type =3D=3D KWORK_TRACE_ENTRY) { - work->id =3D evsel__intval(evsel, sample, "next_pid"); - work->name =3D strdup(evsel__strval(evsel, sample, "next_comm")); + work->id =3D perf_sample__intval(sample, "next_pid"); + work->name =3D strdup(perf_sample__strval(sample, "next_comm")); } } =20 diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 4d8ddf6391e8..cbf3a39c7837 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -563,15 +563,15 @@ static int get_key_by_aggr_mode(u64 *key, u64 addr, s= truct evsel *evsel, return get_key_by_aggr_mode_simple(key, addr, sample->tid); } =20 -static int report_lock_acquire_event(struct evsel *evsel, +static int report_lock_acquire_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); - int flag =3D evsel__intval(evsel, sample, "flags"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); + int flag =3D perf_sample__intval(sample, "flags"); u64 key; int ret; =20 @@ -638,15 +638,15 @@ static int report_lock_acquire_event(struct evsel *ev= sel, return 0; } =20 -static int report_lock_acquired_event(struct evsel *evsel, +static int report_lock_acquired_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; u64 contended_term; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -704,14 +704,14 @@ static int report_lock_acquired_event(struct evsel *e= vsel, return 0; } =20 -static int report_lock_contended_event(struct evsel *evsel, +static int report_lock_contended_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -762,14 +762,14 @@ static int report_lock_contended_event(struct evsel *= evsel, return 0; } =20 -static int report_lock_release_event(struct evsel *evsel, +static int report_lock_release_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -969,8 +969,8 @@ static int report_lock_contention_begin_event(struct ev= sel *evsel, struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - u64 addr =3D evsel__intval(evsel, sample, "lock_addr"); - unsigned int flags =3D evsel__intval(evsel, sample, "flags"); + u64 addr =3D perf_sample__intval(sample, "lock_addr"); + unsigned int flags =3D perf_sample__intval(sample, "flags"); u64 key; int i, ret; static bool kmap_loaded; @@ -1134,7 +1134,7 @@ static int report_lock_contention_end_event(struct ev= sel *evsel, struct thread_stat *ts; struct lock_seq_stat *seq; u64 contended_term; - u64 addr =3D evsel__intval(evsel, sample, "lock_addr"); + u64 addr =3D perf_sample__intval(sample, "lock_addr"); u64 key; int ret; =20 diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 0713e6b28f92..f15b64157589 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -829,8 +829,8 @@ replay_wakeup_event(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { - const char *comm =3D evsel__strval(evsel, sample, "comm"); - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const char *comm =3D perf_sample__strval(sample, "comm"); + const u32 pid =3D perf_sample__intval(sample, "pid"); struct task_desc *waker, *wakee; =20 if (verbose > 0) { @@ -851,10 +851,10 @@ static int replay_switch_event(struct perf_sched *sch= ed, struct perf_sample *sample, struct machine *machine __maybe_unused) { - const char *prev_comm =3D evsel__strval(evsel, sample, "prev_comm"), - *next_comm =3D evsel__strval(evsel, sample, "next_comm"); - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); + const char *prev_comm =3D perf_sample__strval(sample, "prev_comm"), + *next_comm =3D perf_sample__strval(sample, "next_comm"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); struct task_desc *prev, __maybe_unused *next; u64 timestamp0, timestamp =3D sample->time; int cpu =3D sample->cpu; @@ -1134,13 +1134,13 @@ static void free_work_atoms(struct work_atoms *atom= s) } =20 static int latency_switch_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const char prev_state =3D evsel__taskstate(evsel, sample, "prev_state"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); + const char prev_state =3D perf_sample__taskstate(sample, "prev_state"); struct work_atoms *out_events, *in_events; struct thread *sched_out, *sched_in; u64 timestamp0, timestamp =3D sample->time; @@ -1204,12 +1204,12 @@ static int latency_switch_event(struct perf_sched *= sched, } =20 static int latency_runtime_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); - const u64 runtime =3D evsel__intval(evsel, sample, "runtime"); + const u32 pid =3D perf_sample__intval(sample, "pid"); + const u64 runtime =3D perf_sample__intval(sample, "runtime"); struct thread *thread =3D machine__findnew_thread(machine, -1, pid); struct work_atoms *atoms =3D thread_atoms_search(&sched->atom_root, threa= d, &sched->cmp_pid); u64 timestamp =3D sample->time; @@ -1239,11 +1239,11 @@ static int latency_runtime_event(struct perf_sched = *sched, } =20 static int latency_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); struct work_atoms *atoms; struct work_atom *atom; struct thread *wakee; @@ -1300,11 +1300,11 @@ static int latency_wakeup_event(struct perf_sched *= sched, } =20 static int latency_migrate_task_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); u64 timestamp =3D sample->time; struct work_atoms *atoms; struct work_atom *atom; @@ -1626,11 +1626,11 @@ static void print_sched_map(struct perf_sched *sche= d, struct perf_cpu this_cpu, } } =20 -static int map_switch_event(struct perf_sched *sched, struct evsel *evsel, +static int map_switch_event(struct perf_sched *sched, struct evsel *evsel = __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"); struct thread *sched_in, *sched_out; struct thread_runtime *tr; int new_shortname; @@ -1797,8 +1797,8 @@ static int process_sched_switch_event(const struct pe= rf_tool *tool, { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); int this_cpu =3D sample->cpu, err =3D 0; - u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); + u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); =20 if (sched->curr_pid[this_cpu] !=3D (u32)-1) { /* @@ -2068,12 +2068,11 @@ static char *timehist_get_commstr(struct thread *th= read) =20 /* prio field format: xxx or xxx->yyy */ #define MAX_PRIO_STR_LEN 8 -static char *timehist_get_priostr(struct evsel *evsel, - struct thread *thread, +static char *timehist_get_priostr(struct thread *thread, struct perf_sample *sample) { static char prio_str[16]; - int prev_prio =3D (int)evsel__intval(evsel, sample, "prev_prio"); + int prev_prio =3D (int)perf_sample__intval(sample, "prev_prio"); struct thread_runtime *tr =3D thread__priv(thread); =20 if (tr->prio !=3D prev_prio && tr->prio !=3D -1) @@ -2161,15 +2160,14 @@ static void timehist_header(struct perf_sched *sche= d) } =20 static void timehist_print_sample(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct addr_location *al, struct thread *thread, u64 t, const char state) { struct thread_runtime *tr =3D thread__priv(thread); - const char *next_comm =3D evsel__strval(evsel, sample, "next_comm"); - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); + const char *next_comm =3D perf_sample__strval(sample, "next_comm"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); u32 max_cpus =3D sched->max_cpu.cpu + 1; char tstr[64]; char nstr[30]; @@ -2198,14 +2196,15 @@ static void timehist_print_sample(struct perf_sched= *sched, } =20 if (!thread__comm_set(thread)) { - const char *prev_comm =3D evsel__strval(evsel, sample, "pr= ev_comm"); - thread__set_comm(thread, prev_comm, sample->time); + const char *prev_comm =3D perf_sample__strval(sample, "prev_comm"); + + thread__set_comm(thread, prev_comm, sample->time); } =20 printf(" %-*s ", comm_width, timehist_get_commstr(thread)); =20 if (sched->show_prio) - printf(" %-*s ", MAX_PRIO_STR_LEN, timehist_get_priostr(evsel, thread, s= ample)); + printf(" %-*s ", MAX_PRIO_STR_LEN, timehist_get_priostr(thread, sample)); =20 wait_time =3D tr->dt_sleep + tr->dt_iowait + tr->dt_preempt; print_sched_time(wait_time, 6); @@ -2319,7 +2318,7 @@ static bool is_idle_sample(struct perf_sample *sample, { /* pid 0 =3D=3D swapper =3D=3D idle task */ if (evsel__name_is(evsel, "sched:sched_switch")) - return evsel__intval(evsel, sample, "prev_pid") =3D=3D 0; + return perf_sample__intval(sample, "prev_pid") =3D=3D 0; =20 return sample->pid =3D=3D 0; } @@ -2539,7 +2538,7 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, itr->last_thread =3D thread__get(thread); =20 /* copy task callchain when entering to idle */ - if (evsel__intval(evsel, sample, "next_pid") =3D=3D 0) + if (perf_sample__intval(sample, "next_pid") =3D=3D 0) save_idle_callchain(sched, itr, sample); } } @@ -2572,7 +2571,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, if (tr && tr->prio !=3D -1) prio =3D tr->prio; else if (evsel__name_is(evsel, "sched:sched_switch")) - prio =3D evsel__intval(evsel, sample, "prev_prio"); + prio =3D perf_sample__intval(sample, "prev_prio"); =20 if (prio !=3D -1 && !test_bit(prio, sched->prio_bitmap)) { rc =3D true; @@ -2583,8 +2582,8 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, if (sched->idle_hist) { if (!evsel__name_is(evsel, "sched:sched_switch")) rc =3D true; - else if (evsel__intval(evsel, sample, "prev_pid") !=3D 0 && - evsel__intval(evsel, sample, "next_pid") !=3D 0) + else if (perf_sample__intval(sample, "prev_pid") !=3D 0 && + perf_sample__intval(sample, "next_pid") !=3D 0) rc =3D true; } =20 @@ -2647,7 +2646,7 @@ static int timehist_sched_wakeup_event(const struct p= erf_tool *tool, struct thread *thread; struct thread_runtime *tr =3D NULL; /* want pid of awakened task not pid in sample */ - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); =20 thread =3D machine__findnew_thread(machine, 0, pid); if (thread =3D=3D NULL) @@ -2686,8 +2685,8 @@ static void timehist_print_migration_event(struct per= f_sched *sched, return; =20 max_cpus =3D sched->max_cpu.cpu + 1; - ocpu =3D evsel__intval(evsel, sample, "orig_cpu"); - dcpu =3D evsel__intval(evsel, sample, "dest_cpu"); + ocpu =3D perf_sample__intval(sample, "orig_cpu"); + dcpu =3D perf_sample__intval(sample, "dest_cpu"); =20 thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); if (thread =3D=3D NULL) @@ -2736,7 +2735,7 @@ static int timehist_migrate_task_event(const struct p= erf_tool *tool, struct thread *thread; struct thread_runtime *tr =3D NULL; /* want pid of migrated task not pid in sample */ - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); =20 thread =3D machine__findnew_thread(machine, 0, pid); if (thread =3D=3D NULL) @@ -2761,14 +2760,13 @@ static int timehist_migrate_task_event(const struct= perf_tool *tool, return 0; } =20 -static void timehist_update_task_prio(struct evsel *evsel, - struct perf_sample *sample, +static void timehist_update_task_prio(struct perf_sample *sample, struct machine *machine) { struct thread *thread; struct thread_runtime *tr =3D NULL; - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const u32 next_prio =3D evsel__intval(evsel, sample, "next_prio"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); + const u32 next_prio =3D perf_sample__intval(sample, "next_prio"); =20 if (next_pid =3D=3D 0) thread =3D get_idle_thread(sample->cpu); @@ -2798,7 +2796,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, struct thread_runtime *tr =3D NULL; u64 tprev, t =3D sample->time; int rc =3D 0; - const char state =3D evsel__taskstate(evsel, sample, "prev_state"); + const char state =3D perf_sample__taskstate(sample, "prev_state"); =20 addr_location__init(&al); if (machine__resolve(machine, &al, sample) < 0) { @@ -2809,7 +2807,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, } =20 if (sched->show_prio || sched->prio_str) - timehist_update_task_prio(evsel, sample, machine); + timehist_update_task_prio(sample, machine); =20 thread =3D timehist_get_thread(sched, sample, machine, evsel); if (thread =3D=3D NULL) { @@ -2891,7 +2889,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, } =20 if (!sched->summary_only) - timehist_print_sample(sched, evsel, sample, &al, thread, t, state); + timehist_print_sample(sched, sample, &al, thread, t, state); } =20 out: diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 8692d11ccd29..034e0ba3f9cb 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -597,12 +597,12 @@ static int process_sample_event(const struct perf_too= l *tool, =20 static int process_sample_cpu_idle(struct timechart *tchart __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u32 state =3D evsel__intval(evsel, sample, "state"); - u32 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); + u32 state =3D perf_sample__intval(sample, "state"); + u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 if (state =3D=3D (u32)PWR_EVENT_EXIT) c_state_end(tchart, cpu_id, sample->time); @@ -613,12 +613,12 @@ process_sample_cpu_idle(struct timechart *tchart __ma= ybe_unused, =20 static int process_sample_cpu_frequency(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u32 state =3D evsel__intval(evsel, sample, "state"); - u32 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); + u32 state =3D perf_sample__intval(sample, "state"); + u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 p_state_change(tchart, cpu_id, sample->time, state); return 0; @@ -626,13 +626,13 @@ process_sample_cpu_frequency(struct timechart *tchart, =20 static int process_sample_sched_wakeup(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { - u8 flags =3D evsel__intval(evsel, sample, "common_flags"); - int waker =3D evsel__intval(evsel, sample, "common_pid"); - int wakee =3D evsel__intval(evsel, sample, "pid"); + u8 flags =3D perf_sample__intval(sample, "common_flags"); + int waker =3D perf_sample__intval(sample, "common_pid"); + int wakee =3D perf_sample__intval(sample, "pid"); =20 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, back= trace); return 0; @@ -640,13 +640,13 @@ process_sample_sched_wakeup(struct timechart *tchart, =20 static int process_sample_sched_switch(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { - int prev_pid =3D evsel__intval(evsel, sample, "prev_pid"); - int next_pid =3D evsel__intval(evsel, sample, "next_pid"); - u64 prev_state =3D evsel__intval(evsel, sample, "prev_state"); + int prev_pid =3D perf_sample__intval(sample, "prev_pid"); + int next_pid =3D perf_sample__intval(sample, "next_pid"); + u64 prev_state =3D perf_sample__intval(sample, "prev_state"); =20 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, prev_state, backtrace); @@ -656,12 +656,12 @@ process_sample_sched_switch(struct timechart *tchart, #ifdef SUPPORT_OLD_POWER_EVENTS static int process_sample_power_start(struct timechart *tchart __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u64 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); - u64 value =3D evsel__intval(evsel, sample, "value"); + u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); + u64 value =3D perf_sample__intval(sample, "value"); =20 c_state_start(cpu_id, sample->time, value); return 0; @@ -679,12 +679,12 @@ process_sample_power_end(struct timechart *tchart, =20 static int process_sample_power_frequency(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u64 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); - u64 value =3D evsel__intval(evsel, sample, "value"); + u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); + u64 value =3D perf_sample__intval(sample, "value"); =20 p_state_change(tchart, cpu_id, sample->time, value); return 0; @@ -849,120 +849,120 @@ static int pid_end_io_sample(struct timechart *tcha= rt, int pid, int type, =20 static int process_enter_read(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, sample->time, fd); } =20 static int process_exit_read(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, sample->time, ret); } =20 static int process_enter_write(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, sample->time, fd); } =20 static int process_exit_write(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, sample->time, ret); } =20 static int process_enter_sync(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, sample->time, fd); } =20 static int process_exit_sync(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, sample->time, ret); } =20 static int process_enter_tx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, sample->time, fd); } =20 static int process_exit_tx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, sample->time, ret); } =20 static int process_enter_rx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, sample->time, fd); } =20 static int process_exit_rx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, sample->time, ret); } =20 static int process_enter_poll(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, sample->time, fd); } =20 static int process_exit_poll(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, sample->time, ret); } diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index d9e80740e9ac..f05782f03d6c 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3061,7 +3061,7 @@ errno_print: { return err; } =20 -static int trace__vfs_getname(struct trace *trace, struct evsel *evsel, +static int trace__vfs_getname(struct trace *trace, struct evsel *evsel __m= aybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3070,7 +3070,7 @@ static int trace__vfs_getname(struct trace *trace, st= ruct evsel *evsel, size_t filename_len, entry_str_len, to_move; ssize_t remaining_space; char *pos; - const char *filename =3D evsel__rawptr(evsel, sample, "pathname"); + const char *filename =3D perf_sample__strval(sample, "pathname"); =20 if (!thread) goto out; @@ -3126,7 +3126,7 @@ static int trace__sched_stat_runtime(struct trace *tr= ace, struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) { - u64 runtime =3D evsel__intval(evsel, sample, "runtime"); + u64 runtime =3D perf_sample__intval(sample, "runtime"); double runtime_ms =3D (double)runtime / NSEC_PER_MSEC; struct thread *thread =3D machine__findnew_thread(trace->host, sample->pid, @@ -3145,10 +3145,10 @@ static int trace__sched_stat_runtime(struct trace *= trace, struct evsel *evsel, out_dump: fprintf(trace->output, "%s: comm=3D%s,pid=3D%u,runtime=3D%" PRIu64 ",vrun= time=3D%" PRIu64 ")\n", evsel->name, - evsel__strval(evsel, sample, "comm"), - (pid_t)evsel__intval(evsel, sample, "pid"), + perf_sample__strval(sample, "comm"), + (pid_t)perf_sample__intval(sample, "pid"), runtime, - evsel__intval(evsel, sample, "vruntime")); + perf_sample__intval(sample, "vruntime")); goto out_put; } =20 diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests= /openat-syscall-tp-fields.c index 2a139d2781a8..97550b349418 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -118,7 +118,7 @@ static int test__syscall_openat_tp_fields(struct test_s= uite *test __maybe_unused goto out_delete_evlist; } =20 - tp_flags =3D evsel__intval(evsel, &sample, "flags"); + tp_flags =3D perf_sample__intval(&sample, "flags"); perf_sample__exit(&sample); if (flags !=3D tp_flags) { pr_debug("%s: Expected flags=3D%#x, got %#x\n", diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index 72a8289e846d..22b0302252db 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -140,8 +140,8 @@ static int process_sample_event(struct evlist *evlist, =20 evsel =3D evlist__id2evsel(evlist, sample.id); if (evsel =3D=3D switch_tracking->switch_evsel) { - next_tid =3D evsel__intval(evsel, &sample, "next_pid"); - prev_tid =3D evsel__intval(evsel, &sample, "prev_pid"); + next_tid =3D perf_sample__intval(&sample, "next_pid"); + prev_tid =3D perf_sample__intval(&sample, "prev_pid"); cpu =3D sample.cpu; pr_debug3("sched_switch: cpu: %d prev_tid %d next_tid %d\n", cpu, prev_tid, next_tid); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2ee87fd84d3e..ee30e15af054 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3687,9 +3687,9 @@ struct tep_format_field *evsel__common_field(struct e= vsel *evsel, const char *na return tp_format ? tep_find_common_field(tp_format, name) : NULL; } =20 -void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const= char *name) +void *perf_sample__rawptr(struct perf_sample *sample, const char *name) { - struct tep_format_field *field =3D evsel__field(evsel, name); + struct tep_format_field *field =3D evsel__field(sample->evsel, name); int offset; =20 if (!field) @@ -3746,21 +3746,21 @@ u64 format_field__intval(struct tep_format_field *f= ield, struct perf_sample *sam return 0; } =20 -u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const c= har *name) +u64 perf_sample__intval(struct perf_sample *sample, const char *name) { - struct tep_format_field *field =3D evsel__field(evsel, name); + struct tep_format_field *field =3D evsel__field(sample->evsel, name); =20 - return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; + return field ? format_field__intval(field, sample, sample->evsel->needs_s= wap) : 0; } =20 -u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, = const char *name) +u64 perf_sample__intval_common(struct perf_sample *sample, const char *nam= e) { - struct tep_format_field *field =3D evsel__common_field(evsel, name); + struct tep_format_field *field =3D evsel__common_field(sample->evsel, nam= e); =20 - return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; + return field ? format_field__intval(field, sample, sample->evsel->needs_s= wap) : 0; } =20 -char evsel__taskstate(struct evsel *evsel, struct perf_sample *sample, con= st char *name) +char perf_sample__taskstate(struct perf_sample *sample, const char *name) { static struct tep_format_field *prev_state_field; static const char *states; @@ -3769,7 +3769,7 @@ char evsel__taskstate(struct evsel *evsel, struct per= f_sample *sample, const cha unsigned int bit; char state =3D '?'; /* '?' denotes unknown task state */ =20 - field =3D evsel__field(evsel, name); + field =3D evsel__field(sample->evsel, name); =20 if (!field) return state; @@ -3788,7 +3788,7 @@ char evsel__taskstate(struct evsel *evsel, struct per= f_sample *sample, const cha * * We can change this if we have a good reason in the future. */ - val =3D evsel__intval(evsel, sample, name); + val =3D perf_sample__intval(sample, name); bit =3D val ? ffs(val) : 0; state =3D (!bit || bit > strlen(states)) ? 'R' : states[bit-1]; return state; diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 339b5c08a33d..927e5b4756cc 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -371,14 +371,14 @@ bool evsel__precise_ip_fallback(struct evsel *evsel); struct perf_sample; =20 #ifdef HAVE_LIBTRACEEVENT -void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const= char *name); -u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const c= har *name); -u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, = const char *name); -char evsel__taskstate(struct evsel *evsel, struct perf_sample *sample, con= st char *name); +void *perf_sample__rawptr(struct perf_sample *sample, const char *name); +u64 perf_sample__intval(struct perf_sample *sample, const char *name); +u64 perf_sample__intval_common(struct perf_sample *sample, const char *nam= e); +char perf_sample__taskstate(struct perf_sample *sample, const char *name); =20 -static inline char *evsel__strval(struct evsel *evsel, struct perf_sample = *sample, const char *name) +static inline char *perf_sample__strval(struct perf_sample *sample, const = char *name) { - return evsel__rawptr(evsel, sample, name); + return perf_sample__rawptr(sample, name); } #endif =20 diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index fc9eec8b54b8..dab23a96b1d8 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3426,7 +3426,7 @@ static int intel_pt_process_switch(struct intel_pt *p= t, if (evsel !=3D pt->switch_evsel) return 0; =20 - tid =3D evsel__intval(evsel, sample, "next_pid"); + tid =3D perf_sample__intval(sample, "next_pid"); cpu =3D sample->cpu; =20 intel_pt_log("sched_switch: cpu %d tid %d time %"PRIu64" tsc %#"PRIx64"\n= ", diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-arm64.c index 1e76906f719c..018b0db0e6e7 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c @@ -20,10 +20,8 @@ static const char * const __kvm_events_tp[] =3D { static void event_get_key(struct perf_sample *sample, struct event_key *key) { - struct evsel *evsel =3D sample->evsel; - key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_AARCH64)); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(EM_AARCH64)); key->exit_reasons =3D arm64_exit_reasons; =20 /* @@ -32,7 +30,7 @@ static void event_get_key(struct perf_sample *sample, * properly decode event's est_ec. */ if (key->key =3D=3D ARM_EXCEPTION_TRAP) { - key->key =3D evsel__intval(evsel, sample, kvm_trap_exit_reason); + key->key =3D perf_sample__intval(sample, kvm_trap_exit_reason); key->exit_reasons =3D arm64_trap_exit_reasons; } } diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c b/tools/per= f/util/kvm-stat-arch/kvm-stat-loongarch.c index 9d6265290f6d..a04cd09e3361 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c @@ -78,7 +78,7 @@ static void event_gspr_get_key(struct perf_sample *sample= , struct event_key *key unsigned int insn; =20 key->key =3D LOONGARCH_EXCEPTION_OTHERS; - insn =3D evsel__intval(sample->evsel, sample, "inst_word"); + insn =3D perf_sample__intval(sample, "inst_word"); =20 switch (insn >> 24) { case 0: diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c b/tools/perf/= util/kvm-stat-arch/kvm-stat-powerpc.c index 5158d7e88ee6..96d9c4ae0209 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c @@ -32,7 +32,7 @@ static void hcall_event_get_key(struct perf_sample *sampl= e, struct event_key *key) { key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, "req"); + key->key =3D perf_sample__intval(sample, "req"); } =20 static const char *get_hcall_exit_reason(u64 exit_code) diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-riscv.c index e8db8b4f8e2e..967bba261a47 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c @@ -26,8 +26,7 @@ static void event_get_key(struct perf_sample *sample, int xlen =3D 64; // TODO: 32-bit support. =20 key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, - kvm_exit_reason(EM_RISCV)) & ~CAUSE_IRQ_FLAG(xlen); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(EM_RISCV)) & ~CA= USE_IRQ_FLAG(xlen); key->exit_reasons =3D riscv_exit_reasons; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c b/tools/perf/uti= l/kvm-stat-arch/kvm-stat-s390.c index 158372ba0205..4771fc69fa39 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c @@ -23,7 +23,7 @@ static void event_icpt_insn_get_key(struct perf_sample *s= ample, { u64 insn; =20 - insn =3D evsel__intval(sample->evsel, sample, "instruction"); + insn =3D perf_sample__intval(sample, "instruction"); key->key =3D icpt_insn_decoder(insn); key->exit_reasons =3D sie_icpt_insn_codes; } @@ -31,21 +31,21 @@ static void event_icpt_insn_get_key(struct perf_sample = *sample, static void event_sigp_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "order_code"); + key->key =3D perf_sample__intval(sample, "order_code"); key->exit_reasons =3D sie_sigp_order_codes; } =20 static void event_diag_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "code"); + key->key =3D perf_sample__intval(sample, "code"); key->exit_reasons =3D sie_diagnose_codes; } =20 static void event_icpt_prog_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "code"); + key->key =3D perf_sample__intval(sample, "code"); key->exit_reasons =3D sie_icpt_prog_codes; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util= /kvm-stat-arch/kvm-stat-x86.c index 0ce543d82850..788d216f0852 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c @@ -27,8 +27,8 @@ static const struct kvm_events_ops exit_events =3D { static void mmio_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "gpa"); - key->info =3D evsel__intval(sample->evsel, sample, "type"); + key->key =3D perf_sample__intval(sample, "gpa"); + key->info =3D perf_sample__intval(sample, "type"); } =20 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 @@ -43,7 +43,7 @@ static bool mmio_event_begin(struct perf_sample *sample, = struct event_key *key) =20 /* MMIO write begin event in kernel. */ if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && - evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WR= ITE) { + perf_sample__intval(sample, "type") =3D=3D KVM_TRACE_MMIO_WRITE) { mmio_event_get_key(sample, key); return true; } @@ -59,7 +59,7 @@ static bool mmio_event_end(struct perf_sample *sample, st= ruct event_key *key) =20 /* MMIO read end event in kernel.*/ if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && - evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_RE= AD) { + perf_sample__intval(sample, "type") =3D=3D KVM_TRACE_MMIO_READ) { mmio_event_get_key(sample, key); return true; } @@ -87,8 +87,8 @@ static const struct kvm_events_ops mmio_events =3D { static void ioport_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "port"); - key->info =3D evsel__intval(sample->evsel, sample, "rw"); + key->key =3D perf_sample__intval(sample, "port"); + key->info =3D perf_sample__intval(sample, "rw"); } =20 static bool ioport_event_begin(struct perf_sample *sample, @@ -126,8 +126,8 @@ static const struct kvm_events_ops ioport_events =3D { /* The time of emulation msr is from kvm_msr to kvm_entry. */ static void msr_event_get_key(struct perf_sample *sample, struct event_key= *key) { - key->key =3D evsel__intval(sample->evsel, sample, "ecx"); - key->info =3D evsel__intval(sample->evsel, sample, "write"); + key->key =3D perf_sample__intval(sample, "ecx"); + key->info =3D perf_sample__intval(sample, "write"); } =20 static bool msr_event_begin(struct perf_sample *sample, struct event_key *= key) diff --git a/tools/perf/util/kvm-stat.c b/tools/perf/util/kvm-stat.c index f17a6132958d..755ab659a05c 100644 --- a/tools/perf/util/kvm-stat.c +++ b/tools/perf/util/kvm-stat.c @@ -17,7 +17,7 @@ void exit_event_get_key(struct perf_sample *sample, uint16_t e_machine =3D evsel__e_machine(sample->evsel, /*e_flags=3D*/NULL= ); =20 key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, kvm_exit_reason(e_mach= ine)); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(e_machine)); } =20 =20 --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 B02961F0E29 for ; Mon, 13 Apr 2026 01:22:42 +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=1776043364; cv=none; b=t/t8X1+JRFNPO4oIWH3tWdjFVTm/x/bBj8r14WzubqIwcMM+x4eH6ilFffeuj6CwVWJddp5d1I4A5QcnlM0t/rwlSDiKUsHenLKU5gT8gvZ7gO+I5iYYHpCBx92VCdxiskwWkPWySQTUeHsb88xBdSdJRjYAVXMU3etdMAlY4aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043364; c=relaxed/simple; bh=+6/TgirLyVcX/Kq6q4L3ThQN7uhgHB3Eulb+wJXLUO4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Q4lBaiHXGv0pFe0uOBhrZPwt/9Z60+mJJibJPL1gRTQY+JMkg3vyldCJC2IVkTlZ7COb/IvdbjLk3WLu9nXwrVtDJ/W+0XzMlBx7BM5bcXys/tLqRxoEvz8WACZez4flun0uviz9SwuHPL7oKJ5VJc6J9MgsCUqyCighj7Gix4g= 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=u44cXpkZ; 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="u44cXpkZ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d443c3b094so8550263eec.1 for ; Sun, 12 Apr 2026 18:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043362; x=1776648162; 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=23XNRjKq0mKMLzG+gfCPZj6vfaGkX3d4v88eP/QjFIg=; b=u44cXpkZtec24f/wyYwLlmpILE+jPIhyfs+UtcmoBisgSF+Qo+MSD6DYAa0xuJkvOT njctYmg2g9AFXJ6jvppVQtyR/liFy8+uxBG7euzz/QZjPPRd4hhiu6mZtjI6AGCUpzLU sXpFq/lwfbI4BRQqh21R6/6AuiBrU9TrJgIZukS9TtsujYZwYvj53vmdrLxMDiCoqYVM 6PjeOrBfSvVX6LwuWgt0EeSFVx9dK4nn8ZbivXC5UT+WqQ8Jfsp0EVnYLCcLsZWIYC9B ahG+BHqonNBy4dlqwDpqknvH+JKlg7rhHKn2Nc/6INF/MSnvjLyimfxW7VXuRhiLBof0 DiQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043362; x=1776648162; 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=23XNRjKq0mKMLzG+gfCPZj6vfaGkX3d4v88eP/QjFIg=; b=DXznUF7Y6FaxfDKt2Hy19Y66cRbjadZWbVSDMddyBUQzpbj3T2kks8XcWFcnEGvn1g 2zpCuN50ewD25H5pKbGsBezAnRnAfaFt9BdFM+Uit2fepSjPahkHsUFCYRvJL0O5Bt9Z 4l32GyeW9SfcvQkDardnVuo5A8vw24sV1W1phD6YTjYSWMJvtYmVit7siLJc2Vo9h/9Q Vi16yQT052+iCIJHTzpzkEcWVofdzdZSLe7EVTKL61ID/OVmmjP3oNxNq84kZ/RatW1t n1LVAxKNn8xCm+Ih5s2VZMb0KWmL5YIyEctbpwFmhRfJNQQL5hSuuXawgJFcM4fF7/JH aLvg== X-Forwarded-Encrypted: i=1; AJvYcCXmq1lE2Z26tpmqSrDXtkYz8kUz29uExxY+iPrEVhW/WdBo8J1ucwP/TzORP++GcCvYu5hAPIeu7VZFxhE=@vger.kernel.org X-Gm-Message-State: AOJu0YxRjnB8UZvfSXmBwmwEz4Hlbd+HX9a7PIdEC1p3v1lva6MLdByd CiXpN8omc+prtB5LBCsq9Ug5ekCRM3S8xghhfXfiC94dZRPW0EVLMduqy2kzfNSAbngLiGstwk8 04uC4qumCaA== X-Received: from dlbsn14.prod.google.com ([2002:a05:7022:b90e:b0:128:d185:c6ff]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6725:b0:128:d219:e169 with SMTP id a92af1059eb24-12c34ea5555mr6351014c88.10.1776043361558; Sun, 12 Apr 2026 18:22:41 -0700 (PDT) Date: Sun, 12 Apr 2026 18:21:59 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-6-irogers@google.com> Subject: [PATCH v11 05/33] perf trace: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 now contains the evsel and so don't unnecessarily pass the evsel. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 55 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f05782f03d6c..7f40cc81fd21 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -535,12 +535,12 @@ static struct evsel *perf_evsel__raw_syscall_newtp(co= nst char *direction, void * return NULL; } =20 -#define perf_evsel__sc_tp_uint(evsel, name, sample) \ - ({ struct syscall_tp *fields =3D __evsel__syscall_tp(evsel); \ +#define perf_evsel__sc_tp_uint(name, sample) \ + ({ struct syscall_tp *fields =3D __evsel__syscall_tp(sample->evsel); \ fields->name.integer(&fields->name, sample); }) =20 -#define perf_evsel__sc_tp_ptr(evsel, name, sample) \ - ({ struct syscall_tp *fields =3D __evsel__syscall_tp(evsel); \ +#define perf_evsel__sc_tp_ptr(name, sample) \ + ({ struct syscall_tp *fields =3D __evsel__syscall_tp(sample->evsel); \ fields->name.pointer(&fields->name, sample); }) =20 size_t strarray__scnprintf_suffix(struct strarray *sa, char *bf, size_t si= ze, const char *intfmt, bool show_suffix, int val) @@ -2721,8 +2721,8 @@ static int trace__printf_interrupted_entry(struct tra= ce *trace) return printed; } =20 -static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel, - struct perf_sample *sample, struct thread *thread) +static int trace__fprintf_sample(struct trace *trace, struct perf_sample *= sample, + struct thread *thread) { int printed =3D 0; =20 @@ -2730,7 +2730,7 @@ static int trace__fprintf_sample(struct trace *trace,= struct evsel *evsel, double ts =3D (double)sample->time / NSEC_PER_MSEC; =20 printed +=3D fprintf(trace->output, "%22s %10.3f %s %d/%d [%d]\n", - evsel__name(evsel), ts, + evsel__name(sample->evsel), ts, thread__comm_str(thread), sample->pid, sample->tid, sample->cpu); } @@ -2785,7 +2785,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, void *args; int printed =3D 0; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1; int augmented_args_size =3D 0, e_machine; void *augmented_args =3D NULL; struct syscall *sc; @@ -2800,9 +2800,9 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - trace__fprintf_sample(trace, evsel, sample, thread); + trace__fprintf_sample(trace, sample, thread); =20 - args =3D perf_evsel__sc_tp_ptr(evsel, args, sample); + args =3D perf_evsel__sc_tp_ptr(args, sample); =20 if (ttrace->entry_str =3D=3D NULL) { ttrace->entry_str =3D malloc(trace__entry_str_size); @@ -2857,12 +2857,11 @@ static int trace__sys_enter(struct trace *trace, st= ruct evsel *evsel, return err; } =20 -static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evs= el, - struct perf_sample *sample) +static int trace__fprintf_sys_enter(struct trace *trace, struct perf_sampl= e *sample) { struct thread_trace *ttrace; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1; struct syscall *sc; char msg[1024]; void *args, *augmented_args =3D NULL; @@ -2872,7 +2871,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); e_machine =3D thread__e_machine(thread, trace->host, /*e_flags=3D*/NULL); - sc =3D trace__syscall_info(trace, evsel, e_machine, id); + sc =3D trace__syscall_info(trace, sample->evsel, e_machine, id); if (sc =3D=3D NULL) goto out_put; ttrace =3D thread__trace(thread, trace); @@ -2883,7 +2882,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - args =3D perf_evsel__sc_tp_ptr(evsel, args, sample); + args =3D perf_evsel__sc_tp_ptr(args, sample); augmented_args =3D syscall__augmented_args(sc, sample, &augmented_args_si= ze, trace->raw_augmented_syscalls_args_size); printed +=3D syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmente= d_args, augmented_args_size, trace, thread); fprintf(trace->output, "%.*s", (int)printed, msg); @@ -2893,10 +2892,11 @@ static int trace__fprintf_sys_enter(struct trace *t= race, struct evsel *evsel, return err; } =20 -static int trace__resolve_callchain(struct trace *trace, struct evsel *evs= el, +static int trace__resolve_callchain(struct trace *trace, struct perf_sample *sample, struct callchain_cursor *cursor) { + struct evsel *evsel =3D sample->evsel; struct addr_location al; int max_stack =3D evsel->core.attr.sample_max_stack ? evsel->core.attr.sample_max_stack : @@ -2931,7 +2931,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, u64 duration =3D 0; bool duration_calculated =3D false; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1, callchain_ret = =3D 0, printed =3D 0; int alignment =3D trace->args_alignment, e_machine; struct syscall *sc; struct thread_trace *ttrace; @@ -2945,9 +2945,9 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - trace__fprintf_sample(trace, evsel, sample, thread); + trace__fprintf_sample(trace, sample, thread); =20 - ret =3D perf_evsel__sc_tp_uint(evsel, ret, sample); + ret =3D perf_evsel__sc_tp_uint(ret, sample); =20 if (trace->summary) thread__update_stats(thread, ttrace, id, sample, ret, trace); @@ -2969,7 +2969,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out; @@ -3184,9 +3184,10 @@ static void bpf_output__fprintf(struct trace *trace, ++trace->nr_events_printed; } =20 -static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *= evsel, struct perf_sample *sample, +static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sa= mple *sample, struct thread *thread, void *augmented_args, int augmented_args= _size) { + struct evsel *evsel =3D sample->evsel; char bf[2048]; size_t size =3D sizeof(bf); const struct tep_event *tp_format =3D evsel__tp_format(evsel); @@ -3269,7 +3270,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out; @@ -3287,7 +3288,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, trace__fprintf_comm_tid(trace, thread, trace->output); =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); + int id =3D perf_evsel__sc_tp_uint(id, sample); int e_machine =3D thread ? thread__e_machine(thread, trace->host, /*e_flags=3D*/NULL) : EM_HOST; @@ -3295,7 +3296,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (sc) { fprintf(trace->output, "%s(", sc->name); - trace__fprintf_sys_enter(trace, evsel, sample); + trace__fprintf_sys_enter(trace, sample); fputc(')', trace->output); goto newline; } @@ -3315,13 +3316,13 @@ static int trace__event_handler(struct trace *trace= , struct evsel *evsel, const struct tep_event *tp_format =3D evsel__tp_format(evsel); =20 if (tp_format && (strncmp(tp_format->name, "sys_enter_", 10) || - trace__fprintf_sys_enter(trace, evsel, sample))) { + trace__fprintf_sys_enter(trace, sample))) { if (trace->libtraceevent_print) { event_format__fprintf(tp_format, sample->cpu, sample->raw_data, sample->raw_size, trace->output); } else { - trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0); + trace__fprintf_tp_fields(trace, sample, thread, NULL, 0); } } } @@ -3380,7 +3381,7 @@ static int trace__pgfault(struct trace *trace, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out_put; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 1991420A5F3 for ; Mon, 13 Apr 2026 01:22:45 +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=1776043367; cv=none; b=tzppftZ1wlSkTrCXvTI31WwCcx01mP1+Oj8BrgSQ6eEvpKLZDU7e8v1Rg0KTvnczruKWXpY/iXvENtXkxA9t+ZApS8hNWFLgthlzY7wMkRv1LqmDVru4g4ZLIvOS/WcQ3DZHzbdI3corg5V+7v605zBpDq3FRyFvInesp5ZHrOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043367; c=relaxed/simple; bh=hc6l9CKB6FxzdTfTLq8PoMzdccFlHc3iYQeb2+Pdzw4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=V9+FH69MwIDPqT9I7EuKJDkpCrrLClLGUcsXTLMFZG2Uwt0D3TlrlcP0PO8dCbrxVlnlQ9DN2cZrxEpidYDFHJw+qHGonRv4MDBuXHbF6dxvb0cANY2WlN29giDQi/JmC4mPOW/o71+27FcnlqVmfo4uOMuosgixu+KjcOnupJY= 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/WdEu5t; 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="u/WdEu5t" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2d70f60aff7so5829704eec.0 for ; Sun, 12 Apr 2026 18:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043364; x=1776648164; 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=mpOuB27ipijrSoEkyUUE9m9a4OaxXoIVP7E+tT4QvFs=; b=u/WdEu5t3QlPzGZoUhzJR1w2wJcNga6WJrwAHLYRJTt5cV55CesXQZeI+qN46bSa6K a+74FxFP3no70oHiOT5LNirc+CQH+7QZrpxl2xz18zn16gwpKCuT1tFncNVhvdu2Qmlc CAmuD7/LUBWSroEjuBrAJM0L3trRX8ZMNTCOj3Y9abqiOOhfT1h31CvKTohGEbkc73yD sLYuSeCk1sPJsgP1qA20W1sBrmOBQBKv2c9GfaNZcpXPaw3L6f7HlxhmStTR7chCqkce aPuqZstL8BnGJAI+n2cjpgRSu/RH/EEztFgbfuLy5zIuN96GUF8mIy/fIxCqkG/pwvW9 /Fvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043364; x=1776648164; 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=mpOuB27ipijrSoEkyUUE9m9a4OaxXoIVP7E+tT4QvFs=; b=RNKWb8eXHLIw7/YmAjhhL+ZbGC8P63ygi6fCX9yvo6z0c9nySr5675unDy4KP43AIk cHLwIF2ZUvtJOeBrRb7APmcQmvroEwYb+l1wWNlawxArGAduWUyz77ntlPpQvx4Eo0X2 1E5WHXbPiunvwQMFoFcR0TXb3KECMqKaUiRbWLz0n98X2uE3eWTX9SrQn4H6bj1l81Ap SdS9+Hl7Ky9kflh3LdJhPClo2vpNIHaCqGFV5o/3x+knMxbg4GqaHT/mtIksA1R2/eL2 xOfaLIPzxVWPQyhgJTd6DU+JaZldwe+aLyu/ZWGQaeKK8jyJ8BeILMAAXGulAdHwJUVN jy8g== X-Forwarded-Encrypted: i=1; AFNElJ9Gq+jP0xHgO8+qzJg5tDmpKvNmxJrpeTS8DtEmKWaymuWRQWeWaUAPJdOS80agaGMS+i3iEr5GD6vinMg=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp8d3Wmyor90LbIvwSSNAeWVNlriLVVo9pZYXgw+AiipKRDn+j I0IrBUya4yuhEuyf10P+vTMT442qpu+RcKWhiL/BSMuB2lLqxA15P9nyYBX5OlP3AIpjdIXOCdn oDDIHAQGhew== X-Received: from dycnm7.prod.google.com ([2002:a05:7300:d187:b0:2d8:fc66:cd7b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:6ca7:b0:2d9:6373:ad10 with SMTP id 5a478bee46e88-2d96373b138mr819131eec.7.1776043364016; Sun, 12 Apr 2026 18:22:44 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:00 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-7-irogers@google.com> Subject: [PATCH v11 06/33] perf callchain: Don't pass evsel and sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Change callchain resolve code to not pass an evsel with the sample, instead just read the evsel from the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-inject.c | 4 ++-- tools/perf/builtin-kmem.c | 6 ++--- tools/perf/builtin-kwork.c | 5 ++-- tools/perf/builtin-lock.c | 24 +++++++++---------- tools/perf/builtin-sched.c | 5 ++-- tools/perf/builtin-script.c | 6 ++--- tools/perf/builtin-trace.c | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/callchain.c | 8 +++---- tools/perf/util/callchain.h | 6 ++--- tools/perf/util/db-export.c | 8 +++---- tools/perf/util/hist.c | 2 +- tools/perf/util/machine.c | 14 +++++------ tools/perf/util/machine.h | 3 --- .../util/scripting-engines/trace-event-perl.c | 4 ++-- .../scripting-engines/trace-event-python.c | 4 ++-- 17 files changed, 48 insertions(+), 57 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 7593e5908fcc..2fa3d7ec8a09 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -339,7 +339,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 cursor =3D get_tls_callchain_cursor(); ret =3D sample__resolve_callchain(sample, cursor, NULL, - evsel, &al, sysctl_perf_event_max_stack); + &al, sysctl_perf_event_max_stack); if (ret) goto out; =20 diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 3d3f3272918c..f43c165c3a13 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -417,7 +417,7 @@ static int perf_event__convert_sample_callchain(const s= truct perf_tool *tool, goto out; =20 /* this will parse DWARF using stack and register data */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, /*parent=3D*/NULL, /*root_al=3D*/NULL, PERF_MAX_STACK_DEPTH); thread__put(thread); @@ -1017,7 +1017,7 @@ static int perf_event__inject_buildid(const struct pe= rf_tool *tool, union perf_e /*sample_in_dso=3D*/true); } =20 - sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, + sample__for_each_callchain_node(thread, sample, PERF_MAX_STACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, &args); thread__put(thread); repipe: diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index d7233a8b43be..2cdc56bc2616 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -394,7 +394,7 @@ static int build_alloc_func_list(void) * Find first non-memory allocation function from callchain. * The allocation functions are in the 'alloc_func_list'. */ -static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) +static u64 find_callsite(struct perf_sample *sample) { struct addr_location al; struct machine *machine =3D &kmem_session->machines.host; @@ -414,7 +414,7 @@ static u64 find_callsite(struct evsel *evsel, struct pe= rf_sample *sample) if (cursor =3D=3D NULL) goto out; =20 - sample__resolve_callchain(sample, cursor, NULL, evsel, &al, 16); + sample__resolve_callchain(sample, cursor, /*parent=3D*/NULL, &al, 16); =20 callchain_cursor_commit(cursor); while (true) { @@ -838,7 +838,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp if (parse_gfp_flags(evsel, sample, gfp_flags) < 0) return -1; =20 - callsite =3D find_callsite(evsel, sample); + callsite =3D find_callsite(sample); =20 /* * This is to find the current page (with correct gfp flags and diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index ab4519287f47..4b312afed830 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -688,7 +688,6 @@ static int latency_entry_event(struct perf_kwork *kwork, =20 static void timehist_save_callchain(struct perf_kwork *kwork, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct symbol *sym; @@ -708,7 +707,7 @@ static void timehist_save_callchain(struct perf_kwork *= kwork, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(thread, cursor, evsel, sample, + if (thread__resolve_callchain(thread, cursor, sample, NULL, NULL, kwork->max_stack + 2) !=3D 0) { pr_debug("Failed to resolve callchain, skipping\n"); goto out_put; @@ -838,7 +837,7 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, return ret; =20 if (work !=3D NULL) - timehist_save_callchain(kwork, sample, evsel, machine); + timehist_save_callchain(kwork, sample, machine); =20 return 0; } diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index cbf3a39c7837..e2b585e528ac 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -551,13 +551,13 @@ static int get_key_by_aggr_mode_simple(u64 *key, u64 = addr, u32 tid) return 0; } =20 -static u64 callchain_id(struct evsel *evsel, struct perf_sample *sample); +static u64 callchain_id(struct perf_sample *sample); =20 -static int get_key_by_aggr_mode(u64 *key, u64 addr, struct evsel *evsel, +static int get_key_by_aggr_mode(u64 *key, u64 addr, struct perf_sample *sample) { if (aggr_mode =3D=3D LOCK_AGGR_CALLER) { - *key =3D callchain_id(evsel, sample); + *key =3D callchain_id(sample); return 0; } return get_key_by_aggr_mode_simple(key, addr, sample->tid); @@ -841,7 +841,7 @@ static int get_symbol_name_offset(struct map *map, stru= ct symbol *sym, u64 ip, else return strlcpy(buf, sym->name, size); } -static int lock_contention_caller(struct evsel *evsel, struct perf_sample = *sample, +static int lock_contention_caller(struct perf_sample *sample, char *buf, int size) { struct thread *thread; @@ -862,7 +862,7 @@ static int lock_contention_caller(struct evsel *evsel, = struct perf_sample *sampl cursor =3D get_tls_callchain_cursor(); =20 /* use caller function name from the callchain */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, max_stack_depth); if (ret !=3D 0) { thread__put(thread); @@ -896,7 +896,7 @@ static int lock_contention_caller(struct evsel *evsel, = struct perf_sample *sampl return -1; } =20 -static u64 callchain_id(struct evsel *evsel, struct perf_sample *sample) +static u64 callchain_id(struct perf_sample *sample) { struct callchain_cursor *cursor; struct machine *machine =3D &session->machines.host; @@ -911,7 +911,7 @@ static u64 callchain_id(struct evsel *evsel, struct per= f_sample *sample) =20 cursor =3D get_tls_callchain_cursor(); /* use caller function name from the callchain */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, max_stack_depth); thread__put(thread); =20 @@ -963,7 +963,7 @@ static u64 *get_callstack(struct perf_sample *sample, i= nt max_stack) return callstack; } =20 -static int report_lock_contention_begin_event(struct evsel *evsel, +static int report_lock_contention_begin_event(struct evsel *evsel __maybe_= unused, struct perf_sample *sample) { struct lock_stat *ls; @@ -978,7 +978,7 @@ static int report_lock_contention_begin_event(struct ev= sel *evsel, struct map *kmap; struct symbol *sym; =20 - ret =3D get_key_by_aggr_mode(&key, addr, evsel, sample); + ret =3D get_key_by_aggr_mode(&key, addr, sample); if (ret < 0) return ret; =20 @@ -1025,7 +1025,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel, break; case LOCK_AGGR_CALLER: name =3D buf; - if (lock_contention_caller(evsel, sample, buf, sizeof(buf)) < 0) + if (lock_contention_caller(sample, buf, sizeof(buf)) < 0) name =3D "Unknown"; break; case LOCK_AGGR_CGROUP: @@ -1127,7 +1127,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel, return 0; } =20 -static int report_lock_contention_end_event(struct evsel *evsel, +static int report_lock_contention_end_event(struct evsel *evsel __maybe_un= used, struct perf_sample *sample) { struct lock_stat *ls; @@ -1138,7 +1138,7 @@ static int report_lock_contention_end_event(struct ev= sel *evsel, u64 key; int ret; =20 - ret =3D get_key_by_aggr_mode(&key, addr, evsel, sample); + ret =3D get_key_by_aggr_mode(&key, addr, sample); if (ret < 0) return ret; =20 diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index f15b64157589..aea14bff7e61 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2325,7 +2325,6 @@ static bool is_idle_sample(struct perf_sample *sample, =20 static void save_task_callchain(struct perf_sched *sched, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct callchain_cursor *cursor; @@ -2345,7 +2344,7 @@ static void save_task_callchain(struct perf_sched *sc= hed, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(thread, cursor, evsel, sample, + if (thread__resolve_callchain(thread, cursor, sample, NULL, NULL, sched->max_stack + 2) !=3D 0) { if (verbose > 0) pr_err("Failed to resolve callchain. Skipping\n"); @@ -2519,7 +2518,7 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, sample->tid); } =20 - save_task_callchain(sched, sample, evsel, machine); + save_task_callchain(sched, sample, machine); if (sched->idle_hist) { struct thread *idle; struct idle_thread_runtime *itr; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 3ffb8baf40f6..6ea739f20495 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1683,7 +1683,7 @@ static int perf_sample__fprintf_bts(struct perf_sampl= e *sample, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack)) cursor =3D NULL; @@ -2506,7 +2506,7 @@ static void process_event(struct perf_script *script, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack)) cursor =3D NULL; @@ -2791,7 +2791,7 @@ static int process_deferred_sample_event(const struct= perf_tool *tool, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al.thread, cursor, evsel, + if (thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, scripting_max_stack)) { pr_info("cannot resolve deferred callchains\n"); diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7f40cc81fd21..1fac167f7436 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2907,7 +2907,7 @@ static int trace__resolve_callchain(struct trace *tra= ce, if (machine__resolve(trace->host, &al, sample) < 0) goto out; =20 - err =3D thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL,= NULL, max_stack); + err =3D thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, = max_stack); out: addr_location__exit(&al); return err; diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 55b72235f891..af4d874f1381 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -73,7 +73,7 @@ int build_id__mark_dso_hit(const struct perf_tool *tool _= _maybe_unused, =20 addr_location__exit(&al); =20 - sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, + sample__for_each_callchain_node(thread, sample, PERF_MAX_STACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, /*data=3D*/NULL); =20 =20 diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index f031cbbeeba8..5c2282051e39 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -1170,7 +1170,7 @@ int callchain_cursor_append(struct callchain_cursor *= cursor, =20 int sample__resolve_callchain(struct perf_sample *sample, struct callchain_cursor *cursor, struct symbol **parent, - struct evsel *evsel, struct addr_location *al, + struct addr_location *al, int max_stack) { if (sample->callchain =3D=3D NULL && !symbol_conf.show_branchflag_count) @@ -1178,7 +1178,7 @@ int sample__resolve_callchain(struct perf_sample *sam= ple, =20 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain || perf_hpp_list.parent || symbol_conf.show_branchflag_count) { - return thread__resolve_callchain(al->thread, cursor, evsel, sample, + return thread__resolve_callchain(al->thread, cursor, sample, parent, al, max_stack); } return 0; @@ -1853,7 +1853,7 @@ s64 callchain_avg_cycles(struct callchain_node *cnode) return cycles; } =20 -int sample__for_each_callchain_node(struct thread *thread, struct evsel *e= vsel, +int sample__for_each_callchain_node(struct thread *thread, struct perf_sample *sample, int max_stack, bool symbols, callchain_iter_fn cb, void *data) { @@ -1864,7 +1864,7 @@ int sample__for_each_callchain_node(struct thread *th= read, struct evsel *evsel, return -ENOMEM; =20 /* Fill in the callchain. */ - ret =3D __thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D __thread__resolve_callchain(thread, cursor, sample, /*parent=3D*/NULL, /*root_al=3D*/NULL, max_stack, symbols); if (ret) diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 06d463ccc7a0..27d8e486dc22 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -8,11 +8,9 @@ #include "branch.h" =20 struct addr_location; -struct evsel; struct hist_entry; struct hists; struct ip_callchain; -struct map; struct perf_sample; struct record_opts; struct thread; @@ -245,7 +243,7 @@ int record_opts__parse_callchain(struct record_opts *re= cord, =20 int sample__resolve_callchain(struct perf_sample *sample, struct callchain_cursor *cursor, struct symbol **parent, - struct evsel *evsel, struct addr_location *al, + struct addr_location *al, int max_stack); int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample= *sample); int fill_callchain_info(struct addr_location *al, struct callchain_cursor_= node *node, @@ -308,7 +306,7 @@ s64 callchain_avg_cycles(struct callchain_node *cnode); =20 typedef int (*callchain_iter_fn)(struct callchain_cursor_node *node, void = *data); =20 -int sample__for_each_callchain_node(struct thread *thread, struct evsel *e= vsel, +int sample__for_each_callchain_node(struct thread *thread, struct perf_sample *sample, int max_stack, bool symbols, callchain_iter_fn cb, void *data); =20 diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index cc2bb1af4243..d991e3168aed 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -208,8 +208,7 @@ static int db_ids_from_al(struct db_export *dbe, struct= addr_location *al, static struct call_path *call_path_from_sample(struct db_export *dbe, struct machine *machine, struct thread *thread, - struct perf_sample *sample, - struct evsel *evsel) + struct perf_sample *sample) { u64 kernel_start =3D machine__kernel_start(machine); struct call_path *current =3D &dbe->cpr->call_path; @@ -227,7 +226,7 @@ static struct call_path *call_path_from_sample(struct d= b_export *dbe, */ callchain_param.order =3D ORDER_CALLER; cursor =3D get_tls_callchain_cursor(); - err =3D thread__resolve_callchain(thread, cursor, evsel, + err =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, PERF_MAX_STACK_DEPTH); if (err) { callchain_param.order =3D saved_order; @@ -390,8 +389,7 @@ int db_export__sample(struct db_export *dbe, union perf= _event *event, =20 if (dbe->cpr) { struct call_path *cp =3D call_path_from_sample(dbe, machine, - thread, sample, - evsel); + thread, sample); if (cp) { db_export__call_path(dbe, cp); es.call_path_id =3D cp->db_id; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 747fdc455c80..f641cf321ace 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1342,7 +1342,7 @@ int hist_entry_iter__add(struct hist_entry_iter *iter= , struct addr_location *al, alm =3D map__get(al->map); =20 err =3D sample__resolve_callchain(iter->sample, get_tls_callchain_cursor(= ), &iter->parent, - iter->evsel, al, max_stack_depth); + al, max_stack_depth); if (err) { map__put(alm); return err; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e76f8c86e62a..c2e0a99efe97 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2778,13 +2778,13 @@ static u64 get_leaf_frame_caller(struct perf_sample= *sample, =20 static int thread__resolve_callchain_sample(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, int max_stack, bool symbols) { + struct evsel *evsel =3D sample->evsel; struct branch_stack *branch =3D sample->branch_stack; struct branch_entry *entries =3D perf_sample__branch_entries(sample); struct ip_callchain *chain =3D sample->callchain; @@ -2986,10 +2986,11 @@ static int unwind_entry(struct unwind_entry *entry,= void *arg) =20 static int thread__resolve_callchain_unwind(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, int max_stack, bool symbols) { + struct evsel *evsel =3D sample->evsel; + /* Can we do dwarf post unwind? */ if (!((evsel->core.attr.sample_type & PERF_SAMPLE_REGS_USER) && (evsel->core.attr.sample_type & PERF_SAMPLE_STACK_USER))) @@ -3009,7 +3010,6 @@ static int thread__resolve_callchain_unwind(struct th= read *thread, =20 int __thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -3025,22 +3025,22 @@ int __thread__resolve_callchain(struct thread *thre= ad, =20 if (callchain_param.order =3D=3D ORDER_CALLEE) { ret =3D thread__resolve_callchain_sample(thread, cursor, - evsel, sample, + sample, parent, root_al, max_stack, symbols); if (ret) return ret; ret =3D thread__resolve_callchain_unwind(thread, cursor, - evsel, sample, + sample, max_stack, symbols); } else { ret =3D thread__resolve_callchain_unwind(thread, cursor, - evsel, sample, + sample, max_stack, symbols); if (ret) return ret; ret =3D thread__resolve_callchain_sample(thread, cursor, - evsel, sample, + sample, parent, root_al, max_stack, symbols); } diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 22a42c5825fa..048b24e9bd38 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -187,7 +187,6 @@ struct callchain_cursor; =20 int __thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -196,7 +195,6 @@ int __thread__resolve_callchain(struct thread *thread, =20 static inline int thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -204,7 +202,6 @@ static inline int thread__resolve_callchain(struct thre= ad *thread, { return __thread__resolve_callchain(thread, cursor, - evsel, sample, parent, root_al, diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/p= erf/util/scripting-engines/trace-event-perl.c index e261a57b87d4..af0d514b2397 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -257,7 +257,7 @@ static void define_event_symbols(struct tep_event *even= t, } =20 static SV *perl_process_callchain(struct perf_sample *sample, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct addr_location *al) { struct callchain_cursor *cursor; @@ -272,7 +272,7 @@ static SV *perl_process_callchain(struct perf_sample *s= ample, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack) !=3D 0) { pr_err("Failed to resolve callchain. Skipping\n"); goto exit; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 5a30caaec73e..1537122167d5 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -390,7 +390,7 @@ static unsigned long get_offset(struct symbol *sym, str= uct addr_location *al) } =20 static PyObject *python_process_callchain(struct perf_sample *sample, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct addr_location *al) { PyObject *pylist; @@ -404,7 +404,7 @@ static PyObject *python_process_callchain(struct perf_s= ample *sample, goto exit; =20 cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack) !=3D 0) { pr_err("Failed to resolve callchain. Skipping\n"); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 727041F8AC5 for ; Mon, 13 Apr 2026 01:22:47 +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=1776043370; cv=none; b=muKbdzIzbnTnFst2Ew3EovG50pMH74JqtP5AxV30ooG+cf02r5wuVhXAEN/zjseyVwcpCQTN+cRJI7jrkG4rbq73vY4IZ7HsvsAN6OBrdAcqYXY+09WyFpd6wb4kZyuI9jNxazDwJuSFLwdBKYgRxKf1yLVfVT6D6mZ0l0BZMcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043370; c=relaxed/simple; bh=iQzrrSkgD5q24jleWyjN1o5X5X3t72d6WQTerHN5aeA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HiMjPq4KU37h3AQteq1gRWOCT/XSOKDXw1Wi9QdM3xreTFU4YAf6F78CPTKA3m6e2BIYMLjn2btmN+Ie6nIsCEkqQ7G4Q4WOTuBfuqLN66aO3BN90XwyZfsaVUV35W/lgaR9lLG4z3y0Fm8FRYDRcYmOfrqH0bcEGhs5GTyIFIc= 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=Gk4MC8ij; 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="Gk4MC8ij" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2ba9a744f7dso4914823eec.0 for ; Sun, 12 Apr 2026 18:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043367; x=1776648167; 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=jOx0vm5n0Y9FX3aCuWOTcby7VnTaMh5tBI/U2Q+kw/k=; b=Gk4MC8ijzx5hPd/dGIGH9Fk1aqVeRFNixCb/OPjnK8jvXLoV3bqaOYZeY6tvf3QYeK 2e+4GWZWZuhxE0A82+JPOuyArrvfSxhCE4E63aB7lAZYLaNLiKNnvTPflC03R/VYA3fU lXr7+0FytpwPEO5m5Q5g5v28SP4mJNA5bCnabZK2leQttSZszQ/rZjBDVDXadgjDa3jX AtXXKRJsyqmToA5+5oRvXQ9GyYEAwrDiFc+Cxev1pDNLfZEKl0yDX6sV0PBYFup5YS3R NsHzNaplVwoGQAG4JZ8vtlx3bkBIlEdpbyFmNPz8aLNYVj00IiF/uprjh9GvcVFXAMJX dRjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043367; x=1776648167; 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=jOx0vm5n0Y9FX3aCuWOTcby7VnTaMh5tBI/U2Q+kw/k=; b=AA8ZSrSEBlLuvtx/x1bG1K6SRDrlzHcQ0ttDH4ncpqkE5AwNevKIYhh8CBrmbYSABA lp06KIipbM3YjJBh4SfYV1IiKUKL7IW8Bd3PWplK4ZhIpG8SvTdqjzMzI+yaTN4jqEF/ 52z54Ea4pex9p9GiP1vkejVWNKf15LnaQO+u910ly65x5RB9VaRPH1+VaL9ST3A5euN+ nguF3hNGyjY3T2d/n+FDqNFqaYL/s9ReoivGw5MxUinvuowKthenuUwNjn3hhTfZGKTn mPVvlQfymmRxXDHt+HUQzU4r7NG8ykgHoxRZUG7iZ3n0UgkunRX36esKNllPmJNWOA1n y06A== X-Forwarded-Encrypted: i=1; AJvYcCXvHJjGkedAmWKLmeyH3BUcyLINZqPXruJdbHmITL0SDt0G64mIxO0k/OCYpWlBIIfmaVp7P0LsdeKKGhk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz99eyGdeanNAMkHlWePTJYgs8ONPIXHi9rf5V80mSGjYlUyUo5 fl4aicV5QoLDkweZhJXGXTQG2R5+VI5877AvSfkLnBjXAcF6iYdMG4uZJUABDfJrok3PzBD5VWg xM98Ngne54Q== X-Received: from dybor13.prod.google.com ([2002:a05:7301:1f0d:b0:2d8:4599:1d20]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:512:b0:11a:6424:f40f with SMTP id a92af1059eb24-12c34f07cd7mr6086517c88.36.1776043366353; Sun, 12 Apr 2026 18:22:46 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:01 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-8-irogers@google.com> Subject: [PATCH v11 07/33] perf lock: Only pass sample to handlers From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 evsel is within the sample and so only the sample needs to be passed. Remove the parameter and fix call site. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 65 ++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index e2b585e528ac..b6533483ba64 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -473,28 +473,22 @@ static struct lock_stat *pop_from_result(void) =20 struct trace_lock_handler { /* it's used on CONFIG_LOCKDEP */ - int (*acquire_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*acquire_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP && CONFIG_LOCK_STAT */ - int (*acquired_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*acquired_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP && CONFIG_LOCK_STAT */ - int (*contended_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contended_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP */ - int (*release_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*release_event)(struct perf_sample *sample); =20 /* it's used when CONFIG_LOCKDEP is off */ - int (*contention_begin_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contention_begin_event)(struct perf_sample *sample); =20 /* it's used when CONFIG_LOCKDEP is off */ - int (*contention_end_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contention_end_event)(struct perf_sample *sample); }; =20 static struct lock_seq_stat *get_seq(struct thread_stat *ts, u64 addr) @@ -563,8 +557,7 @@ static int get_key_by_aggr_mode(u64 *key, u64 addr, return get_key_by_aggr_mode_simple(key, addr, sample->tid); } =20 -static int report_lock_acquire_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_acquire_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -638,8 +631,7 @@ static int report_lock_acquire_event(struct evsel *evse= l __maybe_unused, return 0; } =20 -static int report_lock_acquired_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_acquired_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -704,8 +696,7 @@ static int report_lock_acquired_event(struct evsel *evs= el __maybe_unused, return 0; } =20 -static int report_lock_contended_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_contended_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -762,8 +753,7 @@ static int report_lock_contended_event(struct evsel *ev= sel __maybe_unused, return 0; } =20 -static int report_lock_release_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_release_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -963,8 +953,7 @@ static u64 *get_callstack(struct perf_sample *sample, i= nt max_stack) return callstack; } =20 -static int report_lock_contention_begin_event(struct evsel *evsel __maybe_= unused, - struct perf_sample *sample) +static int report_lock_contention_begin_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -1127,8 +1116,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel __maybe_unused return 0; } =20 -static int report_lock_contention_end_event(struct evsel *evsel __maybe_un= used, - struct perf_sample *sample) +static int report_lock_contention_end_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -1208,45 +1196,45 @@ static struct trace_lock_handler contention_lock_op= s =3D { =20 static struct trace_lock_handler *trace_handler; =20 -static int evsel__process_lock_acquire(struct evsel *evsel, struct perf_sa= mple *sample) +static int evsel__process_lock_acquire(struct perf_sample *sample) { if (trace_handler->acquire_event) - return trace_handler->acquire_event(evsel, sample); + return trace_handler->acquire_event(sample); return 0; } =20 -static int evsel__process_lock_acquired(struct evsel *evsel, struct perf_s= ample *sample) +static int evsel__process_lock_acquired(struct perf_sample *sample) { if (trace_handler->acquired_event) - return trace_handler->acquired_event(evsel, sample); + return trace_handler->acquired_event(sample); return 0; } =20 -static int evsel__process_lock_contended(struct evsel *evsel, struct perf_= sample *sample) +static int evsel__process_lock_contended(struct perf_sample *sample) { if (trace_handler->contended_event) - return trace_handler->contended_event(evsel, sample); + return trace_handler->contended_event(sample); return 0; } =20 -static int evsel__process_lock_release(struct evsel *evsel, struct perf_sa= mple *sample) +static int evsel__process_lock_release(struct perf_sample *sample) { if (trace_handler->release_event) - return trace_handler->release_event(evsel, sample); + return trace_handler->release_event(sample); return 0; } =20 -static int evsel__process_contention_begin(struct evsel *evsel, struct per= f_sample *sample) +static int evsel__process_contention_begin(struct perf_sample *sample) { if (trace_handler->contention_begin_event) - return trace_handler->contention_begin_event(evsel, sample); + return trace_handler->contention_begin_event(sample); return 0; } =20 -static int evsel__process_contention_end(struct evsel *evsel, struct perf_= sample *sample) +static int evsel__process_contention_end(struct perf_sample *sample) { if (trace_handler->contention_end_event) - return trace_handler->contention_end_event(evsel, sample); + return trace_handler->contention_end_event(sample); return 0; } =20 @@ -1424,8 +1412,7 @@ static int process_event_update(const struct perf_too= l *tool, return 0; } =20 -typedef int (*tracepoint_handler)(struct evsel *evsel, - struct perf_sample *sample); +typedef int (*tracepoint_handler)(struct perf_sample *sample); =20 static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, @@ -1445,7 +1432,7 @@ static int process_sample_event(const struct perf_too= l *tool __maybe_unused, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(evsel, sample); + err =3D f(sample); } =20 thread__put(thread); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 E742E20468E for ; Mon, 13 Apr 2026 01:22:49 +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=1776043372; cv=none; b=CERpWuM+vJhIfN3ZSUhq6UDR+Kohl614ndsNfuwoIfVAciVGCbV2PF04AdtJwndV9rK5falaqSFw0lY0c+v5ekFg6fwG/i8ForSla4G6uZUUHaeLsw0pfa0O/jKp5mU8OTUSztB5xkwtCtwL9ZRR6YuLUKsVwwJxcVIFn0x6wp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043372; c=relaxed/simple; bh=nrE8NbjgL5GodtjlelQu6WKY5Rt5ryJ3pELk9LbtElA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qkOCk5trCJAR0LiF8wdX5MrPwhtCiJmHwrAxoiSxPInPrqmM2mPcBJOTpIRLPc3Alnyqe8Wx/Kl7bRIhez7KiRdaxNSd6SfJkCiNK05DFHxCkMTfVQNUbObUy7+drqu0Dpbq8SB3WkP3GXX/W924f0jUHnaldbJY3+eut6T0GQQ= 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=fTkxMdcA; 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="fTkxMdcA" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2d889997495so2294986eec.0 for ; Sun, 12 Apr 2026 18:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043369; x=1776648169; 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=CYe/pTSkEo3bwawbKUcGMi5fd/X0VJXe6Y5bot3/3gQ=; b=fTkxMdcArzgz855QKL+Hi/ACQ6nRt6ISP2fQRmuiffA8qvwlh8KlkqPDW4VdEnM9tF NmrxoMaZd74xcnbI+RnBLEVuMhtQF6Eu6pnfDI2Qa7B4gXcU63V3X/K887plm1hMWfmW tdBtqmMlOU063GyLFfKakU745SPpwB1xlQPF1QRpLGKIzHQavQal9xJPNzu7SWfyk/0M 4o59jbH54izcTa+IzaTmFgrCxyzxl8lmCLyySvftQ76OG64RKGo1+G7+5l/PgvQKevJ/ pMn4ZhIwtwwkSjdun4jQLdOh1c7e9acgt0yqAya0nmCvRRC88IdgpuJMe78QacSa8KgF cQUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043369; x=1776648169; 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=CYe/pTSkEo3bwawbKUcGMi5fd/X0VJXe6Y5bot3/3gQ=; b=tFRRdRToNOV3xwsFnvQwTeuUOINaeCh77FBaaTMzbVGlkmBQFPgzxeiP3wKaazD5Ww kOeqhbgnAk+GWTiWoNdnauJoy9MYMi7QEdfcBirTx2j/dln6qg5cJPpd5LSDNObPQ7Y4 3j482VNxejNfgzccqpO73IOBTyDQKCumin5OGInvlJmtF9otzYb/IW9JLRELDYz0SoFL UPfl0Uf90WqwauSrfTPkEBW99OesHpCYpoxJtRVE0cgxaMa/hqIV+hzAUEOdhnX/v7fJ m4aRGf6JJ2pXUKb0142GZ7xGUbCEoDGndy4c1xEkX5Yak2U3Bjf1mtPj4LE6OE5TuBke 2rgg== X-Forwarded-Encrypted: i=1; AFNElJ9gWt5rwXKJy5V7BDzo8ieHkE9y2dA1qSzQkj9qyOOC1e4VwP7AQrWogOVWUyqJOtQV2COoSehGNWF96zg=@vger.kernel.org X-Gm-Message-State: AOJu0YwY1ROvzilHRXPtd5VGCBuAqMb6Q1qhwACak6ueZT3boZylOZ3E sCUlhgs8jHlKkutNbjVXfvZ4ZVGmp9zdG4ALTuWkQodhq/EQ3NMusCY/pxfhaBjCz9WtpQcgDG9 EIn0NHFVu7w== X-Received: from dykp42.prod.google.com ([2002:a05:7300:caa:b0:2cb:a16b:ff43]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:4194:b0:2d1:a3ea:d8c5 with SMTP id 5a478bee46e88-2d5881acd82mr6333076eec.17.1776043368820; Sun, 12 Apr 2026 18:22:48 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:02 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-9-irogers@google.com> Subject: [PATCH v11 08/33] perf hist: Remove evsel parameter from inc samples functions From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" hist_entry__inc_addr_samples and addr_map_symbol__inc_samples unnecessarily take an evsel argument. Read the evsel from the sample instead. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 7 +++---- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-report.c | 18 ++++++++---------- tools/perf/builtin-top.c | 6 +++--- tools/perf/util/annotate.c | 19 +++++++++---------- tools/perf/util/annotate.h | 6 ++---- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 58e56f826367..ee1ba2dc35f4 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -176,16 +176,15 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, struct hist_entry *he =3D iter->he; struct branch_info *bi; struct perf_sample *sample =3D iter->sample; - struct evsel *evsel =3D iter->evsel; int err; =20 bi =3D he->branch_info; - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); =20 if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 out: return err; @@ -275,7 +274,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, if (he =3D=3D NULL) return -ENOMEM; =20 - ret =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + ret =3D hist_entry__inc_addr_samples(he, sample, al->addr); hists__inc_nr_samples(hists, true); return ret; } diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 2fa3d7ec8a09..36f386949923 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -371,7 +371,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 if (perf_c2c__has_annotation(NULL)) { perf_c2c__evsel_hists_inc_stats(evsel, he, sample); - addr_map_symbol__inc_samples(mem_info__iaddr(mi), sample, evsel); + addr_map_symbol__inc_samples(mem_info__iaddr(mi), sample); } =20 ret =3D hist_entry__append_callchain(he, sample); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 848e2ccb1420..46d839bbaeef 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -170,7 +170,6 @@ static int hist_iter__report_callback(struct hist_entry= _iter *iter, int err =3D 0; struct report *rep =3D arg; struct hist_entry *he =3D iter->he; - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; struct mem_info *mi; struct branch_info *bi; @@ -180,25 +179,25 @@ static int hist_iter__report_callback(struct hist_ent= ry_iter *iter, =20 if (sort__mode =3D=3D SORT_MODE__BRANCH) { bi =3D he->branch_info; - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 } else if (rep->mem_mode) { mi =3D he->mem_info; - err =3D addr_map_symbol__inc_samples(mem_info__daddr(mi), sample, evsel); + err =3D addr_map_symbol__inc_samples(mem_info__daddr(mi), sample); if (err) goto out; =20 - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); =20 } else if (symbol_conf.cumulate_callchain) { if (single) - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); } else { - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); } =20 out: @@ -214,7 +213,6 @@ static int hist_iter__branch_callback(struct hist_entry= _iter *iter, struct report *rep =3D arg; struct branch_info *bi =3D he->branch_info; struct perf_sample *sample =3D iter->sample; - struct evsel *evsel =3D iter->evsel; int err; =20 branch_type_count(&rep->brtype_stat, &bi->flags, @@ -223,11 +221,11 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, if (!ui__has_annotation() && !rep->symbol_ipc) return 0; =20 - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 out: return err; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f6eb543de537..b4fc991b4eeb 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -199,7 +199,7 @@ static void ui__warn_map_erange(struct map *map, struct= symbol *sym, u64 ip) static void perf_top__record_precise_ip(struct perf_top *top, struct hist_entry *he, struct perf_sample *sample, - struct evsel *evsel, u64 ip) + u64 ip) EXCLUSIVE_LOCKS_REQUIRED(he->hists->lock) { struct annotation *notes; @@ -216,7 +216,7 @@ static void perf_top__record_precise_ip(struct perf_top= *top, if (!annotation__trylock(notes)) return; =20 - err =3D hist_entry__inc_addr_samples(he, sample, evsel, ip); + err =3D hist_entry__inc_addr_samples(he, sample, ip); =20 annotation__unlock(notes); =20 @@ -735,7 +735,7 @@ static int hist_iter__top_callback(struct hist_entry_it= er *iter, struct evsel *evsel =3D iter->evsel; =20 if (perf_hpp_list.sym && single) - perf_top__record_precise_ip(top, iter->he, iter->sample, evsel, al->addr= ); + perf_top__record_precise_ip(top, iter->he, iter->sample, al->addr); =20 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY), diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e745f3034a0e..470569745abe 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -213,9 +213,10 @@ static int __symbol__account_cycles(struct cyc_hist *c= h, } =20 static int __symbol__inc_addr_samples(struct map_symbol *ms, - struct annotated_source *src, struct evsel *evsel, u64 addr, + struct annotated_source *src, u64 addr, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct symbol *sym =3D ms->sym; long hash_key; u64 offset; @@ -318,7 +319,7 @@ struct annotated_source *symbol__hists(struct symbol *s= ym, int nr_hists) } =20 static int symbol__inc_addr_samples(struct map_symbol *ms, - struct evsel *evsel, u64 addr, + u64 addr, struct perf_sample *sample) { struct symbol *sym =3D ms->sym; @@ -326,8 +327,8 @@ static int symbol__inc_addr_samples(struct map_symbol *= ms, =20 if (sym =3D=3D NULL) return 0; - src =3D symbol__hists(sym, evsel->evlist->core.nr_entries); - return src ? __symbol__inc_addr_samples(ms, src, evsel, addr, sample) : 0; + src =3D symbol__hists(sym, sample->evsel->evlist->core.nr_entries); + return src ? __symbol__inc_addr_samples(ms, src, addr, sample) : 0; } =20 static int symbol__account_br_cntr(struct annotated_branch *branch, @@ -581,16 +582,14 @@ static int annotation__compute_ipc(struct annotation = *notes, size_t size, return 0; } =20 -int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample, - struct evsel *evsel) +int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample) { - return symbol__inc_addr_samples(&ams->ms, evsel, ams->al_addr, sample); + return symbol__inc_addr_samples(&ams->ms, ams->al_addr, sample); } =20 -int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, - struct evsel *evsel, u64 ip) +int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, u64 ip) { - return symbol__inc_addr_samples(&he->ms, evsel, ip, sample); + return symbol__inc_addr_samples(&he->ms, ip, sample); } =20 =20 diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 696e36dbf013..1aa6df7d1618 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -422,8 +422,7 @@ static inline struct annotation *symbol__annotation(str= uct symbol *sym) return (void *)sym - symbol_conf.priv_size; } =20 -int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample, - struct evsel *evsel); +int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample); =20 struct annotated_branch *annotation__get_branch(struct annotation *notes); =20 @@ -433,8 +432,7 @@ int addr_map_symbol__account_cycles(struct addr_map_sym= bol *ams, struct evsel *evsel, u64 br_cntr); =20 -int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, - struct evsel *evsel, u64 addr); +int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, u64 addr); =20 struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists); void symbol__annotate_zero_histograms(struct symbol *sym); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 CBF1B1FE451 for ; Mon, 13 Apr 2026 01:22:51 +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=1776043373; cv=none; b=CTcPOrAvMrJ2KzOz9gZFiqMriRH4YHiQVEm0NbSUlVjijLiZuw4UfDUuuTs63sBWNUjl7L5qk2ZSx29BMcXT0/n2vyUiSpnu0mn8VrLCnQyVwulls7US8QQyiruh9wJH2RIoQITkWP6xAB/IuO9Wnhna161p72tLsohF/Zs++Lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043373; c=relaxed/simple; bh=zocEQ15pqhkgaBM7JLqkF/pDJjGAt5zDiwcYu+1pxdw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=d90xzHOn1cR5ui9EMV33qLQ7GnXUcalxmbxooZZtq19ooS4sbNPnxxjJoGcJJfT6nRwDumoNxalHLcB0tdO+TlgAAQ+NUmigrRxGwTenDX8xCehHBia7ilwuHr0nQWzT4rXOxW3BKAhWbWMUsvbPf23jfJEcjGGu3QGCAMqQslU= 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=M48ft5QY; 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="M48ft5QY" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12c21dbc9c1so12529555c88.0 for ; Sun, 12 Apr 2026 18:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043371; x=1776648171; 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=qFmOnjJwpBpu0n7wKSDPl2Bef0Eg6yPkVeQqUwZtmi0=; b=M48ft5QYHPV5tUR/MyuwM5CRWlxuHruh/pbLwni8Xl2kP+y+3f3zN6HOVzIaSH+Gpj KO8lLEO63x2h0amL7+qXZwp27dA8fXWkAijU+UCqVOBofor4uJ85dPPu+NPEGwqxJFdB I6Hs/OT7Ez0Mj9MWc5JsKqyrCgYTdTkjcBylgYwvUs4kM2n4iq8QydE0yt8ZHchF5RpO bRwmeZ8+TVq/nV6U6MUhtkxl0g3pz8s/HjkhM4IidFAyRTY8+uy5dZPVmxSey+ANfvYx gOT11pEpd+HA2d7MJAPNii1xjG8EsR9frmKfOzLdKYGfUI2NfNot/OlNDNmwICSkauKN afzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043371; x=1776648171; 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=qFmOnjJwpBpu0n7wKSDPl2Bef0Eg6yPkVeQqUwZtmi0=; b=N6uOksNETYa5qW5Fcnn3PFj4WPfhM32UMAJ/TSUaelKgqHrQZXMVyJ9Wwmrwo8WkWy Sj9VYSklGmkOGKK8kyjZnwE8pAiKuKNfttHIAGV3ogO3I2WuAevETPFcPK4sefnYuZIN TjFpXcWpyOvveIJrq3XGPNkEuGYGN++urAXO9yV8xoI9EuKmpSmE5BuMHlLGngiMtRYu MQui7BHNTSxZcg97wy636ownEmvJUToKABhQWqD8Tl20fN7x4/1cp52kbm6YtBJaDkgI L2pCxmwCmqaNq8JtKry8rXuQbfUFVU1aDp4APFAXqxh4dqERUD/D+gfwVOLGBnTKvf3u /GRg== X-Forwarded-Encrypted: i=1; AJvYcCVqPeDvn6eAiO69+8J7lY8ElMvRVcOV4QNEmSbkiKKn/L2zhAZy4cOLE1tQPnhPwqIs+YwXTyfeaJw2ibY=@vger.kernel.org X-Gm-Message-State: AOJu0YyDRIqh/eej+rQ7mnU/5PD/klNnRO1WrTWon+CuNy153roGNLpM VTjN2ikLMVluF5lLvN2pWwa0edqYRj7kLw21vS3hHy5SoXVARDL/3Emc35NRuq2f7TQ+o6SR1Rx FhjzkfYpuKw== X-Received: from dlbvt7.prod.google.com ([2002:a05:7022:3f87:b0:12b:eb91:8863]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4194:b0:119:e56b:c75b with SMTP id a92af1059eb24-12c34f03b09mr6342772c88.32.1776043370806; Sun, 12 Apr 2026 18:22:50 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:03 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-10-irogers@google.com> Subject: [PATCH v11 09/33] perf db-export: Remove evsel from struct export_sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" As the sample contains the evsel avoid the duplication. Remove the evsel from db_export__sample as it can also read from the sample. Signed-off-by: Ian Rogers --- tools/perf/util/db-export.c | 5 ++--- tools/perf/util/db-export.h | 3 +-- tools/perf/util/scripting-engines/trace-event-python.c | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index d991e3168aed..ba54b1119ee6 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -344,14 +344,13 @@ static int db_export__threads(struct db_export *dbe, = struct thread *thread, } =20 int db_export__sample(struct db_export *dbe, union perf_event *event, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al) { struct thread *thread =3D al->thread; struct export_sample es =3D { .event =3D event, .sample =3D sample, - .evsel =3D evsel, .al =3D al, }; struct thread *main_thread; @@ -364,7 +363,7 @@ int db_export__sample(struct db_export *dbe, union perf= _event *event, if (!machine) return -1; =20 - err =3D db_export__evsel(dbe, evsel); + err =3D db_export__evsel(dbe, sample->evsel); if (err) return err; =20 diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h index 23983cb35706..1abbfd398e3a 100644 --- a/tools/perf/util/db-export.h +++ b/tools/perf/util/db-export.h @@ -25,7 +25,6 @@ struct call_return; struct export_sample { union perf_event *event; struct perf_sample *sample; - struct evsel *evsel; struct addr_location *al; u64 db_id; u64 comm_db_id; @@ -96,7 +95,7 @@ int db_export__symbol(struct db_export *dbe, struct symbo= l *sym, int db_export__branch_type(struct db_export *dbe, u32 branch_type, const char *name); int db_export__sample(struct db_export *dbe, union perf_event *event, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al); =20 int db_export__branch_types(struct db_export *dbe); diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 1537122167d5..9e1069ec0578 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -1312,7 +1312,7 @@ static void python_export_sample_table(struct db_expo= rt *dbe, t =3D tuple_new(28); =20 tuple_set_d64(t, 0, es->db_id); - tuple_set_d64(t, 1, es->evsel->db_id); + tuple_set_d64(t, 1, es->sample->evsel->db_id); tuple_set_d64(t, 2, maps__machine(thread__maps(es->al->thread))->db_id); tuple_set_d64(t, 3, thread__db_id(es->al->thread)); tuple_set_d64(t, 4, es->comm_db_id); @@ -1353,7 +1353,7 @@ static void python_export_synth(struct db_export *dbe= , struct export_sample *es) t =3D tuple_new(3); =20 tuple_set_d64(t, 0, es->db_id); - tuple_set_d64(t, 1, es->evsel->core.attr.config); + tuple_set_d64(t, 1, es->sample->evsel->core.attr.config); tuple_set_bytes(t, 2, es->sample->raw_data, es->sample->raw_size); =20 call_object(tables->synth_handler, t, "synth_data"); @@ -1368,7 +1368,7 @@ static int python_export_sample(struct db_export *dbe, =20 python_export_sample_table(dbe, es); =20 - if (es->evsel->core.attr.type =3D=3D PERF_TYPE_SYNTH && tables->synth_han= dler) + if (es->sample->evsel->core.attr.type =3D=3D PERF_TYPE_SYNTH && tables->s= ynth_handler) python_export_synth(dbe, es); =20 return 0; @@ -1517,7 +1517,7 @@ static void python_process_event(union perf_event *ev= ent, /* Reserve for future process_hw/sw/raw APIs */ default: if (tables->db_export_mode) - db_export__sample(&tables->dbe, event, sample, evsel, al, addr_al); + db_export__sample(&tables->dbe, event, sample, al, addr_al); else python_process_general_event(sample, evsel, al, addr_al); } --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 07621221F20 for ; Mon, 13 Apr 2026 01:22:53 +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=1776043378; cv=none; b=bo0B/kTpmWo8aoZVxWJo0sZmkU+MWj9UaF/mfwmVbfT3XRzgM7cTL3vqaBrRtJwSeg/NtaUbGpRqOdOqJTd1lalweOP/JwoWLcPW6bP8aHOPy5Pb6Mo8djfx8XGhyLPgmnY+IuzNMIfa1nLWYMbaqyvQKQCoNYvCnztpjbVj0qU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043378; c=relaxed/simple; bh=O8SeBQYRtZfVbPx2BCDTNpujwAYEkUSpzlGDMnrE3rg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eTrCqPzY3d0jdVE8HY/agpui32Y8BGrMxPyBN9nh0hQavadIuwx/6NUKP5G9kcIFTqOAOfq6sIKDZ76ABMAs/HWAwX4iLNAQTTQPCFjVVE9G20s+qIc+rVCYg3LBkH3LwaPMooZ38OM+Y/W57vQs+ccNArv0fCARkb+UvVKyLZM= 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=q0wfdD1j; 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="q0wfdD1j" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12737f276a2so15039213c88.1 for ; Sun, 12 Apr 2026 18:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043373; x=1776648173; 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=QXDoV621AgmOA9pWlvFBOO3ASn3gi8/J5JlWkTFIGII=; b=q0wfdD1jnw2esndyCrpvZWbciCbk25ArPhv0VkJmWPG3w7C5Z4fXA7gw65ognUBOC8 J/vcY7xpw9GQmrWYEKQ/ld5PvZeesVpoXP7X77fRyn6NUR5Dtl7bdjdXGwlemjM6wC5K 0RnK45S+cGD6y/gnHftvGns33RCuDeZSpSERp0exa/htP4zmxX8ZyNo2j9Gd8dHYWtED bNs6w7qs5fhcieTBsDkwOu6PLlj5x35oCAA3cUvi7Cnw9kFUOysae51u2RBmVDtakXnh XbDxu+glIuLkxHpZliwnLngHisoiCk/DwAhcl9HsZ36Zf7DO3K5PknRBQYX+JrLpfVmC 5vcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043373; x=1776648173; 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=QXDoV621AgmOA9pWlvFBOO3ASn3gi8/J5JlWkTFIGII=; b=ZNAN+Rw9S9HztramYhqDwKLl9AmHr/XRFmtdeGFF0P/0cAtBlAiNa1FJiES8d2TE2c 2QxcvAok6EehwrAgq2HFbCuRnpy/GmGwR6Xnyh+12MQRzA7a0heKihUGdxnrEltZsQTQ BKNL2xsR7CSGkCMToxdOSnz+1V0YbAIZ43wHPgNMFY79K8FxVPa9sYBWbRm/VLloFE6O UWXRwM+oPi8t+qgNCa2m65pTrKXrf1uGjcd2qAjPmUZByDMlYAUdFqaSgNpWWWXUuwMI WyaY6qD2gPE1ZelqObyKyqd3DH4U9nCvGAFPal8mEoLGtTx4EbEjcXtdB1TXoXdFqwR0 sBPA== X-Forwarded-Encrypted: i=1; AJvYcCWzHkBzz+SDeIPdQ279QAt/jgfiu7tVrd9e/oOVx6Li5ws9R6URNqAUpV70hYalHvYRkWNRO2iyufLnlPo=@vger.kernel.org X-Gm-Message-State: AOJu0YxRtEHbCN0N8gaCRizVwLIaovFDrLQevvyb6xTy6sB+o/rRKXbw pwVsS2FqeAtlB/tFEL9+kOaMJz/lrY70n/EGfO9j5ldgt8gnVqobDuns2ry8jVCazpbIJMLIdcA L6BaNGDBukw== X-Received: from dyji40.prod.google.com ([2002:a05:7300:7a28:b0:2d8:dd18:baee]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6725:b0:12a:72af:83d2 with SMTP id a92af1059eb24-12c34e7181amr5988666c88.14.1776043372785; Sun, 12 Apr 2026 18:22:52 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:04 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-11-irogers@google.com> Subject: [PATCH v11 10/33] perf hist: Remove evsel from struct hist_entry_iter From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" struct hist_entry_iter has the sample within it so the evsel is unnecessary. Remove the evsel and update uses. Also remove the evsel from hist__account_cycles and derive it from the sample too. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 10 ++++------ tools/perf/builtin-diff.c | 3 +-- tools/perf/builtin-report.c | 6 ++---- tools/perf/builtin-top.c | 9 +++------ tools/perf/tests/hists_cumulate.c | 1 - tools/perf/tests/hists_filter.c | 1 - tools/perf/tests/hists_output.c | 1 - tools/perf/util/hist.c | 24 ++++++++++++------------ tools/perf/util/hist.h | 3 +-- 9 files changed, 23 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index ee1ba2dc35f4..6f8be9ead43b 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -190,14 +190,12 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, return err; } =20 -static int process_branch_callback(struct evsel *evsel, - struct perf_sample *sample, +static int process_branch_callback(struct perf_sample *sample, struct addr_location *al, struct perf_annotate *ann, struct machine *machine) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .add_entry_cb =3D hist_iter__branch_callback, .hide_unresolved =3D symbol_conf.hide_unresolved, @@ -220,8 +218,8 @@ static int process_branch_callback(struct evsel *evsel, if (a.map !=3D NULL) dso__set_hit(map__dso(a.map)); =20 - hist__account_cycles(sample->branch_stack, al, sample, false, - NULL, evsel); + hist__account_cycles(sample->branch_stack, al, sample, /*nonany_branch_mo= de=3D*/false, + /*total_cycles=3D*/NULL); =20 ret =3D hist_entry_iter__add(&iter, &a, PERF_MAX_STACK_DEPTH, ann); out: @@ -268,7 +266,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, process_branch_stack(sample->branch_stack, al, sample); =20 if (ann->has_br_stack && has_annotation(ann)) - return process_branch_callback(evsel, sample, al, ann, machine); + return process_branch_callback(sample, al, ann, machine); =20 he =3D hists__add_entry(hists, al, NULL, NULL, NULL, NULL, sample, true); if (he =3D=3D NULL) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 82e9e514922b..b4ff863b304c 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -397,7 +397,6 @@ static int diff__process_sample_event(const struct perf= _tool *tool, struct evsel *evsel =3D sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .ops =3D &hist_iter_normal, }; @@ -431,7 +430,7 @@ static int diff__process_sample_event(const struct perf= _tool *tool, } =20 hist__account_cycles(sample->branch_stack, &al, sample, - false, NULL, evsel); + /*nonany_branch_mode=3D*/false, /*total_cycles=3D*/NULL); break; =20 case COMPUTE_STREAM: diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 46d839bbaeef..ff7117c5470f 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -265,10 +265,8 @@ static int process_sample_event(const struct perf_tool= *tool, struct machine *machine) { struct report *rep =3D container_of(tool, struct report, tool); - struct evsel *evsel =3D sample->evsel; struct addr_location al; struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .hide_unresolved =3D symbol_conf.hide_unresolved, .add_entry_cb =3D hist_iter__report_callback, @@ -280,7 +278,7 @@ static int process_sample_event(const struct perf_tool = *tool, return 0; } =20 - if (evswitch__discard(&rep->evswitch, evsel)) + if (evswitch__discard(&rep->evswitch, sample->evsel)) return 0; =20 addr_location__init(&al); @@ -324,7 +322,7 @@ static int process_sample_event(const struct perf_tool = *tool, if (ui__has_annotation() || rep->symbol_ipc || rep->total_cycles_mode) { hist__account_cycles(sample->branch_stack, &al, sample, rep->nonany_branch_mode, - &rep->total_cycles, evsel); + &rep->total_cycles); } =20 rep->total_samples++; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index b4fc991b4eeb..6cf73bb0c7af 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -732,20 +732,18 @@ static int hist_iter__top_callback(struct hist_entry_= iter *iter, EXCLUSIVE_LOCKS_REQUIRED(iter->he->hists->lock) { struct perf_top *top =3D arg; - struct evsel *evsel =3D iter->evsel; =20 if (perf_hpp_list.sym && single) perf_top__record_precise_ip(top, iter->he, iter->sample, al->addr); =20 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY), - NULL, evsel); + /*total_cycles=3D*/NULL); return 0; } =20 static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -831,9 +829,8 @@ static void perf_event__process_sample(const struct per= f_tool *tool, } =20 if (al.sym =3D=3D NULL || !al.sym->idle) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .add_entry_cb =3D hist_iter__top_callback, }; @@ -1211,7 +1208,7 @@ static int deliver_event(struct ordered_events *qe, } =20 if (event->header.type =3D=3D PERF_RECORD_SAMPLE) { - perf_event__process_sample(&top->tool, event, evsel, + perf_event__process_sample(&top->tool, event, &sample, machine); } else if (event->header.type =3D=3D PERF_RECORD_LOST) { perf_top__process_lost(top, event, evsel); diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cum= ulate.c index 606aa926a8fc..267cbc24691a 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -87,7 +87,6 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) addr_location__init(&al); for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .hide_unresolved =3D false, }; diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filte= r.c index cc6b26e373d1..002e3a4c1ca5 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -63,7 +63,6 @@ static int add_hist_entries(struct evlist *evlist, evlist__for_each_entry(evlist, evsel) { for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .ops =3D &hist_iter_normal, .hide_unresolved =3D false, diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_outpu= t.c index 7818950d786e..fa683fd7b1e5 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -57,7 +57,6 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) addr_location__init(&al); for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .ops =3D &hist_iter_normal, .hide_unresolved =3D false, diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f641cf321ace..811d68fa6770 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -935,8 +935,8 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter,= struct addr_location *al { u64 cost; struct mem_info *mi =3D iter->mi; - struct hists *hists =3D evsel__hists(iter->evsel); struct perf_sample *sample =3D iter->sample; + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry *he; =20 if (mi =3D=3D NULL) @@ -968,7 +968,7 @@ static int iter_finish_mem_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { - struct evsel *evsel =3D iter->evsel; + struct evsel *evsel =3D iter->sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry *he =3D iter->he; int err =3D -EINVAL; @@ -1036,9 +1036,9 @@ static int iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_locat= ion *al) { struct branch_info *bi; - struct evsel *evsel =3D iter->evsel; - struct hists *hists =3D evsel__hists(evsel); struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; + struct hists *hists =3D evsel__hists(evsel); struct hist_entry *he =3D NULL; int i =3D iter->curr; int err =3D 0; @@ -1078,7 +1078,7 @@ static int iter_finish_branch_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { - struct evsel *evsel =3D iter->evsel; + struct evsel *evsel =3D iter->sample->evsel; struct hists *hists =3D evsel__hists(evsel); =20 for (int i =3D 0; i < iter->total; i++) @@ -1103,8 +1103,8 @@ iter_prepare_normal_entry(struct hist_entry_iter *ite= r __maybe_unused, static int iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_loc= ation *al) { - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; struct hist_entry *he; =20 he =3D hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL, @@ -1121,8 +1121,8 @@ iter_finish_normal_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { struct hist_entry *he =3D iter->he; - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; =20 if (he =3D=3D NULL) return 0; @@ -1165,9 +1165,9 @@ static int iter_add_single_cumulative_entry(struct hist_entry_iter *iter, struct addr_location *al) { - struct evsel *evsel =3D iter->evsel; - struct hists *hists =3D evsel__hists(evsel); struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; + struct hists *hists =3D evsel__hists(evsel); struct hist_entry **he_cache =3D iter->he_cache; struct hist_entry *he; int err =3D 0; @@ -1224,8 +1224,8 @@ static int iter_add_next_cumulative_entry(struct hist_entry_iter *iter, struct addr_location *al) { - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; struct hist_entry **he_cache =3D iter->he_cache; struct hist_entry *he; struct hist_entry he_tmp =3D { @@ -2826,7 +2826,7 @@ int hists__unlink(struct hists *hists) =20 void hist__account_cycles(struct branch_stack *bs, struct addr_location *a= l, struct perf_sample *sample, bool nonany_branch_mode, - u64 *total_cycles, struct evsel *evsel) + u64 *total_cycles) { struct branch_info *bi; struct branch_entry *entries =3D perf_sample__branch_entries(sample); @@ -2850,7 +2850,7 @@ void hist__account_cycles(struct branch_stack *bs, st= ruct addr_location *al, for (int i =3D bs->nr - 1; i >=3D 0; i--) { addr_map_symbol__account_cycles(&bi[i].from, nonany_branch_mode ? NULL : prev, - bi[i].flags.cycles, evsel, + bi[i].flags.cycles, sample->evsel, bi[i].branch_stack_cntr); prev =3D &bi[i].to; =20 diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index d97a4efb9250..8fb89d81ef06 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -156,7 +156,6 @@ struct hist_entry_iter { int total; int curr; =20 - struct evsel *evsel; struct perf_sample *sample; struct hist_entry *he; struct symbol *parent; @@ -799,7 +798,7 @@ unsigned int hists__overhead_width(struct hists *hists); =20 void hist__account_cycles(struct branch_stack *bs, struct addr_location *a= l, struct perf_sample *sample, bool nonany_branch_mode, - u64 *total_cycles, struct evsel *evsel); + u64 *total_cycles); =20 struct option; int parse_filter_percentage(const struct option *opt, const char *arg, int= unset); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 1B9432222D0 for ; Mon, 13 Apr 2026 01:22:56 +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=1776043380; cv=none; b=YuLDhZB9PzpGUkOXULUjAJ7+R+ZuPll9TJTdthCqL4olA0EuA6BH19KUVOG1j4tfC24e4RDH7QqqaADczA2pauITyMTv5YKH0n4fAdKLxq2myN67xbFcCWQlkl8mPMYkruqGPeKcPIKxdJsCr7stRENbhVGGPz6Nsx79K1yde4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043380; c=relaxed/simple; bh=cLWE7bs+0Cxg9cEMpw2DCvBK22szFSANqxVQJFFr1kA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DRCJHc8aNQiSu3gMOf1e99yF5JtMwsFB6L2aZ5P5JLB34PbxqMMPEwULNGY5OT4rzVHlRR6DNnlQ6UwJ71fibDB1GnXjhZ9ly+XVoviFuvZLLFeXJmnTK/TCU1p/YlHtSQM3rjmoM1PLsDfgOXyhSL1GvfcLlBawBdYRCbYkUuI= 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=Xs++6KqQ; 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="Xs++6KqQ" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1279caef718so16146593c88.1 for ; Sun, 12 Apr 2026 18:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043375; x=1776648175; 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=18PpJMje7yTmFawrKVzMshBAHP9Be4M6fcInXM7pDdU=; b=Xs++6KqQ3StK9HIy+UdVngP2dAqsCUs6fVoEadiIBiiFlT2xNRtg6aaPTIdMhpxSsy 18PvwgorH11b8iM9PmR1WovM/J8HLz6sxpDZ4ESN+JbgO8qpgTeaPcvx6BszIQr6Xl8J rK5DkgDy0taFcwH0tySkqsoCFIGTW2Pfh1ohCLX6lPAU+ejkfJc7lhqkmaS2nCZPpvy6 BoHHx6geERFEh0s8U8duLAbr+xArXdlTyUt6U1/THRzBv6KHVtqSPVQW8IwZsVbM2fs9 X80hKvQ220erqIe0YomxHJ5VghFcinlVpAIpiU6pv64wcmioXeWCiESHdHvYpDp4kPNe Lg8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043375; x=1776648175; 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=18PpJMje7yTmFawrKVzMshBAHP9Be4M6fcInXM7pDdU=; b=olybbM55r9zX+BVj+SSVkkNBmxMk+7NqDvqP5foSxaUUbkGYwgxtMx7NWSG2SOgq/m aePf0WcybLNGud+r+c4TQ3a97/14EMTws48ehAr9E9JXYdNXLEFSYLQkqVgT9sW9AWCx 9nY3htwhE5LtOoTrLCyGB28QIDdcrnFfYXf0NTl8NFUYQLCFYCjvbOOs7yCo6//ybS1b JgJoNySC8E4ib0E9dch4ZFl6fd5smKi7X/qabpqO+QpDUL1qatLkJKvV2LYU49ZzqiK+ vGEIoDUrG/QTGO7Vsgx53LVDMZ5V2Y6aW+EudYNqkOrRiWWrI92VZ0Qv6g/13/0cC6QH iyEg== X-Forwarded-Encrypted: i=1; AJvYcCWWN/enotGAJZHG5iSdmWQTbAP8lo7rI9PifCXD6F6XoVGOOkgVG30xb2ZYQFNkVYfKyeVULYdIwZdNBDU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7l+NXpSBU/ZbZMBkboO0+v0m83+McViUgEaR+yZhsA7/Vc2u2 Z9wlhTCGQVA5jcIcBV0lfLVsiaOhYOghTs5O8LKF3PyuQ0CCYV61oEl7E6P6PEKNYWH7EjrK+dP FOsB3gjZXgw== X-Received: from dlbvv26.prod.google.com ([2002:a05:7022:5f1a:b0:12c:1fa5:ab7c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2229:b0:12a:6b99:1ad4 with SMTP id a92af1059eb24-12c34e899d7mr5747983c88.11.1776043374997; Sun, 12 Apr 2026 18:22:54 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:05 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-12-irogers@google.com> Subject: [PATCH v11 11/33] perf report: Directly use sample->evsel to avoid computing from sample->id From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" In count_lost_samples_events try to avoid searching for the evsel for the sample, just use the variable within the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-report.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ff7117c5470f..3deb21f4d781 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -788,9 +788,11 @@ static int count_lost_samples_event(const struct perf_= tool *tool, struct machine *machine __maybe_unused) { struct report *rep =3D container_of(tool, struct report, tool); - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; + + if (!evsel) + evsel =3D evlist__id2evsel(rep->session->evlist, sample->id); =20 - evsel =3D evlist__id2evsel(rep->session->evlist, sample->id); if (evsel) { struct hists *hists =3D evsel__hists(evsel); u32 count =3D event->lost_samples.lost; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 81D641F0E29 for ; Mon, 13 Apr 2026 01:22:58 +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=1776043380; cv=none; b=u+Fk14PUzQ4xEI8BkFEGFqrgqJqHUnI/Q9rBQxMuKJX3QwFSckBlfkP0iLhUeo0GRAXK7n3rjMT1BSBlV5YLpyVpgcdPZWD9JWd78HY/Cr0ixyEubKtZB/BVU8lJb+tWQTxQ7qg4iba7AtRCAUj7R4aC0YTZM/P7rOraQ502c+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043380; c=relaxed/simple; bh=s03PR3NdhraoAct+z3ztP2wak5yT9JPVUBwMWmour+o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FCm/agEPKAjzF5S9C7/Ta1VsLslF5K104103TjPhofgZ8mCschoNvDzbCaewHfSI15htgU4o4D5as8VaYFu70HkBdP8ajFG+tKWvaB6z3/9dM5apsWJM8aJjYh6PslpADvbxTdlqYsy4z9vKX7hszu72s8fHd55xcJPHv0l3NbU= 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=N2xqSPe9; 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="N2xqSPe9" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127133794b6so16136257c88.1 for ; Sun, 12 Apr 2026 18:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043378; x=1776648178; 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=VnOzocw/zY+37IjMdz6jX9+0KodIGkyYOBbLG+SMCCM=; b=N2xqSPe9uwuorFW12HlekK1HDrZeG5BXevOb2hxOvpOqIFEpCSCcOpGLbxGQYjlm5K 0TFhwuPf6WTN990TG2KSeb2BCqXN9BZqmt1R7E0KZmGvnGZQfXrztbKJhysAxvge7yE6 19uKphHl+1of29A8uk0mpS0o6oSCm4/sMvmvXG0+exd/ZeWcaKKFc0sns9C9pLkL/jNa pZzSYa4B3/7mhbfzzdqvmQbPL+54VFSXsVvn2PW80syuMsYVIaf/GcuRUYTfuwfGSPVU Uv4EuStyBMStH/mP03aW65FjgYyf4Jn+Sop4/ZoSB4IH6OYGruEMFvSZtdCrYcws7A6M zOhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043378; x=1776648178; 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=VnOzocw/zY+37IjMdz6jX9+0KodIGkyYOBbLG+SMCCM=; b=haM0YENpeFj38FNZXHzGsioTi/knWKdNDFVd6vKAjcs3Ez2qfo7KqVWYiEVhZ1dZk0 SCB6on83l/gtt8GiHuxgUDXOUPZavt79Az2/cyfFA+3UC3ps5aI+8iI2bm92BGeQ6DF3 bTiLlYvvGBNdAJYsOmBmouZlPrFovCVHIgdD3ZHUl6YEyrmwvX+EXiWH23FEdZe2GLeh 5e1fz+C56DSMPr+oy3MbIM97t9eGNVrwvpD+sX5kRoDvEYHMGKFOrfxFYOrYGTLtEpTI HgHW4BvhrnShETvqcwFr8r98Nz4XJ8ByPBA10nkWz40rXRdEeI8C9efiXdzaf3J0rX+/ r0IQ== X-Forwarded-Encrypted: i=1; AJvYcCUzWrxajhVeqwJVh5qgh/3ncfGQNjXX5qiWie7HCFdVCY3IkTf/xCQOfiS/YJP7IdsKAxJds9NglsnrW1c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2v3RK3FHC2qCE5CwsasVmN4zOOMXWnsjuFabTBxL+4yThakRi B/5CtaDQ7j3w/yjWyRDeYlv23izsQ73ZK+woinw0c6BvPKlLcB4brynVV91VzxM6fCsmGwUc5uJ 9uvyyKHU80Q== X-Received: from dycue6.prod.google.com ([2002:a05:7300:86:b0:2d7:2fce:704c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2915:b0:12c:3d30:37cd with SMTP id a92af1059eb24-12c3d303aa7mr2038467c88.0.1776043377520; Sun, 12 Apr 2026 18:22:57 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:06 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-13-irogers@google.com> Subject: [PATCH v11 12/33] perf annotate: Don't pass evsel to add_sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 so read it rather than pass it. Update call site. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 6f8be9ead43b..719b36d4eed5 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -232,11 +232,11 @@ static bool has_annotation(struct perf_annotate *ann) return ui__has_annotation() || ann->use_stdio2; } =20 -static int evsel__add_sample(struct evsel *evsel, struct perf_sample *samp= le, - struct addr_location *al, struct perf_annotate *ann, - struct machine *machine) +static int add_sample(struct perf_sample *sample, + struct addr_location *al, struct perf_annotate *ann, + struct machine *machine) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry *he; int ret; =20 @@ -298,7 +298,7 @@ static int process_sample_event(const struct perf_tool = *tool, goto out_put; =20 if (!al.filtered && - evsel__add_sample(sample->evsel, sample, &al, ann, machine)) { + add_sample(sample, &al, ann, machine)) { pr_warning("problem incrementing symbol count, " "skipping event\n"); ret =3D -1; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 AC55821638D for ; Mon, 13 Apr 2026 01:23:00 +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=1776043382; cv=none; b=ERa0BEGkpLhIgRycLSXabNMfxiRglRpddiFP0l5+eJB6Y0zxQB3Pw1pQ+4u5pS7ZXOJOOdtgnI1svRihaPwX2OyS4hEeMLMYOplRgQpdCRmAMcRiL5qhzRYsJ0Jmx3lm2E1od5kqxC08jud/PWt2sr21Z1Ccet77KKqZb/qz2KM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043382; c=relaxed/simple; bh=U21YjZbTLKjhR+W4EfBEee1/yW+4HlS/oTGqe0Nrojw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C1JpMHfbAgRCaPa92W5Zzbfe3vM7/hvZ55BeyK5ue+oS1ClUxugPMvmSIWDGynq/0YnSM7RDKqxPw0lfmUIjS2iN7M3oCEvoHet1SVWKUtovz2sG2yfMZeCss18OazRkFk8ln1A6gNy1AR3bNj3CFE3/aktUa2XL3YX9w1uy8+Y= 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=AKU+VVTX; 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="AKU+VVTX" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0ba59a830so5124391eec.0 for ; Sun, 12 Apr 2026 18:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043380; x=1776648180; 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=CexyOKGLd1wDyUtEXB2mYM32u5jxlu6R2jpDLPNHjCI=; b=AKU+VVTXXoABFgspc+tzfO4QIxDOcA/crQhC4XOPKUkwdWZ2In5LrLcAnisDK/L48e 5uSU7BvJuXiuI+VOP7uZDfv9X6XX32A4UUPnP00MukSWLrV8ZIGSRflVlTrpttk37Nue kieblqeR+knfUvImpr6TXbMrt0T56+XlYT+P4dGDBjYFxfgkhzuMY0kplSvp6Vrdb7zc pwM5aRRcDg+qrdaUSNyoyMdfyZZdGGG/Qfk1m6uOmskdls1IGEdR4ztYx71Ejsv+XHK9 ej8t1z+sshEMCyeok2nLSNI8GUiwiYMBTZaR1z0Ea2LNJcKrG4Ok2t2rAFYppBL4iIIg ghOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043380; x=1776648180; 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=CexyOKGLd1wDyUtEXB2mYM32u5jxlu6R2jpDLPNHjCI=; b=T3zIXO+4SyqX0qHnXXpky6xzI2sbNkPkJbn/wm3KznVEGZrOS/XXzsqSypvlZjxMJx YnlNGok36SvbN5wEBa9QR/7E/K4qWFvIw4TbiS/yuVgSx8mX4osG3X5b2SzshY7KITQT N8wlKr+0kphtlOQbHqzjclNCTjrdz9WyvYYK4fXIKJWFb9wQHfkf1XuIA0cF+BMBTcny o2i5iuHJO4Y3PFWIQ8PPvgI+LiMNjME1PPUmoyb1kQniT+Jr7FEUmcNRPkneWqeobh3v JkA1vrDyFvVX2Jhg74vWlcr7l5nwvdZRFe2iaFeQaqj+HwwYpSdcBOirZ1KuR90crfKi wqNA== X-Forwarded-Encrypted: i=1; AJvYcCXKomOlEsuDTVn4EWpS3Bp9zwPY/4TjwwFqHsPaHnu4MBvwE9Yyrz2GWsnDHU3blnYOKJ6l/UMhNQoEu30=@vger.kernel.org X-Gm-Message-State: AOJu0YzJhf4v9AN0hruby9mco7bX9LUkqnDBp22YbQyn3s5T7hAM/6nU VGU+ljjSkF+X2FG2COBB96SZBInPHbpijKAUy9s616foKDXL35lzEzqgLg1AWHcR2xRV1o4aucT 3FMGg3wgQ/g== X-Received: from dybtn10.prod.google.com ([2002:a05:7300:f10a:b0:2d7:f6a7:dbdb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:2287:b0:2d9:db50:c6a5 with SMTP id 5a478bee46e88-2d9db50cd6amr171436eec.0.1776043379660; Sun, 12 Apr 2026 18:22:59 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:07 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-14-irogers@google.com> Subject: [PATCH v11 13/33] perf inject: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Clean up handling of sample and mmap_evsel when synthesizing build id events and mmap2 events with build ids. For callchain walking and things that expect the evsel to match sample, the sample->evsel shouldn't change. The mmap_evsel should be used when making mmap2 events. Some minor tweaks to synthetic events to be robust to evsel being NULL and to remove an unnecessary branch (as the id sample will be empty) on the evsel. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 52 ++++++++++++++++-------------- tools/perf/util/synthetic-events.c | 30 ++++++++--------- tools/perf/util/synthetic-events.h | 2 -- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index f43c165c3a13..593d3ed5ac47 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -146,14 +146,12 @@ struct event_entry { static int tool__inject_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, const char *filename, struct dso *dso, u32 flags); static int tool__inject_mmap2_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -356,7 +354,6 @@ perf_inject__cut_auxtrace_sample(struct perf_inject *in= ject, typedef int (*inject_handler)(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine); =20 static int perf_event__repipe_sample(const struct perf_tool *tool, @@ -369,7 +366,7 @@ static int perf_event__repipe_sample(const struct perf_= tool *tool, =20 if (evsel && evsel->handler) { inject_handler f =3D evsel->handler; - return f(tool, event, sample, evsel, machine); + return f(tool, event, sample, machine); } =20 build_id__mark_dso_hit(tool, event, sample, machine); @@ -583,11 +580,12 @@ static int perf_event__repipe_common_mmap(const struc= t perf_tool *tool, } =20 if (dso && !dso__hit(dso)) { - struct evsel *evsel =3D evlist__event2evsel(inject->session->evlist, ev= ent); + if (!sample->evsel) + sample->evsel =3D evlist__event2evsel(inject->session->evlist, event); =20 - if (evsel) { + if (sample->evsel) { dso__set_hit(dso); - tool__inject_build_id(tool, sample, machine, evsel, + tool__inject_build_id(tool, sample, machine, /*misc=3D*/sample->cpumode, filename, dso, flags); } @@ -614,23 +612,26 @@ static int perf_event__repipe_common_mmap(const struc= t perf_tool *tool, } if ((inject->build_id_style =3D=3D BID_RWS__MMAP2_BUILDID_ALL) && !(event->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID)) { - struct evsel *evsel =3D evlist__event2evsel(inject->session->evlist, eve= nt); + struct evsel *saved_evsel =3D sample->evsel; =20 - if (evsel && !dso_sought) { + sample->evsel =3D evlist__event2evsel(inject->session->evlist, event); + if (sample->evsel && !dso_sought) { dso =3D findnew_dso(pid, tid, filename, dso_id, machine); dso_sought =3D true; } - if (evsel && dso && - !tool__inject_mmap2_build_id(tool, sample, machine, evsel, + if (sample->evsel && dso && + !tool__inject_mmap2_build_id(tool, sample, machine, sample->cpumode | PERF_RECORD_MISC_MMAP_BUILD_ID, pid, tid, start, len, pgoff, dso, prot, flags, filename)) { /* Injected mmap2 so no need to repipe. */ + sample->evsel =3D saved_evsel; dso__put(dso); return 0; } + sample->evsel =3D saved_evsel; } dso__put(dso); if (inject->build_id_style =3D=3D BID_RWS__MMAP2_BUILDID_LAZY) @@ -835,7 +836,6 @@ static bool perf_inject__lookup_known_build_id(struct p= erf_inject *inject, static int tool__inject_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, const char *filename, struct dso *dso, u32 flags) @@ -859,7 +859,7 @@ static int tool__inject_build_id(const struct perf_tool= *tool, =20 err =3D perf_event__synthesize_build_id(tool, sample, machine, perf_event__repipe, - evsel, misc, dso__bid(dso), + misc, dso__bid(dso), filename); if (err) { pr_err("Can't synthesize build_id event for %s\n", filename); @@ -872,7 +872,6 @@ static int tool__inject_build_id(const struct perf_tool= *tool, static int tool__inject_mmap2_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -895,7 +894,6 @@ static int tool__inject_mmap2_build_id(const struct per= f_tool *tool, =20 err =3D perf_event__synthesize_mmap2_build_id(tool, sample, machine, perf_event__repipe, - evsel, misc, pid, tid, start, len, pgoff, dso__bid(dso), @@ -912,7 +910,7 @@ static int mark_dso_hit(const struct perf_inject *injec= t, const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *mmap_evsel, + struct evsel *mmap_evsel, struct map *map, bool sample_in_dso) { struct dso *dso; @@ -940,9 +938,13 @@ static int mark_dso_hit(const struct perf_inject *inje= ct, dso =3D map__dso(map); if (inject->build_id_style =3D=3D BID_RWS__INJECT_HEADER_LAZY) { if (dso && !dso__hit(dso)) { + /* + * The sample is just read for identifiers which we want + * to match the for the event of the sample. + */ dso__set_hit(dso); tool__inject_build_id(tool, sample, machine, - mmap_evsel, misc, dso__long_name(dso), dso, + misc, dso__long_name(dso), dso, map__flags(map)); } } else if (inject->build_id_style =3D=3D BID_RWS__MMAP2_BUILDID_LAZY) { @@ -950,11 +952,13 @@ static int mark_dso_hit(const struct perf_inject *inj= ect, const struct build_id null_bid =3D { .size =3D 0 }; const struct build_id *bid =3D dso ? dso__bid(dso) : &null_bid; const char *filename =3D dso ? dso__long_name(dso) : ""; + struct evsel *saved_evsel =3D sample->evsel; =20 map__set_hit(map); + /* Creating a new mmap2 event which has an evsel for the mmap event. */ + sample->evsel =3D mmap_evsel; perf_event__synthesize_mmap2_build_id(tool, sample, machine, perf_event__repipe, - mmap_evsel, misc, sample->pid, sample->tid, map__start(map), @@ -964,6 +968,7 @@ static int mark_dso_hit(const struct perf_inject *injec= t, map__prot(map), map__flags(map), filename); + sample->evsel =3D saved_evsel; } } return 0; @@ -974,7 +979,7 @@ struct mark_dso_hit_args { const struct perf_tool *tool; struct perf_sample *sample; struct machine *machine; - const struct evsel *mmap_evsel; + struct evsel *mmap_evsel; }; =20 static int mark_dso_hit_callback(struct callchain_cursor_node *node, void = *data) @@ -1029,7 +1034,6 @@ static int perf_event__inject_buildid(const struct pe= rf_tool *tool, union perf_e static int perf_inject__sched_process_exit(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel __maybe_unused, struct machine *machine __maybe_unused) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); @@ -1049,13 +1053,12 @@ static int perf_inject__sched_process_exit(const st= ruct perf_tool *tool, static int perf_inject__sched_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); struct event_entry *ent; =20 - perf_inject__sched_process_exit(tool, event, sample, evsel, machine); + perf_inject__sched_process_exit(tool, event, sample, machine); =20 ent =3D malloc(event->header.size + sizeof(struct event_entry)); if (ent =3D=3D NULL) { @@ -1074,13 +1077,13 @@ static int perf_inject__sched_switch(const struct p= erf_tool *tool, static int perf_inject__sched_stat(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct event_entry *ent; union perf_event *event_sw; struct perf_sample sample_sw; struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; u32 pid =3D perf_sample__intval(sample, "pid"); int ret; =20 @@ -1445,7 +1448,7 @@ static int synthesize_build_id(struct perf_inject *in= ject, struct dso *dso, pid_ dso__set_hit(dso); =20 return perf_event__synthesize_build_id(&inject->tool, &synth_sample, mach= ine, - process_build_id, inject__mmap_evsel(inject), + process_build_id, /*misc=3D*/synth_sample.cpumode, dso__bid(dso), dso__long_name(dso)); } @@ -2007,7 +2010,6 @@ static int evsel__check_stype(struct evsel *evsel, u6= 4 sample_type, const char * static int drop_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, struct machine *machine __maybe_unused) { return 0; diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 85bee747f4cd..de812a2befbc 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -2252,13 +2252,15 @@ int perf_event__synthesize_build_id(const struct pe= rf_tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, const struct build_id *bid, const char *filename) { union perf_event ev; size_t len; + u64 sample_type =3D sample->evsel ? sample->evsel->core.attr.sample_type = : 0; + void *array =3D &ev; + int ret; =20 len =3D sizeof(ev.build_id) + strlen(filename) + 1; len =3D PERF_ALIGN(len, sizeof(u64)); @@ -2275,23 +2277,17 @@ int perf_event__synthesize_build_id(const struct pe= rf_tool *tool, ev.build_id.header.size =3D len; strcpy(ev.build_id.filename, filename); =20 - if (evsel) { - void *array =3D &ev; - int ret; - - array +=3D ev.header.size; - ret =3D perf_event__synthesize_id_sample(array, evsel->core.attr.sample_= type, sample); - if (ret < 0) - return ret; - - if (ret & 7) { - pr_err("Bad id sample size %d\n", ret); - return -EINVAL; - } + array +=3D ev.header.size; + ret =3D perf_event__synthesize_id_sample(array, sample_type, sample); + if (ret < 0) + return ret; =20 - ev.header.size +=3D ret; + if (ret & 7) { + pr_err("Bad id sample size %d\n", ret); + return -EINVAL; } =20 + ev.header.size +=3D ret; return process(tool, &ev, sample, machine); } =20 @@ -2299,7 +2295,6 @@ int perf_event__synthesize_mmap2_build_id(const struc= t perf_tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -2309,6 +2304,7 @@ int perf_event__synthesize_mmap2_build_id(const struc= t perf_tool *tool, { union perf_event ev; size_t ev_len; + u64 sample_type =3D sample->evsel ? sample->evsel->core.attr.sample_type = : 0; void *array; int ret; =20 @@ -2339,7 +2335,7 @@ int perf_event__synthesize_mmap2_build_id(const struc= t perf_tool *tool, =20 array =3D &ev; array +=3D ev.header.size; - ret =3D perf_event__synthesize_id_sample(array, evsel->core.attr.sample_t= ype, sample); + ret =3D perf_event__synthesize_id_sample(array, sample_type, sample); if (ret < 0) return ret; =20 diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic= -events.h index b0edad0c3100..473a43a78993 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -50,7 +50,6 @@ int perf_event__synthesize_build_id(const struct perf_too= l *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, const struct build_id *bid, const char *filename); @@ -58,7 +57,6 @@ int perf_event__synthesize_mmap2_build_id(const struct pe= rf_tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 D5DD82248AF for ; Mon, 13 Apr 2026 01:23:02 +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=1776043384; cv=none; b=BZ7tBd7g7pWoXCsWHCRLWTe0TTBZv86wPeVgF7IsQO+zK88ppXAWSEIy0RynooZJkkk0nKMz5lw/nW2/6kmtVEzSb8OpS0Nmx6FXFN8O1Td4+ZRItkuFy/LBoprVn9tc3didW5XeamaLMkrHtBIr9uCWcGX8yptkKEiPhI/uTfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043384; c=relaxed/simple; bh=495v7vwy/bxdki64nsuLUq2VLnkw+FqQnijSjVyewWk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kLCEFThR1rYh5AbAV+DbAZUSVR3oshKtFsmETaqziUG+ovZkzOx53XurXBcPmzCjvx59AL59S2GiNzmZoD9lypnqdmNhLPfx5spbQOoQUnqzXVoyylX2wakvVy55+iH1xmsw+KCz/jilkywkG+V0yow6kv206AizcAm0OSqVgzI= 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=dmSxGNxa; 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="dmSxGNxa" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d443c3b094so8550675eec.1 for ; Sun, 12 Apr 2026 18:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043382; x=1776648182; 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=TdCCiiHDf0G456jnJXOkKokcXFcoaXYbGwyy1xI9gh0=; b=dmSxGNxatmZRLgH0q9DZ48sPuK/xs8QwHCNm3OUh5LTIbfXc/3XkXWkgTURF0b4jAQ lhdZmFCEhoCGTQD3JDarSh0YBIxKf3MCAqlE4DMSKJr7n+oPvr0hYUT5+3lw4EtEsQBP UEPZe/srXUY4BGlJc97DA972gfC7p0xjO8CMmtbAcjl7ahXxRV80lRroT9bfsP++dyZZ jyFlCAY49iVIG/xoyEFd6RhtNoFO0iKmxELjmgvyPb1iFHJ845zjKVYpm1HoyyF1W6PB eVa9sEynH618bUjo4Mj7j0xmcoQoNP/5HmIz04EUpmmaOx2BCuQIy+/83SvSbDURGmVG bJzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043382; x=1776648182; 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=TdCCiiHDf0G456jnJXOkKokcXFcoaXYbGwyy1xI9gh0=; b=lYt6jQWjwdyZI9YvH24FIsNsUWKQwyaW+84iHQ0idOyCF36+tqx5+VzGdc6guPk1Fh lJaJMuIsqteNuceF14B7mpztJu0FRresldFqQuogs8oESHnDuvz6hWObG7AVu4d4YrX1 x1MxJNh07RorWsl2VlaFoT/RXM7v1i+9xRin99SghZqF6CCHrWrGc+2hEuWm5DFyxLdn p2uT0Auta8/TvcPu4lOr4yquVwaEcYNpBmO7OSc4qCjpNzMPwRY8e84NbXZJuzXBWwM+ OJAS/WWbx8Ys3WslIY7XEzaF5ZEjdPzMeG8ECM2tmGG2u0J+CY6AMbmfx/FXGtvixiKl XpRA== X-Forwarded-Encrypted: i=1; AFNElJ9c0hjg3MZevpzCXoFr+NdZ4yHcDhThIRdzfBMutGhTNAUMqsZ9aj8SyCF1MyU+YH8Eeb1QTMj6vPy1kgk=@vger.kernel.org X-Gm-Message-State: AOJu0YzPuqahOQtO/e3WqDBL9uBuZmvkP2GZLEtK5ikybyOowSPNrqvX vJqYDoHDFoqdE6srAQj0FgFKq6kWfkxKJLpIZFMMlLIKENb4YLvb1ojsgxLtoQ+W8NEtXcl9wV5 KGugA7h9lUg== X-Received: from dycnr23-n2.prod.google.com ([2002:a05:7300:e9d7:20b0:2d8:6e2f:8c6a]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:8184:b0:2d9:d062:4cb3 with SMTP id 5a478bee46e88-2d9d0624f07mr299361eec.26.1776043381790; Sun, 12 Apr 2026 18:23:01 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:08 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-15-irogers@google.com> Subject: [PATCH v11 14/33] perf kmem: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 2cdc56bc2616..68a39f56204d 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -171,7 +171,7 @@ static int insert_caller_stat(unsigned long call_site, return 0; } =20 -static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sam= ple *sample) +static int evsel__process_alloc_event(struct perf_sample *sample) { unsigned long ptr =3D perf_sample__intval(sample, "ptr"), call_site =3D perf_sample__intval(sample, "call_site"); @@ -198,7 +198,7 @@ static int evsel__process_alloc_event(struct evsel *evs= el, struct perf_sample *s * If the tracepoint contains the field "node" the tool stats the * cross allocation. */ - if (evsel__field(evsel, "node")) { + if (evsel__field(sample->evsel, "node")) { int node1, node2; =20 node1 =3D cpu__get_node((struct perf_cpu){.cpu =3D sample->cpu}); @@ -243,7 +243,7 @@ static struct alloc_stat *search_alloc_stat(unsigned lo= ng ptr, return NULL; } =20 -static int evsel__process_free_event(struct evsel *evsel __maybe_unused, s= truct perf_sample *sample) +static int evsel__process_free_event(struct perf_sample *sample) { unsigned long ptr =3D perf_sample__intval(sample, "ptr"); struct alloc_stat *s_alloc, *s_caller; @@ -751,8 +751,7 @@ static char *compact_gfp_string(unsigned long gfp_flags) return NULL; } =20 -static int parse_gfp_flags(struct evsel *evsel, struct perf_sample *sample, - unsigned int gfp_flags) +static int parse_gfp_flags(struct perf_sample *sample, unsigned int gfp_fl= ags) { struct tep_record record =3D { .cpu =3D sample->cpu, @@ -773,7 +772,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, } =20 trace_seq_init(&seq); - tp_format =3D evsel__tp_format(evsel); + tp_format =3D evsel__tp_format(sample->evsel); if (tp_format) tep_print_event(tp_format->tep, &seq, &record, "%s", TEP_PRINT_INFO); =20 @@ -805,7 +804,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, return 0; } =20 -static int evsel__process_page_alloc_event(struct evsel *evsel, struct per= f_sample *sample) +static int evsel__process_page_alloc_event(struct perf_sample *sample) { u64 page; unsigned int order =3D perf_sample__intval(sample, "order"); @@ -835,7 +834,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp return 0; } =20 - if (parse_gfp_flags(evsel, sample, gfp_flags) < 0) + if (parse_gfp_flags(sample, gfp_flags) < 0) return -1; =20 callsite =3D find_callsite(sample); @@ -876,8 +875,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp return 0; } =20 -static int evsel__process_page_free_event(struct evsel *evsel __maybe_unus= ed, - struct perf_sample *sample) +static int evsel__process_page_free_event(struct perf_sample *sample) { u64 page; unsigned int order =3D perf_sample__intval(sample, "order"); @@ -954,8 +952,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *= sample) return false; } =20 -typedef int (*tracepoint_handler)(struct evsel *evsel, - struct perf_sample *sample); +typedef int (*tracepoint_handler)(struct perf_sample *sample); =20 static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, @@ -973,14 +970,15 @@ static int process_sample_event(const struct perf_too= l *tool __maybe_unused, return -1; } =20 - if (perf_kmem__skip_sample(sample)) + if (perf_kmem__skip_sample(sample)) { return 0; + } =20 dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread__tid= (thread)); =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(evsel, sample); + err =3D f(sample); } =20 thread__put(thread); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 298472264D9 for ; Mon, 13 Apr 2026 01:23:05 +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=1776043386; cv=none; b=PetJBm9Iz0oUNBMeHoy+7WRxM/D8rFALEoqzPsVn6CaDV45Jyd1REEeXs3tq5Pif3xAhAclGTq28ZoWldSrhSDLFLPsIXOZBkhFpgX08XowKPDMYGNPTgfh9eVU52xTjsE//YvPPkUv4khHndnayqvt6QnGlOqwIGopuFyA5g0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043386; c=relaxed/simple; bh=4AitkhbMT/H25fSVWezh726kNN913ChWpH9ozuiIptg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tVo7KeLYltKKT8AvmVfl98AMWhzD0rxU9djjN6Ej+6euoVOI2vAAGctW03uYysCAVmEDDOcFuO1yRNLfLUfT+nGATTR6vDfQ1YZx9i6FYxTQK9sOPRgPnJFLl9PQTDNC9ZnP3MSXHJxXPdR5Zq3vl8f5Gie08ZludMqtp0ASh1M= 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=F7u/LSoU; 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="F7u/LSoU" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c21dbc9c1so12530163c88.0 for ; Sun, 12 Apr 2026 18:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043384; x=1776648184; 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=/r7dggWXwMFscIDTaUN6PdgwhXUpKGlt+pv5j46vEHM=; b=F7u/LSoU3lN9eL4Xl1SEkrXT2nQr29Fh7Ll+4NKkrZ7Szw5mebKCUv+npsEfUnAlWH oiObMbpxQIOEMUe+2Dw0JA7YI35g8DM3JexTLwbMKv/6h2nrvwjep2EyaQ7aY6cm8vXh fh5GceQWtrI298ZLebpP9ETlWJdRsFFYmCZvoShbQNBHcMe7R3bmX3OK6hA7asXsaZUp o/BPcaWTRdz0yrCfPm/+7LpuioHWvgdnPtLUUJ2YJ75GkTPEdUmWt5lDQ4UPhZu5Q2V/ QTO0zXgftmO4UBq0LJ2hX/YZcHjZeDUqr/LbyFcznelr1fM5aAycV/DI+foC3N+KPKVT Kpwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043384; x=1776648184; 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=/r7dggWXwMFscIDTaUN6PdgwhXUpKGlt+pv5j46vEHM=; b=jMOcpRjp2Aqsx8lkg+U0cUytboOYf4G4vWufdMW3bsEx+hUcytSDxMGPVwQQ3p47vg rdkAi8XeFt8vgLj6fCzwG5nv+m+qvzOMPJXKqbA7IrtSeZzpYfO+SON6EAy4I9Gj+/yF zj4JEO1kDCX7LbvsKgYf2T5vIgbu0cDJDWmqvRdls/Rf510uTOeu1R4oguC5y+bYg+HZ d8Pe+51T5g2u9fcSBx6S39vYbB8suQFFi3j7vZUEPw1ooQ/5LW0xWgzJC7P6IcH2wpp/ fJyXyGvhM//gp44kCmVpMaF1a9Qb0eQGeGH5tdalS5i1zx3tIQ6BHiR9A9Ip2Kgw7bCd XTfg== X-Forwarded-Encrypted: i=1; AFNElJ8l9eVnyGSi0iPR2FG6mQgnvFKgTBOPCMr85B1c9P823MVOa7JO35gGnPUa3kQ+PLj43hUkidorCWHj86U=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2f0S/MX3DEeUnosyfX9cKGFA3TJQ1NNyA9u8aWE2Fv4woX7Ju nJkm1BIPH1nFzw0c+zJwlbJcNE873V46Tld4AxqZQ3oikMnN/alE/wxloqjwE6UOigQFNPOKfO5 kEpSmXXmesQ== X-Received: from dybqf21.prod.google.com ([2002:a05:7301:6495:b0:2d8:b1cf:5d12]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:6086:b0:2d2:c60d:4fc2 with SMTP id 5a478bee46e88-2d5871bc5a9mr6736484eec.4.1776043384158; Sun, 12 Apr 2026 18:23:04 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:09 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-16-irogers@google.com> Subject: [PATCH v11 15/33] perf kwork: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Remove the evsel from struct kwork_class. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 74 +++++++++++++------------------------- tools/perf/util/kwork.h | 9 +++-- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 4b312afed830..59a54d11f7fa 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -448,7 +448,6 @@ static int work_push_atom(struct perf_kwork *kwork, struct kwork_class *class, enum kwork_trace_type src_type, enum kwork_trace_type dst_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct kwork_work **ret_work, @@ -458,7 +457,7 @@ static int work_push_atom(struct perf_kwork *kwork, struct kwork_work *work, key; =20 BUG_ON(class->work_init =3D=3D NULL); - class->work_init(kwork, class, &key, src_type, evsel, sample, machine); + class->work_init(kwork, class, &key, src_type, sample, machine); =20 atom =3D atom_new(kwork, sample); if (atom =3D=3D NULL) @@ -507,7 +506,6 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, struct kwork_class *class, enum kwork_trace_type src_type, enum kwork_trace_type dst_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct kwork_work **ret_work) @@ -516,7 +514,7 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, struct kwork_work *work, key; =20 BUG_ON(class->work_init =3D=3D NULL); - class->work_init(kwork, class, &key, src_type, evsel, sample, machine); + class->work_init(kwork, class, &key, src_type, sample, machine); =20 work =3D work_findnew(&class->work_root, &key, &kwork->cmp_id); if (ret_work !=3D NULL) @@ -599,18 +597,16 @@ static void report_update_exit_event(struct kwork_wor= k *work, =20 static int report_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int report_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -618,7 +614,7 @@ static int report_exit_event(struct perf_kwork *kwork, struct kwork_work *work =3D NULL; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (work =3D=3D NULL) return -1; @@ -654,18 +650,16 @@ static void latency_update_entry_event(struct kwork_w= ork *work, =20 static int latency_raise_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int latency_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -673,7 +667,7 @@ static int latency_entry_event(struct perf_kwork *kwork, struct kwork_work *work =3D NULL; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_RAISE, evsel, sample, + KWORK_TRACE_RAISE, sample, machine, &work); if (work =3D=3D NULL) return -1; @@ -812,18 +806,16 @@ static void timehist_print_event(struct perf_kwork *k= work, =20 static int timehist_raise_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int timehist_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -831,7 +823,7 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, struct kwork_work *work =3D NULL; =20 ret =3D work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_RAISE, evsel, sample, + KWORK_TRACE_RAISE, sample, machine, &work, true); if (ret) return ret; @@ -844,7 +836,6 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, =20 static int timehist_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -861,7 +852,7 @@ static int timehist_exit_event(struct perf_kwork *kwork, } =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (work =3D=3D NULL) { ret =3D -1; @@ -895,18 +886,16 @@ static void top_update_runtime(struct kwork_work *wor= k, =20 static int top_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int top_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -915,7 +904,7 @@ static int top_exit_event(struct perf_kwork *kwork, struct kwork_atom *atom; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (!work) return -1; @@ -936,7 +925,6 @@ static int top_exit_event(struct perf_kwork *kwork, =20 static int top_sched_switch_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -944,7 +932,7 @@ static int top_sched_switch_event(struct perf_kwork *kw= ork, struct kwork_work *work; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (!work) return -1; @@ -954,12 +942,11 @@ static int top_sched_switch_event(struct perf_kwork *= kwork, atom_del(atom); } =20 - return top_entry_event(kwork, class, evsel, sample, machine); + return top_entry_event(kwork, class, sample, machine); } =20 static struct kwork_class kwork_irq; static int process_irq_handler_entry_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -967,12 +954,11 @@ static int process_irq_handler_entry_event(const stru= ct perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_irq, - evsel, sample, machine); + sample, machine); return 0; } =20 static int process_irq_handler_exit_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -980,7 +966,7 @@ static int process_irq_handler_exit_event(const struct = perf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_irq, - evsel, sample, machine); + sample, machine); return 0; } =20 @@ -1005,7 +991,6 @@ static void irq_work_init(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1038,7 +1023,6 @@ static struct kwork_class kwork_irq =3D { =20 static struct kwork_class kwork_softirq; static int process_softirq_raise_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1046,13 +1030,12 @@ static int process_softirq_raise_event(const struct= perf_tool *tool, =20 if (kwork->tp_handler->raise_event) return kwork->tp_handler->raise_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_softirq_entry_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1060,13 +1043,12 @@ static int process_softirq_entry_event(const struct= perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_softirq_exit_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1074,7 +1056,7 @@ static int process_softirq_exit_event(const struct pe= rf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } @@ -1133,7 +1115,6 @@ static void softirq_work_init(struct perf_kwork *kwor= k, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1148,7 +1129,7 @@ static void softirq_work_init(struct perf_kwork *kwor= k, } else { num =3D perf_sample__intval(sample, "vec"); work->id =3D num; - work->name =3D evsel__softirq_name(evsel, num); + work->name =3D evsel__softirq_name(sample->evsel, num); } } =20 @@ -1169,7 +1150,6 @@ static struct kwork_class kwork_softirq =3D { =20 static struct kwork_class kwork_workqueue; static int process_workqueue_activate_work_event(const struct perf_tool *t= ool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1177,13 +1157,12 @@ static int process_workqueue_activate_work_event(co= nst struct perf_tool *tool, =20 if (kwork->tp_handler->raise_event) return kwork->tp_handler->raise_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_workqueue_execute_start_event(const struct perf_tool *t= ool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1191,13 +1170,12 @@ static int process_workqueue_execute_start_event(co= nst struct perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_workqueue_execute_end_event(const struct perf_tool *too= l, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1205,7 +1183,7 @@ static int process_workqueue_execute_end_event(const = struct perf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } @@ -1233,7 +1211,6 @@ static void workqueue_work_init(struct perf_kwork *kw= ork __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1267,7 +1244,6 @@ static struct kwork_class kwork_workqueue =3D { =20 static struct kwork_class kwork_sched; static int process_sched_switch_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1275,7 +1251,7 @@ static int process_sched_switch_event(const struct pe= rf_tool *tool, =20 if (kwork->tp_handler->sched_switch_event) return kwork->tp_handler->sched_switch_event(kwork, &kwork_sched, - evsel, sample, machine); + sample, machine); return 0; } =20 @@ -1300,7 +1276,6 @@ static void sched_work_init(struct perf_kwork *kwork = __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1946,7 +1921,6 @@ static int perf_kwork__report(struct perf_kwork *kwor= k) } =20 typedef int (*tracepoint_handler)(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -1961,7 +1935,7 @@ static int perf_kwork__process_tracepoint_sample(cons= t struct perf_tool *tool, if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; =20 - err =3D f(tool, evsel, sample, machine); + err =3D f(tool, sample, machine); } =20 return err; diff --git a/tools/perf/util/kwork.h b/tools/perf/util/kwork.h index db00269b73f2..abf637d44794 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -157,7 +157,6 @@ struct kwork_class { struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -167,19 +166,19 @@ struct kwork_class { =20 struct trace_kwork_handler { int (*raise_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*entry_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*exit_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*sched_switch_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); }; =20 --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 5A9CD22F767 for ; Mon, 13 Apr 2026 01:23:07 +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=1776043389; cv=none; b=ZNeClIEcxlL0FjTubcUJCiMtABkd5q7Ov3P76XqJizOD2KNO6Ju2VHtZ4yXG801MJRtfYCdOunmjPYY+yC+grVjxnypdXqs9up40W8vM2Q04tFZytDge1IGj/2ufz33SiN+fW9i8JuJYXXjI7VAP08PcnGIRTEQE6EeB7sXSevo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043389; c=relaxed/simple; bh=bZFYQTHNj09jPUVsZ8Lp0qqyUMeLrlsOChwSvyrzbj8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Zx92PuOuhZHkv3Pl0Ty1Isldz6OGLBpRWFQfUD5eMQRZinSEw0A9hpAC4fovCMSH7txbAXSY9JPV9nfIK3POOkGZwoCsQmJR1Kej4l/cniY/l4K8LPjVGc9uCUEWgWzkSW4BG5ezFUySmPAu8SOhD9/SMYhlRM90ZZILwHW9Mx4= 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=bmFqWQzQ; 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="bmFqWQzQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c4cfe08c9dso9192004eec.1 for ; Sun, 12 Apr 2026 18:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043387; x=1776648187; 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=G3RKd90CU7bpfJzsVRgdoPzaWpWL8PVovDD5xnBS+Qs=; b=bmFqWQzQkEyIxTMhiNdLO7j5whrAbxmP1CkeXppwC/nBjIRO4t5ThSjCaFZZuE1NRk j6t9Au1E32xJk1J2t02iR+AECCJfPo+ujQ/sZgWNqp+CZlKd8Nva1GVa9/8bfHCD4Sig qd8dJgJ39/rSd1huotk+QFxUYn9v7N/at0wKedROH7Li8tCrV7O0oCbLe7f7KXeOrJds zvA5FqfQOHFr5lqlJ3FYmxY8g25/we4OHG590MCMbZVgcfm48189e557mIrXjyD65p15 S0+YcPatNAXrE3OVgjSxPj4suhBFvyL96VpCmZJVnIu8+Ketl9uHuXLAl2seUoxw2LEh TIHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043387; x=1776648187; 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=G3RKd90CU7bpfJzsVRgdoPzaWpWL8PVovDD5xnBS+Qs=; b=DSX+p3Xn5FNyqwD3Z+soWLL9pEZcpMckVfNdbqVGqsjIWWDeyXfp1JrbH2OVQlxid5 7G3SQVCBie4NRz6W90vNGQ39o85POgLRSKLzI99gQ5Zd+Fri1fFbPvEmjUvnjJz4KEib /0SG6DWuJuYjnOC7Qq75fA6MPC+Pkpl+BHhTHY5JAEKw6k/gFZcb3Cf3x5kv82HhHprK 2nz0609MvPbN0KlQNOsW4xxn9SxjPN9YjNBIsJJfvHFUlERmTihxm3fTEZ+11LnvgOs7 fWq87qWeBTINQT+H03KkUvUxQNOsBawfmfvRDzWI7GBfUE77f6xxAIWaMzczd4mK1eIu pBgQ== X-Forwarded-Encrypted: i=1; AFNElJ/ocp+MybGZs3/Q7zOlIs+mBCltlMcy0Bxd7Slvfy9yQMQcPwNiyW+sAsEKXp0h8FrDoxDqfhIoGkZ/RU4=@vger.kernel.org X-Gm-Message-State: AOJu0YzoLrpTEjsSoadHvUlEdGTccnOwy70zJ8bHV6KiEKdTeeoxLs/F WoAAT8woY30IJ8It35DHMNZ1TbzmLN1bHcGqT3v+ns0ZCtD38GRvXuRjl3EJkBj6dyXjtyeFUGh T4UhwHviX1g== X-Received: from dygg16.prod.google.com ([2002:a05:693c:80d0:b0:2d1:13bb:389c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:bc03:b0:2c8:409:a9bb with SMTP id 5a478bee46e88-2d5834e6014mr6070655eec.0.1776043386287; Sun, 12 Apr 2026 18:23:06 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:10 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-17-irogers@google.com> Subject: [PATCH v11 16/33] perf sched: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 92 ++++++++++++++------------------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index aea14bff7e61..45439e2af8ff 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -129,21 +129,20 @@ typedef int (*sort_fn_t)(struct work_atoms *, struct = work_atoms *); struct perf_sched; =20 struct trace_sched_handler { - int (*switch_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*switch_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 - int (*runtime_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*runtime_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 - int (*wakeup_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*wakeup_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 /* PERF_RECORD_FORK event, not sched_process_fork tracepoint */ int (*fork_event)(struct perf_sched *sched, union perf_event *event, struct machine *machine); =20 int (*migrate_task_event)(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); }; @@ -826,7 +825,7 @@ static void test_calibrations(struct perf_sched *sched) =20 static int replay_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, + struct perf_sample *sample, struct machine *machine __maybe_unused) { const char *comm =3D perf_sample__strval(sample, "comm"); @@ -834,7 +833,7 @@ replay_wakeup_event(struct perf_sched *sched, struct task_desc *waker, *wakee; =20 if (verbose > 0) { - printf("sched_wakeup event %p\n", evsel); + printf("sched_wakeup event %p\n", sample->evsel); =20 printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid); } @@ -847,7 +846,6 @@ replay_wakeup_event(struct perf_sched *sched, } =20 static int replay_switch_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -861,7 +859,7 @@ static int replay_switch_event(struct perf_sched *sched, s64 delta; =20 if (verbose > 0) - printf("sched_switch event %p\n", evsel); + printf("sched_switch event %p\n", sample->evsel); =20 if (cpu >=3D MAX_CPUS || cpu < 0) return 0; @@ -1134,7 +1132,6 @@ static void free_work_atoms(struct work_atoms *atoms) } =20 static int latency_switch_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1204,7 +1201,6 @@ static int latency_switch_event(struct perf_sched *sc= hed, } =20 static int latency_runtime_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1239,7 +1235,6 @@ static int latency_runtime_event(struct perf_sched *s= ched, } =20 static int latency_wakeup_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1300,7 +1295,6 @@ static int latency_wakeup_event(struct perf_sched *sc= hed, } =20 static int latency_migrate_task_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1519,20 +1513,18 @@ static void perf_sched__sort_lat(struct perf_sched = *sched) } =20 static int process_sched_wakeup_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->wakeup_event) - return sched->tp_handler->wakeup_event(sched, evsel, sample, machine); + return sched->tp_handler->wakeup_event(sched, sample, machine); =20 return 0; } =20 static int process_sched_wakeup_ignore(const struct perf_tool *tool __mayb= e_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { @@ -1626,8 +1618,8 @@ static void print_sched_map(struct perf_sched *sched,= struct perf_cpu this_cpu, } } =20 -static int map_switch_event(struct perf_sched *sched, struct evsel *evsel = __maybe_unused, - struct perf_sample *sample, struct machine *machine) +static int map_switch_event(struct perf_sched *sched, struct perf_sample = *sample, + struct machine *machine) { const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"); @@ -1791,7 +1783,6 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel __mayb } =20 static int process_sched_switch_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1810,21 +1801,20 @@ static int process_sched_switch_event(const struct = perf_tool *tool, } =20 if (sched->tp_handler->switch_event) - err =3D sched->tp_handler->switch_event(sched, evsel, sample, machine); + err =3D sched->tp_handler->switch_event(sched, sample, machine); =20 sched->curr_pid[this_cpu] =3D next_pid; return err; } =20 static int process_sched_runtime_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->runtime_event) - return sched->tp_handler->runtime_event(sched, evsel, sample, machine); + return sched->tp_handler->runtime_event(sched, sample, machine); =20 return 0; } @@ -1847,20 +1837,18 @@ static int perf_sched__process_fork_event(const str= uct perf_tool *tool, } =20 static int process_sched_migrate_task_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->migrate_task_event) - return sched->tp_handler->migrate_task_event(sched, evsel, sample, machi= ne); + return sched->tp_handler->migrate_task_event(sched, sample, machine); =20 return 0; } =20 typedef int (*tracepoint_handler)(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -1874,7 +1862,7 @@ static int perf_sched__process_tracepoint_sample(cons= t struct perf_tool *tool __ =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(tool, evsel, sample, machine); + err =3D f(tool, sample, machine); } =20 return err; @@ -2313,11 +2301,10 @@ static void timehist_update_runtime_stats(struct th= read_runtime *r, r->total_pre_mig_time +=3D r->dt_pre_mig; } =20 -static bool is_idle_sample(struct perf_sample *sample, - struct evsel *evsel) +static bool is_idle_sample(struct perf_sample *sample) { /* pid 0 =3D=3D swapper =3D=3D idle task */ - if (evsel__name_is(evsel, "sched:sched_switch")) + if (evsel__name_is(sample->evsel, "sched:sched_switch")) return perf_sample__intval(sample, "prev_pid") =3D=3D 0; =20 return sample->pid =3D=3D 0; @@ -2499,12 +2486,11 @@ static void save_idle_callchain(struct perf_sched *= sched, =20 static struct thread *timehist_get_thread(struct perf_sched *sched, struct perf_sample *sample, - struct machine *machine, - struct evsel *evsel) + struct machine *machine) { struct thread *thread; =20 - if (is_idle_sample(sample, evsel)) { + if (is_idle_sample(sample)) { thread =3D get_idle_thread(sample->cpu); if (thread =3D=3D NULL) pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); @@ -2547,7 +2533,6 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, =20 static bool timehist_skip_sample(struct perf_sched *sched, struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { bool rc =3D false; @@ -2569,7 +2554,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, tr =3D thread__get_runtime(thread); if (tr && tr->prio !=3D -1) prio =3D tr->prio; - else if (evsel__name_is(evsel, "sched:sched_switch")) + else if (evsel__name_is(sample->evsel, "sched:sched_switch")) prio =3D perf_sample__intval(sample, "prev_prio"); =20 if (prio !=3D -1 && !test_bit(prio, sched->prio_bitmap)) { @@ -2579,7 +2564,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, } =20 if (sched->idle_hist) { - if (!evsel__name_is(evsel, "sched:sched_switch")) + if (!evsel__name_is(sample->evsel, "sched:sched_switch")) rc =3D true; else if (perf_sample__intval(sample, "prev_pid") !=3D 0 && perf_sample__intval(sample, "next_pid") !=3D 0) @@ -2590,7 +2575,6 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, } =20 static void timehist_print_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct thread *awakened) @@ -2603,8 +2587,8 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, return; =20 /* show wakeup unless both awakee and awaker are filtered */ - if (timehist_skip_sample(sched, thread, evsel, sample) && - timehist_skip_sample(sched, awakened, evsel, sample)) { + if (timehist_skip_sample(sched, thread, sample) && + timehist_skip_sample(sched, awakened, sample)) { thread__put(thread); return; } @@ -2628,7 +2612,6 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, =20 static int timehist_sched_wakeup_ignore(const struct perf_tool *tool __may= be_unused, union perf_event *event __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { @@ -2637,7 +2620,6 @@ static int timehist_sched_wakeup_ignore(const struct = perf_tool *tool __maybe_unu =20 static int timehist_sched_wakeup_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2663,14 +2645,13 @@ static int timehist_sched_wakeup_event(const struct= perf_tool *tool, /* show wakeups if requested */ if (sched->show_wakeups && !perf_time__skip_sample(&sched->ptime, sample->time)) - timehist_print_wakeup_event(sched, evsel, sample, machine, thread); + timehist_print_wakeup_event(sched, sample, machine, thread); =20 thread__put(thread); return 0; } =20 static void timehist_print_migration_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct thread *migrated) @@ -2691,8 +2672,8 @@ static void timehist_print_migration_event(struct per= f_sched *sched, if (thread =3D=3D NULL) return; =20 - if (timehist_skip_sample(sched, thread, evsel, sample) && - timehist_skip_sample(sched, migrated, evsel, sample)) { + if (timehist_skip_sample(sched, thread, sample) && + timehist_skip_sample(sched, migrated, sample)) { thread__put(thread); return; } @@ -2726,7 +2707,6 @@ static void timehist_print_migration_event(struct per= f_sched *sched, =20 static int timehist_migrate_task_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2751,8 +2731,7 @@ static int timehist_migrate_task_event(const struct p= erf_tool *tool, =20 /* show migrations if requested */ if (sched->show_migrations) { - timehist_print_migration_event(sched, evsel, sample, - machine, thread); + timehist_print_migration_event(sched, sample, machine, thread); } thread__put(thread); =20 @@ -2784,7 +2763,6 @@ static void timehist_update_task_prio(struct perf_sam= ple *sample, =20 static int timehist_sched_change_event(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2808,13 +2786,13 @@ static int timehist_sched_change_event(const struct= perf_tool *tool, if (sched->show_prio || sched->prio_str) timehist_update_task_prio(sample, machine); =20 - thread =3D timehist_get_thread(sched, sample, machine, evsel); + thread =3D timehist_get_thread(sched, sample, machine); if (thread =3D=3D NULL) { rc =3D -1; goto out; } =20 - if (timehist_skip_sample(sched, thread, evsel, sample)) + if (timehist_skip_sample(sched, thread, sample)) goto out; =20 tr =3D thread__get_runtime(thread); @@ -2823,7 +2801,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, goto out; } =20 - tprev =3D evsel__get_time(evsel, sample->cpu); + tprev =3D evsel__get_time(sample->evsel, sample->cpu); =20 /* * If start time given: @@ -2913,7 +2891,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, tr->migrated =3D 0; } =20 - evsel__save_time(evsel, sample->time, sample->cpu); + evsel__save_time(sample->evsel, sample->time, sample->cpu); =20 thread__put(thread); addr_location__exit(&al); @@ -2922,11 +2900,10 @@ static int timehist_sched_change_event(const struct= perf_tool *tool, =20 static int timehist_sched_switch_event(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { - return timehist_sched_change_event(tool, event, evsel, sample, machine); + return timehist_sched_change_event(tool, event, sample, machine); } =20 static int process_lost(const struct perf_tool *tool __maybe_unused, @@ -3174,7 +3151,6 @@ static void timehist_print_summary(struct perf_sched = *sched, =20 typedef int (*sched_handler)(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -3196,7 +3172,7 @@ static int perf_timehist__process_sample(const struct= perf_tool *tool, if (evsel->handler !=3D NULL) { sched_handler f =3D evsel->handler; =20 - err =3D f(tool, event, evsel, sample, machine); + err =3D f(tool, event, sample, machine); } =20 return err; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 7C9B01F8AC5 for ; Mon, 13 Apr 2026 01:23:09 +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=1776043392; cv=none; b=G3hXf4cXV+pBWyOpkWE3tUmIP/0XgeVZxHeM/5DgzCCGR3ET3ovwft1NKn/rPVddshrDTlnhOJKTsmwzMuBgrdbXJDHNtMcEWY1cSh3IHtRCmk+J4CJzHu347EB0l2+raQTnQhh0KmTENuAz9OtMloghbVMwELnPrIOswwmbYnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043392; c=relaxed/simple; bh=Pp17mH3cyPs8wClDF436l++iCbJL7V577K67JvRUutU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=f6W16ZuDjqkUGtAEZP6fJOhYf7MDrnW+v6XsQ9RUfnykoHOIXg0CPdlTQSjRn2eLOwY8EG12hfJQCVp5VYs4OTkOvh3KILY+aRSnrTv5w0EELbyNHYZNcpdZMEOSGFYFYXn9UVLp+ZbuX82UcPCy2pyfIcJLSwQvXqsSsiVIOZU= 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=MmJTd1vs; 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="MmJTd1vs" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d443c3b094so8550856eec.1 for ; Sun, 12 Apr 2026 18:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043389; x=1776648189; 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=Nq7inTgObUkJQusjbZywjT67pBRs4vv79SY6QidR5y4=; b=MmJTd1vstdfU7Bs7UTeffJ9e6c3H2N5vc8r4lpA23ZGXnbvM+IuKfc9jkzAGaRYed5 rUEHl9Rl1lP1lpDFIevkZplRX8OveORPBvwLhTeuvYlOHyCtqGbK4xSQzmNkeAoOuySm jhYbjAuJ0xVue2oVj2tbU6RSOckpl+XI8e5sUXpq+upnyaXPE3gUjpLElxPCIiFd2RJt O6I7cdyQHSl1Dh2YuVzZJH+xsHapWtgaC5yu2h9zS+qCbp9rbULgxFKJiEjs9cTMbpf4 +72kzwzc/PritZUFsxcktxKlCyXdjderI50jT2snlfa3D1XIxkSqnGOE9Oj7/TG1s4Rh BvPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043389; x=1776648189; 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=Nq7inTgObUkJQusjbZywjT67pBRs4vv79SY6QidR5y4=; b=bewePYR0iAzH9rrGGsVvZpgq0rZ7WlOemmvyfJ618YxO0me15ESFkAY4rFGjGUhP5S twLJy17m2bMkOi7QoJenP4smasbTwZZU1eOYN7YyqSiy7RhrNya9elDOlXVudywk0a/t 1b03CuJjYsm5mfvzkFw23JmdIdzxCpC+zhtCzZ3Ejagb9/ZNRFEUrUwFlwZF7c57niYB JaGHV9pMAaKkGi8QLH73ES6M0R2aYBR5lnYhQge2kHjRajgfEwjnhuJu+zaCrorR1SkG /ZPrk8KV5hxCjWFpn27bBlrUBRA6aTUd737sw7ZpnTGyP0tMzIbycT+5ua+bKdQ1VITt +ECw== X-Forwarded-Encrypted: i=1; AFNElJ/N7JerqYhjffNyu39+M/IaN7KOC/A3UVACxJg5/24vGcUJIK7rc2w4IEr7KUfxLMZQQSNxv0EOK4iKM8I=@vger.kernel.org X-Gm-Message-State: AOJu0YxFXR+Or5+f9Unx/6hEQPp9MaftLlP99uzG8HWTqd1ilLhHMsAF xjLhQgUsDcZmk8GaW27pfEJdWH2HJbqHXsHaqh5DTHQsX8HwDVnVXrhssgs4T2V7h3gLzADbqwf TAVwi12tf+A== X-Received: from dycnr23-n2.prod.google.com ([2002:a05:7300:e9d7:20b0:2d8:6e2f:8c6a]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:e82c:b0:2cb:990a:b5e with SMTP id 5a478bee46e88-2d5881acd8dmr5868004eec.15.1776043388353; Sun, 12 Apr 2026 18:23:08 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:11 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-18-irogers@google.com> Subject: [PATCH v11 17/33] perf timechart: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Add missing backtrace argument to tracepoint_handler functions and mark them unused. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 60 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 034e0ba3f9cb..1d24d8738519 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -567,7 +567,6 @@ static const char *cat_backtrace(union perf_event *even= t, } =20 typedef int (*tracepoint_handler)(struct timechart *tchart, - struct evsel *evsel, struct perf_sample *sample, const char *backtrace); =20 @@ -588,8 +587,8 @@ static int process_sample_event(const struct perf_tool = *tool, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - return f(tchart, evsel, sample, - cat_backtrace(event, sample, machine)); + + return f(tchart, sample, cat_backtrace(event, sample, machine)); } =20 return 0; @@ -597,7 +596,6 @@ static int process_sample_event(const struct perf_tool = *tool, =20 static int process_sample_cpu_idle(struct timechart *tchart __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -613,7 +611,6 @@ process_sample_cpu_idle(struct timechart *tchart __mayb= e_unused, =20 static int process_sample_cpu_frequency(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -626,7 +623,6 @@ process_sample_cpu_frequency(struct timechart *tchart, =20 static int process_sample_sched_wakeup(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { @@ -640,7 +636,6 @@ process_sample_sched_wakeup(struct timechart *tchart, =20 static int process_sample_sched_switch(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { @@ -656,7 +651,6 @@ process_sample_sched_switch(struct timechart *tchart, #ifdef SUPPORT_OLD_POWER_EVENTS static int process_sample_power_start(struct timechart *tchart __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -669,7 +663,6 @@ process_sample_power_start(struct timechart *tchart __m= aybe_unused, =20 static int process_sample_power_end(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -679,7 +672,6 @@ process_sample_power_end(struct timechart *tchart, =20 static int process_sample_power_frequency(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -849,8 +841,8 @@ static int pid_end_io_sample(struct timechart *tchart, = int pid, int type, =20 static int process_enter_read(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, @@ -859,8 +851,8 @@ process_enter_read(struct timechart *tchart, =20 static int process_exit_read(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, @@ -869,8 +861,8 @@ process_exit_read(struct timechart *tchart, =20 static int process_enter_write(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, @@ -879,8 +871,8 @@ process_enter_write(struct timechart *tchart, =20 static int process_exit_write(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, @@ -889,8 +881,8 @@ process_exit_write(struct timechart *tchart, =20 static int process_enter_sync(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, @@ -899,8 +891,8 @@ process_enter_sync(struct timechart *tchart, =20 static int process_exit_sync(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, @@ -909,8 +901,8 @@ process_exit_sync(struct timechart *tchart, =20 static int process_enter_tx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, @@ -919,8 +911,8 @@ process_enter_tx(struct timechart *tchart, =20 static int process_exit_tx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, @@ -929,8 +921,8 @@ process_exit_tx(struct timechart *tchart, =20 static int process_enter_rx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, @@ -939,8 +931,8 @@ process_enter_rx(struct timechart *tchart, =20 static int process_exit_rx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, @@ -949,8 +941,8 @@ process_exit_rx(struct timechart *tchart, =20 static int process_enter_poll(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, @@ -959,8 +951,8 @@ process_enter_poll(struct timechart *tchart, =20 static int process_exit_poll(struct timechart *tchart, - struct evsel *evsel __maybe_unused, - struct perf_sample *sample) + struct perf_sample *sample, + const char *backtrace __maybe_unused) { long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.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 E3945238D27 for ; Mon, 13 Apr 2026 01:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043393; cv=none; b=EE0+adHLO5ueZ3mVZdDPOYg7diJ41olnMRMSAy5DcILGJqVIqoWboEpW4j3tfw0T/+dp726cpZSqd0C7TOFax/TGawppXB5E2GTv8mW0AfHPHfUwgIzpsf2W+g/gr2ukE/H+nmJnt+K9tgKoUWOpfBhagMITUwttksurLd3BzzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043393; c=relaxed/simple; bh=ge8wARLhBMwexhRDGIWjn0ZcXZilIlhpkFC0+P8MGis=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r1d1DulU227fKLpkaRL80Txb2LC3kmHXozSe4g7T66vhJY5Akf/cChLXAItg/xjzLv4haWsR1Vj8U++IeSn3CoRjVYd/Ss+1P20UST1mgx6dlJ7Z1Fir5Fwxb/IZJp4XAhtT/Dd0E98y++LZs5NR1lzG8hAhwRMCQt6mOJbJy+w= 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=grhQcXc9; arc=none smtp.client-ip=209.85.216.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="grhQcXc9" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-35d9e67f6dcso7652439a91.1 for ; Sun, 12 Apr 2026 18:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043391; x=1776648191; 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=dApPHTKd9TWmg34UUEla0Pul7we/BjeRSMVVeuYijd4=; b=grhQcXc9t4zIinn9z3HfUWA0v5x8Jh6aDK2PrO5H4VNQWvJ7E+g3OzZ8CcX5sVpJgg F7xoeiNnkv9Pn5kSuNYf+A/6pgSnysJoPa1EHJyMBRTHz3pPgfDwJGIWWQLMN9A8kKhv fobbrvUsXT98SjR5ux3MpfzyEQUGOpH5cFiwCPiajeAZJMJ4NTLyn9sjkGeujMxqwMT+ FxQa+PibuZoqE1h4E/LHgUfkjrhGJF0FrWX1sii+SeaGUfaRi4/tyYTKqsAtTovBOJjj yRgQbmL1jFeJfcbufU6DcGEpdfMj7jDSqH+TBWTYgTzoGNj/AZ3ZydleQyRRcmaXD5f+ +s5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043391; x=1776648191; 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=dApPHTKd9TWmg34UUEla0Pul7we/BjeRSMVVeuYijd4=; b=CBlq/u2+AMSAZ5KWYsctP4JFcJ4zEaZ9LaorHx773ltX9gmzS3USddqiKrsyj/NOA4 +RcEk9gJjuB0LcgnS04fFSTADw7nvId3yDlru9bfHMuu3M1f+bg76h3T4DO4+olc5O4X 2kP+VXAumHELXryGnTyA9z36GO/QEatF0V28XPNSN5c3yX6/e+ad+2WSNsXDfbWCxhfY VrqscsP57Esgk/UWlfq946OpAIzJQ14Yw4TcKIepgb11nVMCTA29On2a+QgxRWbCmrcP 1tLWzyvnkX0wmaPsBCC4BM1EsbyhTbzF/AhyUXP8zYhZEhPQG54sAOX2L4z0lttCwzq6 awHQ== X-Forwarded-Encrypted: i=1; AFNElJ/bbeAxgAe5CKsL3fpv1FBAC4F1BzuWvxtXS9hpESJAnpf7Md9CUtxsv9nuLjLoeO9nSCdmmuMcwuQ+mE8=@vger.kernel.org X-Gm-Message-State: AOJu0YxVK8b7yNW1MONctLz3jWR/MWOn0yMIzJqqibgPgMIL6FSKq7z1 7YCJPN7QVUp36TqrJ1iQyA3mJl/qUmo+9Pn5aLzZxhOL2ej7PIIRQc9CJEdpM+HcdMRfDZFX40G xLbRw+yhQgg== X-Received: from pjhk59.prod.google.com ([2002:a17:90a:4cc1:b0:35f:b313:d194]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1e0c:b0:35d:a3b4:2f00 with SMTP id 98e67ed59e1d1-35e427ea4c3mr12639233a91.8.1776043390780; Sun, 12 Apr 2026 18:23:10 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:12 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-19-irogers@google.com> Subject: [PATCH v11 18/33] perf trace: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 | 52 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1fac167f7436..4e54e75d8ff0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2582,7 +2582,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 @@ -2777,10 +2777,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; @@ -2923,10 +2924,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; @@ -3061,7 +3063,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) { @@ -3122,7 +3124,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) { @@ -3144,7 +3146,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, @@ -3255,10 +3257,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 @@ -3364,7 +3367,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) { @@ -3393,7 +3395,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 { @@ -3409,7 +3411,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); @@ -3434,7 +3436,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: @@ -3446,7 +3449,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) { /* @@ -3458,7 +3460,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 @@ -3478,11 +3480,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); @@ -3624,32 +3626,34 @@ 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 From nobody Mon Jun 15 18:01:56 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 EB6DF23C8C7 for ; Mon, 13 Apr 2026 01:23:13 +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=1776043396; cv=none; b=FvJnJSBnNbv7KfMJDtoyMsfHH/OH7xhyHW3yJQmvuOCwFC9mb4zVHqpYPZQ4dE+pPma/8EcXAzRv1TIvonWx6flg/UC9lB2On5TTOJ2FBh8qrM3prg2EgfA9GW3NW7J0jZVfW2cHeQRw4dEfQRAbp8g6xJtKP0vHdE8DfOayHaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043396; c=relaxed/simple; bh=D6J4TrILnw+Vd5duIq8Xx5kVQzeF4EcLXmzsOqpDjuo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PtzvG3puQ3I1YQjsUS7lSzi9HburYj2hrpAh5vvqYdZERUX/EJH80f8tY0Omx2PMF8eIu5sDiry8oBC28fSI3ktesanf9Oj2kfq+HQnTRXYjvnH3FtieKmwiZ0i1BhC7Ds9VVXD3CJuqn8dhbEdJMQkyvjtbcmfbxhjPHuhixps= 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=Pw+cRVc/; 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="Pw+cRVc/" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c282d6d32so7455509c88.0 for ; Sun, 12 Apr 2026 18:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043393; x=1776648193; 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=DtrEOzqaeIjI7JHJhlF1QdgQmfPYgnjdkQHTwBVDnJc=; b=Pw+cRVc/qd/FUaYSizxVYLzCUIAofyEkazGmgGiuV/wqdjztf1rVoSDuOp0ky//WXF 6V9twxmn/1JWSrKCpImMj+Xw2RmxwMhdlaK+ikzVbFjXz/277wrgDiAzSg4oXINw3iuB ZsLhi5+yvu/pQxMPBOrGVm3o2AWQkeZZGoRm3lnswQZYPjfMUv9t6NgvuOQLRajCZ7vM xZve4FSw5Uqu4/LJZf8yrXwYvc7X0iKrgT62ou3hpez7igDWOwZpEGSdWPnGWkoTohsk ngj91mM99SISZCVLshIBRzZL4o/BsmmU+gxH8/heK+qlTxOJxk7tKKfH0L3tqo3/UxtL 2I8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043393; x=1776648193; 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=DtrEOzqaeIjI7JHJhlF1QdgQmfPYgnjdkQHTwBVDnJc=; b=FlUIjvpywWzd3blZoMeRJ9riTkxlCxtMvs/54k1Bmatcyyq/gGJH/Jry4uLmh73liP JMGckNFAxTCpyK1aYDzprVdgw2Zss2enpHTwQMUq/VBgOVNfSfQ7K6IU0A/YmaqZ8HcU GrjLvA9oa5/Ab7RcE4eXjXidxRSWPfcAmK+o5XxDlG1sjX9DxzCz3SIyXeEVKGnTTQ4N kZlBwr3Kq7/Armmw2qqJPsHQWPKV7RDzWqTxSAfeQTJPRZ2DTM6V1Dn0sBcWqALlHyMQ yya0XxAnKgOXhMGK52hIq69JDCOaFirAYsVwOzLpsfNdfHYXiAA1zUbeST6Qd/cDofac u/Ag== X-Forwarded-Encrypted: i=1; AJvYcCUGTBLUDQRLtJUcUXgcAwdBBUjqjAn9Fjb1yLkuOWNjPhp6kM6+9Fk85e7ayy5l+0M7ZgeXaPJx2Pevin0=@vger.kernel.org X-Gm-Message-State: AOJu0YxtnhlBrPU3PGNvN73zbOwQx/pSMEBi2Z19q6XYlhQX4B0PmZ/5 7eBn1W1I4H5uJxxFnWgmxmguYG21JA+e0fpP7Kp1yXIxN6f93FypdxNeYDnnxcccvDL0n/hXc72 6ZyTFhPbjuA== X-Received: from dlag4.prod.google.com ([2002:a05:701b:2504:b0:12b:e83a:8d31]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:fd01:b0:128:d4be:7438 with SMTP id a92af1059eb24-12c34eeb7f3mr6967038c88.30.1776043392976; Sun, 12 Apr 2026 18:23:12 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:13 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-20-irogers@google.com> Subject: [PATCH v11 19/33] perf evlist: Try to avoid computing evsel from sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" If the sample has an evsel, don't recompute using the sample.id. Signed-off-by: Ian Rogers --- tools/perf/builtin-top.c | 4 +++- tools/perf/tests/mmap-basic.c | 4 +++- tools/perf/tests/switch-tracking.c | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 6cf73bb0c7af..c8474f7ac658 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1164,7 +1164,9 @@ static int deliver_event(struct ordered_events *qe, goto next_event; } =20 - evsel =3D evlist__id2evsel(session->evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(session->evlist, sample.id); assert(evsel !=3D NULL); =20 if (event->header.type =3D=3D PERF_RECORD_SAMPLE) { diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 3313c236104e..a18d84d858aa 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -142,7 +142,9 @@ static int test__basic_mmap(struct test_suite *test __m= aybe_unused, int subtest } =20 err =3D -1; - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); perf_sample__exit(&sample); if (evsel =3D=3D NULL) { pr_debug("event with id %" PRIu64 diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index 22b0302252db..e32331fee277 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -138,7 +138,10 @@ static int process_sample_event(struct evlist *evlist, goto out; } =20 - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); + if (evsel =3D=3D switch_tracking->switch_evsel) { next_tid =3D perf_sample__intval(&sample, "next_pid"); prev_tid =3D perf_sample__intval(&sample, "prev_pid"); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 716C6242D7B for ; Mon, 13 Apr 2026 01:23:16 +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=1776043398; cv=none; b=oRSEOVSCVN16m7tZ8jB7j2ZNLUzxzyDc51z3DRm1n5QqPAgMdyoyy09ZUzPBCtTlCXX2LYTPQVsOL0jdqwzjUFb3rVBoTuloLXHL3+BGmbIrQxqBg4bKwQraXARlIiGJRyID7ZgoxoLvl9R/rS+pQBS33AGJomWvswg8BrIsNi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043398; c=relaxed/simple; bh=aBbjJYLIj3JlgKicEywSIpg8iDK6n1Z+4CENOSS2sBg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AaS35Ii2aiQN4xFfdarT2iDg1yNmTLocj8mCANZcb9dvw69Iy5w3cmoPe7HUbhvwfOBvgnH6R7TGcThmCDbrwhanQsLYwDz9zKiGEu2kXB1bow5w4GIZGCy+K55afpF3IeAdI97KDYvSA3qDcF8dh4nx5cAjc0CeeYCRa3iLAMI= 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=WGEe/2FG; 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="WGEe/2FG" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12c282d6d32so7455600c88.0 for ; Sun, 12 Apr 2026 18:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043396; x=1776648196; 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=kwG1W24uSzD7B/5afwjU1RRK24gDCHemA91ftb3lUmE=; b=WGEe/2FGdCyR6w39++zKKdKx+sVaaMl0nhOvWO3Y1R1CfpzgGTcIyXeMSGQOK3gfCE X6NxCzBxwg1MkBIGcMQt+FJNa1uXM9888H8Wu6rWMPsg2vbV9uK4hmB6g4FOmsHDVfsj wBmZ7VBm2jTihN5y77pKTenxHD1xFm+zaO1tlO9mcx0zsfOFfGkXeZGC6X3KshFuHzqe MFY7IPJVh5ojDVHXkWDOl+AqIKNRBvyHkVJgSmCETMwnxje8WlSPS0A61wd3/19So5AN 1QixiK5+Y2zAph8xJ1ULS4nhZUQsUsZocpcrB47PWd/8ub3+UjIVJ75hn5VdIfzruXqt pnGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043396; x=1776648196; 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=kwG1W24uSzD7B/5afwjU1RRK24gDCHemA91ftb3lUmE=; b=iEHAlW7otCPEhhEqcHZVCmB4s3Gli+2l/RARLPQAID7YQLM3OGbxiEhGR2x17ggDNR ntrdFJZXyNU6VCgLuG+RTTqDefgZE/bEkfgj+x0yctAZHCAazs25O7ryV0D5esPUHE/U PC9MlqkIeCU58iPF1IgJYaV9LwEiW5ebFrB3hyNWGG8CyqoZWs9KZ5/O2GiauL25MHNb 2enu8LzMHOTtUPVRswYsl8UZuwna6FHsRHoHcLcQX1u1INmQg63NXLPe76AJXewRj0/Q r86qon+/xiD3FhK7qAo4m34IFriNJ98terP2RMXkgDjuGeRGqvu1hTwMKVIaW+S2zOHC vbzw== X-Forwarded-Encrypted: i=1; AJvYcCWciu31DEFpB6OM1YNB01uuXSJYv/92RUM8stkh/qNGOOePv/3Nck7fkRGi/TNmzpdpM5Tgd7W4IHpxx2s=@vger.kernel.org X-Gm-Message-State: AOJu0YzQMLnR55vW4olDJjs8bw+ZEAeVgJToXOxG/EHr/0anqYnupy9y MSB6UzgcvN0h+P3SyCLHjX5+KKfzCWJIsHVBXw2cf/KrKfn4Ei402ptupwXRwFsjxGbHP5rxT6P m+8+bIP9LtA== X-Received: from dlcip13.prod.google.com ([2002:a05:7023:c08d:b0:12c:3dd4:fcf5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:60a7:b0:12c:33dd:f9ff with SMTP id a92af1059eb24-12c34ef7bbbmr5885452c88.33.1776043395303; Sun, 12 Apr 2026 18:23:15 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:14 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-21-irogers@google.com> Subject: [PATCH v11 20/33] perf script: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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. Remove the evsel from the struct scripting_context so that the sample version is always accessed. Signed-off-by: Ian Rogers --- tools/perf/builtin-script.c | 12 ++++-- .../util/scripting-engines/trace-event-perl.c | 21 +++++------ .../scripting-engines/trace-event-python.c | 37 ++++++++----------- tools/perf/util/trace-event-scripting.c | 5 +-- tools/perf/util/trace-event.h | 3 -- 5 files changed, 33 insertions(+), 45 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6ea739f20495..c8ecf250577f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2418,12 +2418,13 @@ static bool show_event(struct perf_sample *sample, } =20 static void process_event(struct perf_script *script, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al, struct machine *machine) { struct thread *thread =3D al->thread; + struct evsel *evsel =3D sample->evsel; struct perf_event_attr *attr =3D &evsel->core.attr; unsigned int type =3D evsel__output_type(evsel); struct evsel_script *es =3D evsel->priv; @@ -2715,9 +2716,9 @@ static int process_sample_event(const struct perf_too= l *tool, thread__resolve(al.thread, &addr_al, sample); addr_al_ptr =3D &addr_al; } - scripting_ops->process_event(event, sample, evsel, &al, addr_al_ptr); + scripting_ops->process_event(event, sample, &al, addr_al_ptr); } else { - process_event(scr, sample, evsel, &al, &addr_al, machine); + process_event(scr, sample, &al, &addr_al, machine); } =20 out_put: @@ -2893,9 +2894,12 @@ static int print_event_with_time(const struct perf_t= ool *tool, { struct perf_script *script =3D container_of(tool, struct perf_script, too= l); struct perf_session *session =3D script->session; - struct evsel *evsel =3D evlist__id2evsel(session->evlist, sample->id); + struct evsel *evsel =3D sample->evsel; struct thread *thread =3D NULL; =20 + if (!evsel) + evsel =3D evlist__id2evsel(session->evlist, sample->id); + if (evsel && !evsel->core.attr.sample_id_all) { sample->cpu =3D 0; sample->time =3D timestamp; diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/p= erf/util/scripting-engines/trace-event-perl.c index af0d514b2397..7a18ea4b7d50 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -257,7 +257,6 @@ static void define_event_symbols(struct tep_event *even= t, } =20 static SV *perl_process_callchain(struct perf_sample *sample, - struct evsel *evsel __maybe_unused, struct addr_location *al) { struct callchain_cursor *cursor; @@ -340,7 +339,6 @@ static SV *perl_process_callchain(struct perf_sample *s= ample, } =20 static void perl_process_tracepoint(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al) { struct thread *thread =3D al->thread; @@ -355,6 +353,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, unsigned long long nsecs =3D sample->time; const char *comm =3D thread__comm_str(thread); DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX); + struct evsel *evsel =3D sample->evsel; =20 bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX); dSP; @@ -389,7 +388,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, XPUSHs(sv_2mortal(newSVuv(ns))); XPUSHs(sv_2mortal(newSViv(pid))); XPUSHs(sv_2mortal(newSVpv(comm, 0))); - XPUSHs(sv_2mortal(perl_process_callchain(sample, evsel, al))); + XPUSHs(sv_2mortal(perl_process_callchain(sample, al))); =20 /* common fields other than pid can be accessed via xsub fns */ =20 @@ -426,7 +425,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, XPUSHs(sv_2mortal(newSVuv(nsecs))); XPUSHs(sv_2mortal(newSViv(pid))); XPUSHs(sv_2mortal(newSVpv(comm, 0))); - XPUSHs(sv_2mortal(perl_process_callchain(sample, evsel, al))); + XPUSHs(sv_2mortal(perl_process_callchain(sample, al))); call_pv("main::trace_unhandled", G_SCALAR); } SPAGAIN; @@ -435,9 +434,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, LEAVE; } =20 -static void perl_process_event_generic(union perf_event *event, - struct perf_sample *sample, - struct evsel *evsel) +static void perl_process_event_generic(union perf_event *event, struct per= f_sample *sample) { dSP; =20 @@ -448,7 +445,8 @@ static void perl_process_event_generic(union perf_event= *event, SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpvn((const char *)event, event->header.size))); - XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->core.attr, sizeof(evsel-= >core.attr)))); + XPUSHs(sv_2mortal(newSVpvn((const char *)&sample->evsel->core.attr, + sizeof(sample->evsel->core.attr)))); XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample)))); XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_si= ze))); PUTBACK; @@ -461,13 +459,12 @@ static void perl_process_event_generic(union perf_eve= nt *event, =20 static void perl_process_event(union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { - scripting_context__update(scripting_context, event, sample, evsel, al, ad= dr_al); - perl_process_tracepoint(sample, evsel, al); - perl_process_event_generic(event, sample, evsel); + scripting_context__update(scripting_context, event, sample, al, addr_al); + perl_process_tracepoint(sample, al); + perl_process_event_generic(event, sample); } =20 static void run_start_sub(void) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 9e1069ec0578..8edd2f36e5a9 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -390,7 +390,6 @@ static unsigned long get_offset(struct symbol *sym, str= uct addr_location *al) } =20 static PyObject *python_process_callchain(struct perf_sample *sample, - struct evsel *evsel __maybe_unused, struct addr_location *al) { PyObject *pylist; @@ -651,11 +650,9 @@ static PyObject *get_sample_value_as_tuple(struct samp= le_read_value *value, return t; } =20 -static void set_sample_read_in_dict(PyObject *dict_sample, - struct perf_sample *sample, - struct evsel *evsel) +static void set_sample_read_in_dict(PyObject *dict_sample, struct perf_sam= ple *sample) { - u64 read_format =3D evsel->core.attr.read_format; + u64 read_format =3D sample->evsel->core.attr.read_format; PyObject *values; unsigned int i; =20 @@ -741,11 +738,10 @@ static void regs_map(struct regs_dump *regs, uint64_t= mask, uint16_t e_machine, =20 static int set_regs_in_dict(PyObject *dict, struct perf_sample *sample, - struct evsel *evsel, uint16_t e_machine, uint32_t e_flags) { - struct perf_event_attr *attr =3D &evsel->core.attr; + struct perf_event_attr *attr =3D &sample->evsel->core.attr; =20 int size =3D (__sw_hweight64(attr->sample_regs_intr) * MAX_REG_SIZE) + 1; char *bf =3D NULL; @@ -831,7 +827,6 @@ static void python_process_sample_flags(struct perf_sam= ple *sample, PyObject *di } =20 static PyObject *get_perf_sample_dict(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al, PyObject *callchain) @@ -839,6 +834,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, PyObject *dict, *dict_sample, *brstack, *brstacksym; uint16_t e_machine =3D EM_HOST; uint32_t e_flags =3D EF_HOST; + struct evsel *evsel =3D sample->evsel; =20 dict =3D PyDict_New(); if (!dict) @@ -871,7 +867,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, PyLong_FromUnsignedLongLong(sample->phys_addr)); pydict_set_item_string_decref(dict_sample, "addr", PyLong_FromUnsignedLongLong(sample->addr)); - set_sample_read_in_dict(dict_sample, sample, evsel); + set_sample_read_in_dict(dict_sample, sample); pydict_set_item_string_decref(dict_sample, "weight", PyLong_FromUnsignedLongLong(sample->weight)); pydict_set_item_string_decref(dict_sample, "ins_lat", @@ -928,7 +924,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, if (al->thread) e_machine =3D thread__e_machine(al->thread, /*machine=3D*/NULL, &e_flags= ); =20 - if (set_regs_in_dict(dict, sample, evsel, e_machine, e_flags)) + if (set_regs_in_dict(dict, sample, e_machine, e_flags)) Py_FatalError("Failed to setting regs in dict"); =20 return dict; @@ -936,7 +932,6 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, =20 #ifdef HAVE_LIBTRACEEVENT static void python_process_tracepoint(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { @@ -954,6 +949,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, const char *comm =3D thread__comm_str(al->thread); const char *default_handler_name =3D "trace_unhandled"; DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX); + struct evsel *evsel =3D sample->evsel; =20 bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX); =20 @@ -995,7 +991,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, PyTuple_SetItem(t, n++, context); =20 /* ip unwinding */ - callchain =3D python_process_callchain(sample, evsel, al); + callchain =3D python_process_callchain(sample, al); /* Need an additional reference for the perf_sample dict */ Py_INCREF(callchain); =20 @@ -1051,7 +1047,7 @@ static void python_process_tracepoint(struct perf_sam= ple *sample, PyTuple_SetItem(t, n++, dict); =20 if (get_argument_count(handler) =3D=3D (int) n + 1) { - all_entries_dict =3D get_perf_sample_dict(sample, evsel, al, addr_al, + all_entries_dict =3D get_perf_sample_dict(sample, al, addr_al, callchain); PyTuple_SetItem(t, n++, all_entries_dict); } else { @@ -1070,7 +1066,6 @@ static void python_process_tracepoint(struct perf_sam= ple *sample, } #else static void python_process_tracepoint(struct perf_sample *sample __maybe_u= nused, - struct evsel *evsel __maybe_unused, struct addr_location *al __maybe_unused, struct addr_location *addr_al __maybe_unused) { @@ -1465,7 +1460,6 @@ static int python_process_call_return(struct call_ret= urn *cr, u64 *parent_db_id, } =20 static void python_process_general_event(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { @@ -1488,8 +1482,8 @@ static void python_process_general_event(struct perf_= sample *sample, Py_FatalError("couldn't create Python tuple"); =20 /* ip unwinding */ - callchain =3D python_process_callchain(sample, evsel, al); - dict =3D get_perf_sample_dict(sample, evsel, al, addr_al, callchain); + callchain =3D python_process_callchain(sample, al); + dict =3D get_perf_sample_dict(sample, al, addr_al, callchain); =20 PyTuple_SetItem(t, n++, dict); if (_PyTuple_Resize(&t, n) =3D=3D -1) @@ -1502,24 +1496,23 @@ static void python_process_general_event(struct per= f_sample *sample, =20 static void python_process_event(union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { struct tables *tables =3D &tables_global; =20 - scripting_context__update(scripting_context, event, sample, evsel, al, ad= dr_al); + scripting_context__update(scripting_context, event, sample, al, addr_al); =20 - switch (evsel->core.attr.type) { + switch (sample->evsel->core.attr.type) { case PERF_TYPE_TRACEPOINT: - python_process_tracepoint(sample, evsel, al, addr_al); + python_process_tracepoint(sample, al, addr_al); break; /* Reserve for future process_hw/sw/raw APIs */ default: if (tables->db_export_mode) db_export__sample(&tables->dbe, event, sample, al, addr_al); else - python_process_general_event(sample, evsel, al, addr_al); + python_process_general_event(sample, al, addr_al); } } =20 diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trac= e-event-scripting.c index fa850e44cb46..dc584ac316a3 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -103,12 +103,11 @@ int script_spec__for_each(int (*cb)(struct scripting_= ops *ops, const char *spec) void scripting_context__update(struct scripting_context *c, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { #ifdef HAVE_LIBTRACEEVENT - const struct tep_event *tp_format =3D evsel__tp_format(evsel); + const struct tep_event *tp_format =3D evsel__tp_format(sample->evsel); =20 c->pevent =3D tp_format ? tp_format->tep : NULL; #else @@ -117,7 +116,6 @@ void scripting_context__update(struct scripting_context= *c, c->event_data =3D sample->raw_data; c->event =3D event; c->sample =3D sample; - c->evsel =3D evsel; c->al =3D al; c->addr_al =3D addr_al; } @@ -134,7 +132,6 @@ static int stop_script_unsupported(void) =20 static void process_event_unsupported(union perf_event *event __maybe_unus= ed, struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, struct addr_location *al __maybe_unused, struct addr_location *addr_al __maybe_unused) { diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 914d9b69ed62..720121c74f1d 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -94,7 +94,6 @@ struct scripting_ops { int (*stop_script) (void); void (*process_event) (union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al); void (*process_switch)(union perf_event *event, @@ -124,7 +123,6 @@ struct scripting_context { void *event_data; union perf_event *event; struct perf_sample *sample; - struct evsel *evsel; struct addr_location *al; struct addr_location *addr_al; struct perf_session *session; @@ -133,7 +131,6 @@ struct scripting_context { void scripting_context__update(struct scripting_context *scripting_context, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al); =20 --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 AE9C924E4AF for ; Mon, 13 Apr 2026 01:23:18 +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=1776043399; cv=none; b=TLFeT/YnbG/f/hX9JIWRZQe55keFCWVJeVfuKzCfs3K/HP6ibN6DePjB3HlMqT5Xq2eol6EyMS0DhpWnFjtqSdzlb0Zk3fMWQFzDxbh32O6A7gud4N4IbXJGrwdG5CKn5X9Sz3ueILBz3JL9eBqCx7OlekgJPrN7a+1o+2VjiSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043399; c=relaxed/simple; bh=p3zEoq/bmQlpgAQt3/UAgTTaA4JyI4UO/QfGKpe/qI0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lem/vF3zQPweSwEPOhPe8GgWfKu1WiYPakzUuDcpQnEWBB+OCEhJToa7hYjdjX/wLTlnsuG8Lm5rSomxlrCVptObtwQn3Y7sMVvMr6NpOhzlNxQe0AhowssxRIX3JsF58FySgZW/378h45QecXb7ieqokI2oOxR9pyYMTakXT0o= 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=vBepE8bQ; 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="vBepE8bQ" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c20d5d7f4so13204318c88.1 for ; Sun, 12 Apr 2026 18:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043398; x=1776648198; 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=f8QqzSuQNDbhCu1T3qPBkA3LFLyljNgjUWQeDCGZhEI=; b=vBepE8bQhfwC7goW+EbUo6hG8YrCCma/Bt1L0fkcsFTUkd3onVvuE3FggwEG1M3zEw C+oZZXF5qux2HyzC+y+5RNF4UIqjxWsp2VajA7Sj6ZU4q9D5vnzXc7hHtu66u8uNvxKZ eMOGtU4j4zMo741NXyhMjXIF8nKYdDWqxKgfk44QXpRyKvB9FNByrrMH/9MYYGO2Hv4T bDEm/Ulru3KEMTZzLoc7+ZBCvR7Y1a6Wk/9zGXCAEJ/9TNSbK2IurDKt0579vm1UPxet FrVNvsLM4TGPw4RyS1TP8p83iZRuArBHwunU+vimJZ4yni+/a8ETKijfW7zCIDf8Njfi wp8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043398; x=1776648198; 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=f8QqzSuQNDbhCu1T3qPBkA3LFLyljNgjUWQeDCGZhEI=; b=NiGwXzOkOo7gQu7TO2QTKHQieiNl7Jlyf3W+X/da7HDuqGB9MGoR9ROurUObMk3F6x m5aQeYFLfdJkpuKjcX38xy7DZxKdMRCjH9nBx8he6sN55lC6EHBZvq4Ci0L+92fVURy4 sazQs/G4vvWM9E5JzERm1/+/PuFP7sw10XU52hZ34V1iWJDbAwZLod0JgVmnRlAG0RbL ILVkRoD73NzwTidxJYT+l/08/5jWI3WyzU/z7z+unOrnnRs7dDAXUCAmmbyjsDH6OYvD lL5Tn24ijXFWXt/jJV2QsDnH31zR5jEpy/Z+7juB0ip1SN6oH1z/FC9aQOwNEtmQ2/JQ h3iA== X-Forwarded-Encrypted: i=1; AFNElJ8EdEDUDdttTwMys+M2yLENmepxiUZgasoEbF/1wkh6W1Nx43rBEAVHfYJbQ/c8OU4mw+D0eZ4um7aNsuY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1VCFThUyKaOFheTHmPTx0ZsOqVvfh/B7ftrev5wSpR0jojTb1 rYUkMNKMdZqK1dVJiXKRySS+afDKTv0bQlgm/RNpE8jUKbQWawXGFKLtLUDG9dbXXoQx6uWXkCU jEpp/PAhtWA== X-Received: from dyji40.prod.google.com ([2002:a05:7300:7a28:b0:2d8:dd18:baee]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:8c85:b0:2c5:50fe:c782 with SMTP id 5a478bee46e88-2d5871bc6b9mr6192275eec.3.1776043397595; Sun, 12 Apr 2026 18:23:17 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:15 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-22-irogers@google.com> Subject: [PATCH v11 21/33] perf s390-sample-raw: Don't pass evsel or its PMU with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 its PMU so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/util/s390-sample-raw.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sampl= e-raw.c index c6ae0ae8d86a..52bbca5c56c8 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -222,8 +222,9 @@ static char *get_counter_name(int set, int nr, struct p= erf_pmu *pmu) return result; } =20 -static void s390_cpumcfdg_dump(struct perf_pmu *pmu, struct perf_sample *s= ample) +static void s390_cpumcfdg_dump(struct perf_sample *sample) { + struct perf_pmu *pmu =3D sample->evsel->pmu; size_t i, len =3D sample->raw_size, offset =3D 0; unsigned char *buf =3D sample->raw_data; const char *color =3D PERF_COLOR_BLUE; @@ -284,8 +285,9 @@ static bool s390_pai_all_test(struct perf_sample *sampl= e) return true; } =20 -static void s390_pai_all_dump(struct evsel *evsel, struct perf_sample *sam= ple) +static void s390_pai_all_dump(struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; size_t len =3D sample->raw_size, offset =3D 0; unsigned char *p =3D sample->raw_data; const char *color =3D PERF_COLOR_BLUE; @@ -332,31 +334,32 @@ void evlist__s390_sample_raw(struct evlist *evlist, u= nion perf_event *event, struct perf_sample *sample) { const char *pai_name; - struct evsel *evsel; =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) return; =20 - evsel =3D evlist__event2evsel(evlist, event); - if (!evsel) - return; + if (!sample->evsel) { + sample->evsel =3D evlist__event2evsel(evlist, event); + if (!sample->evsel) + return; + } =20 /* Check for raw data in sample */ if (!sample->raw_size || !sample->raw_data) return; =20 /* Display raw data on screen */ - if (evsel->core.attr.config =3D=3D PERF_EVENT_CPUM_CF_DIAG) { - if (!evsel->pmu) - evsel->pmu =3D perf_pmus__find("cpum_cf"); + if (sample->evsel->core.attr.config =3D=3D PERF_EVENT_CPUM_CF_DIAG) { + if (!sample->evsel->pmu) + sample->evsel->pmu =3D perf_pmus__find("cpum_cf"); if (!s390_cpumcfdg_testctr(sample)) pr_err("Invalid counter set data encountered\n"); else - s390_cpumcfdg_dump(evsel->pmu, sample); + s390_cpumcfdg_dump(sample); return; } =20 - switch (evsel->core.attr.config) { + switch (sample->evsel->core.attr.config) { case PERF_EVENT_PAI_NNPA_ALL: pai_name =3D "NNPA_ALL"; break; @@ -370,8 +373,8 @@ void evlist__s390_sample_raw(struct evlist *evlist, uni= on perf_event *event, if (!s390_pai_all_test(sample)) { pr_err("Invalid %s raw data encountered\n", pai_name); } else { - if (!evsel->pmu) - evsel->pmu =3D perf_pmus__find_by_type(evsel->core.attr.type); - s390_pai_all_dump(evsel, sample); + if (!sample->evsel->pmu) + sample->evsel->pmu =3D perf_pmus__find_by_type(sample->evsel->core.attr= .type); + s390_pai_all_dump(sample); } } --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 10E4921CC71 for ; Mon, 13 Apr 2026 01:23:20 +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=1776043402; cv=none; b=YP6LIEV/IvBTHP2rBja8jF2ctEG9CGAqNeaRDWDBSJ/JobHq4qTH9b9XzGFFru3YmN7ncoE44hoCMCVUsg8J7P456IP6+hTtVuiTu7R7GUafLz8yNUnHkLCzxmaA/o2md8pVaOpdj2SRNFg3JFO7a8Lxjz5//jtpE0OS9SeSgqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043402; c=relaxed/simple; bh=X3d+bv/RmpzHuDPVyAZXrbt4fTvCbWhYts+FzU9xRfA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AkO5FvckjLKFqOZUM0voOtIhVuTceD524E+Mwf7s9XkCZU8fXwI1oJ2KQqLfNDBTyp5ClYIOTIn+mC5dOXyTAL9KNXC6QwIqXuLqQHkJMOi77/1c62r5EZfCGu/kntBmzTKD+SKj+8OnJA0ViVewdF6AMaJwfnc+OrcpxG55Swk= 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=KqaW+ypB; 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="KqaW+ypB" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2d889997495so2295729eec.0 for ; Sun, 12 Apr 2026 18:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043400; x=1776648200; 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=fyJqf5DqEvyRM5sRLSS8mIeWVbUiTjGftiY+F4po8Hs=; b=KqaW+ypBr+o5n7pSfatbkxjwC/J+oO1OXydfRb7PVUPzuPFWXjdEQqd6Zp+PyjQIno uxf69B5Yd51u/6a5l+GQZT9ngyUZkPEolUM0Yi3eg27mr0KAF2/QOd19adXugz8Cy4gB ZbCjVFWu4ZqjjiKXlA6Utaq3vBQhNQhb28ASkWbmOsO+rWv2kGN+LK/7uEqjY0oW4jYG kNu5rF5O1KdmyJYuBxIYV7i8k04ydpfstxiEu86/PRuqiaunQZ2jtI6ulUwMfoze6mD8 D1XxM0PoA00+qQEfv0UYyDwj+2X0J8j2UeTxQq+ppJbR0zqrHlcv62bEQjbXGmoHRXcW IL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043400; x=1776648200; 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=fyJqf5DqEvyRM5sRLSS8mIeWVbUiTjGftiY+F4po8Hs=; b=VbIQfrVxJM5x3s+gdq3WFi294waXtiCNRakue0LZfozYWxk8H897GFVs8jTxcnz6yM agj0BliozaXaZmBKEBbBclUDKXJDUAoJZpG+CXuYtNbOZYKK5YIzlzqKFeGt2OmQ0tgr Qc2VE1wSvxgwBPXcrtw91zOnfTOUMauHThOYKfviTIhs73epAM2oVnl8BNeAH95v+bV0 7NgxtC4ChUuuoSBhTNR0zWlxsS5g1HkxwIw0DUtbG08A6e2CKaDA1v1LRz61QX1WReBM WNkmxmdn7zIRgTYLtLbV961sXJJMN8EFIa1Nvl83hZmNUHeuuuJX29zB6f9vQWMMX22b 7SnQ== X-Forwarded-Encrypted: i=1; AFNElJ/4kYCiSu16lO3+Jm0hoP2lHB7+fv3EqQrAiOwl7BUXYPFHbjmWxUtigU1yDB7dX5Q3yOl17tDZ1Bj8Mzk=@vger.kernel.org X-Gm-Message-State: AOJu0YzVc/JeuDAIwefqOfN70JOAnMybHyNWMDcsYlmqGVaGmn+WplnL N8pOeWOtVjNz4Zuvzrq3lbPhD/4SCOOF6mukKQgKADbzuMz6g35FYktsd6AQWK2GlZ7S2SAyD0W 3emohASI5vg== X-Received: from dyclx4.prod.google.com ([2002:a05:693c:2184:b0:2d1:f2ee:2849]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:df05:b0:2d2:d7b7:5c70 with SMTP id 5a478bee46e88-2d5881b0358mr7559771eec.15.1776043399642; Sun, 12 Apr 2026 18:23:19 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:16 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-23-irogers@google.com> Subject: [PATCH v11 22/33] perf evsel: Don't pass evsel with sample From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Arrange for the sample to contain the evsel and so it is unnecessary to pass the evsel as well. This is done for uniformity, although parsing of the sample is arguably a special case. Add bound checks in perf_evsel__parse_id_sample by switching to using an index and checking it doesn't become negative. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 61 +++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ee30e15af054..bb48568b8101 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3003,52 +3003,62 @@ int evsel__open_per_thread(struct evsel *evsel, str= uct perf_thread_map *threads) return ret; } =20 -static int perf_evsel__parse_id_sample(const struct evsel *evsel, - const union perf_event *event, +static int perf_evsel__parse_id_sample(const union perf_event *event, struct perf_sample *sample) { + const struct evsel *evsel =3D sample->evsel; u64 type =3D evsel->core.attr.sample_type; const __u64 *array =3D event->sample.array; bool swapped =3D evsel->needs_swap; union u64_swap u; - - array +=3D ((event->header.size - - sizeof(event->header)) / sizeof(u64)) - 1; + int i =3D ((event->header.size - sizeof(event->header)) / sizeof(u64)) - = 1; =20 if (type & PERF_SAMPLE_IDENTIFIER) { - sample->id =3D *array; - array--; + if (i < 0) + return -EFAULT; + + sample->id =3D array[i--]; } =20 if (type & PERF_SAMPLE_CPU) { - u.val64 =3D *array; + if (i < 0) + return -EFAULT; + + u.val64 =3D array[i--]; if (swapped) { /* undo swap of u64, then swap on individual u32s */ u.val64 =3D bswap_64(u.val64); u.val32[0] =3D bswap_32(u.val32[0]); } - sample->cpu =3D u.val32[0]; - array--; } =20 if (type & PERF_SAMPLE_STREAM_ID) { - sample->stream_id =3D *array; - array--; + if (i < 0) + return -EFAULT; + + sample->stream_id =3D array[i--]; } =20 if (type & PERF_SAMPLE_ID) { - sample->id =3D *array; - array--; + if (i < 0) + return -EFAULT; + + sample->id =3D array[i--]; } =20 if (type & PERF_SAMPLE_TIME) { - sample->time =3D *array; - array--; + if (i < 0) + return -EFAULT; + + sample->time =3D array[i--]; } =20 if (type & PERF_SAMPLE_TID) { - u.val64 =3D *array; + if (i < 0) + return -EFAULT; + + u.val64 =3D array[i--]; if (swapped) { /* undo swap of u64, then swap on individual u32s */ u.val64 =3D bswap_64(u.val64); @@ -3058,7 +3068,6 @@ static int perf_evsel__parse_id_sample(const struct e= vsel *evsel, =20 sample->pid =3D u.val32[0]; sample->tid =3D u.val32[1]; - array--; } =20 return 0; @@ -3244,15 +3253,18 @@ int evsel__parse_sample(struct evsel *evsel, union = perf_event *event, =20 data->deferred_cookie =3D event->callchain_deferred.cookie; =20 - if (evsel->core.attr.sample_id_all) - perf_evsel__parse_id_sample(evsel, event, data); - + if (evsel->core.attr.sample_id_all) { + if (perf_evsel__parse_id_sample(event, data)) + goto out_efault; + } return 0; } =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) { - if (evsel->core.attr.sample_id_all) - perf_evsel__parse_id_sample(evsel, event, data); + if (evsel->core.attr.sample_id_all) { + if (perf_evsel__parse_id_sample(event, data)) + goto out_efault; + } return 0; } =20 @@ -3614,12 +3626,13 @@ int evsel__parse_sample_timestamp(struct evsel *evs= el, union perf_event *event, =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) { struct perf_sample data =3D { + .evsel =3D evsel, .time =3D -1ULL, }; =20 if (!evsel->core.attr.sample_id_all) return -1; - if (perf_evsel__parse_id_sample(evsel, event, &data)) + if (perf_evsel__parse_id_sample(event, &data)) return -1; =20 *timestamp =3D data.time; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 848EF225A38 for ; Mon, 13 Apr 2026 01:23:23 +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=1776043405; cv=none; b=fJaW02GIw41M9RIPh6bEVGYDk7tt2hHKo3evRbTIKoOh/Z62/xYsyX6Q7nywFgVZM2sgeWoR1u1XTg0isqMytmlenj8qrrtsycG3LZlAyqklSgPspKjjm3tZGQnWNuf3igQTEaW/Q57TQhRGSTySFfo8kG+5bsvQ6Q6fegZ9j9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043405; c=relaxed/simple; bh=/TJHliXZNcJc0WMzmCn1uj85dssMOv30WvsxQWbGYts=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=j6p5hzxywLBmfhWnaXmQ6tUmg++/cuiRMZSb2LGD6hVaRtwA3CKwhykJFZCgqC/Rz4Pz0l0f1mOuZevmjhS9kHiDIkkSvUKmg+dCXIo9/+PxDtiS/KUIVPrZD/VmvSI+TL1xC8xnqyTaQ9XuhSmEtdt0BAO8BXHdpUq2nrd7FrU= 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=Ho9+dIaU; 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="Ho9+dIaU" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d70f60aff7so5830911eec.0 for ; Sun, 12 Apr 2026 18:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043403; x=1776648203; 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=1ky2umPzRcxH/XBrATEo/kk5mztVaDExoaZNmlerHag=; b=Ho9+dIaU1j4N+OCKXy/QjT0MgW3VnEs4SuMt8lsg82c+auG0OK58RaJpJfImC7N8vZ sd27t7KAzJ7X7tw1t1iOdJdLMfGPTTSXRfYCGqApKO23onrHEUNLiuwF8t9qKTLR67OR /DFJeS4sYt/cpSKBUTx/OXzVb8zChXvcznaY5Mi8eJFG9h+qBsvXAjpJ1g/McsZsiKpY ujvF8SAsMbk51c114biiR71TQaL+hNf2K/X2/ph9ZesUm4IUvVfCDWppzlsmiOVCZjrE OmKO11coo/sqXMmrJFh8TinD58PA/t1y3B7SyuI9PsfcY0TSwsWNteAKQoahPcUCOO2a rE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043403; x=1776648203; 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=1ky2umPzRcxH/XBrATEo/kk5mztVaDExoaZNmlerHag=; b=s1RV3qGsEVruszJ0Bugd0jUVH1CVl4v7TBl7OKw7QnZTqNSh2LnOPVb+z6gIu2Ybo8 zozim26OE+WN8d2HU7Itp0BrZnCww9rY+3CbLPVxMVE/KLAXkCljmM8utDvPDNlnUlVa LrN0Nt6gYFQuw04ck2SDHPZggi3UNKU8Hem/0UIAk85I/BW+JIvaIbI8mocVK1k+KmLf 2Y9x5wTUamJ+G5ngBKv6TZRmIYLh+pUqPSyUdxeGtdVpuKVCPcw/xIB+BQs62E23BNvt mWJyjDca2GIvD06DrLF3ehifkm3VeTN57hj7Bhmxgjq5Asu9U158BvVzFadKukJ65S9r DeLw== X-Forwarded-Encrypted: i=1; AFNElJ/VWomvW3W/vBViL3ih5NoLR5e5mEGPfkbZivPUG2Y2CWh5zB45VGiceW8Wm6H3rs0WpLkcCBruyUXgg1g=@vger.kernel.org X-Gm-Message-State: AOJu0YxbDWJHD3qZdYt2tkq6gcceTBO10DsxOLoA4npGtS8LBoKCW+NU R5O9ht7kAZhED9hJG/6qIPEIo+3oJMjGYd3m3khHkdMGVzPwAkDG6o8zE7GJnGaBiqDr3IBN+BR pjqN27zjyDw== X-Received: from dybts2.prod.google.com ([2002:a05:7300:f582:b0:2d6:703e:417d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:7495:b0:2ca:e4f2:31ff with SMTP id 5a478bee46e88-2d5873adf3emr7247555eec.6.1776043402318; Sun, 12 Apr 2026 18:23:22 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:17 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-24-irogers@google.com> Subject: [PATCH v11 23/33] perf lock: Constify trace_lock_handler variables From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Structs don't change and so constify. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index b6533483ba64..89a40d385b27 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1179,7 +1179,7 @@ static int report_lock_contention_end_event(struct pe= rf_sample *sample) =20 /* lock oriented handlers */ /* TODO: handlers for CPU oriented, thread oriented */ -static struct trace_lock_handler report_lock_ops =3D { +static const struct trace_lock_handler report_lock_ops =3D { .acquire_event =3D report_lock_acquire_event, .acquired_event =3D report_lock_acquired_event, .contended_event =3D report_lock_contended_event, @@ -1188,13 +1188,13 @@ static struct trace_lock_handler report_lock_ops = =3D { .contention_end_event =3D report_lock_contention_end_event, }; =20 -static struct trace_lock_handler contention_lock_ops =3D { +static const struct trace_lock_handler contention_lock_ops =3D { .contention_begin_event =3D report_lock_contention_begin_event, .contention_end_event =3D report_lock_contention_end_event, }; =20 =20 -static struct trace_lock_handler *trace_handler; +static const struct trace_lock_handler *trace_handler; =20 static int evsel__process_lock_acquire(struct perf_sample *sample) { --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 83FC8273D8F for ; Mon, 13 Apr 2026 01:23:25 +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=1776043406; cv=none; b=KF/huuvVhvNBrQcWYmmYUUT3RatmhYTK0gcFQtE7CydW6GPRvZkER1UAXE6/OJZCvIr1N1vIkr1m/vCu/dR4ill2Z+APKiCCR7l7zv53WRwwyHI5V73vjJ7NyyNZ7xrMH7jMJTpYZ48B8p8y1HiMYYoaXO7mbPr/K/fwCXeL+yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043406; c=relaxed/simple; bh=+R1TjR7D/n+SVy+MvcOVgKHmNVERa5SqQsXwquU4Gqc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aIS5IIfOxAk4yO1ypyL1A08nWDNorZJoaVloky588Lce3Pe2stVAf/l+HMLVjgMFSAnrVPMcJyduKz7niTGJ8YRdmlFoERG9GOuv7s1BBwOO05M67ENDUYs4v3HRR6TZ1tZ4oOZoAffZ2OdbJKMFGJ5snAKuevWO84kNpDt0cto= 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=aruvWU3f; 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="aruvWU3f" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12bf9974587so5571550c88.0 for ; Sun, 12 Apr 2026 18:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043405; x=1776648205; 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=I6cwCi85nL+UMzH5dHBjsjgh7zFGt951FXHMXIOHqdc=; b=aruvWU3f5RJfrQ7Fpsp5kNoVwvW2SkPtuvqprWP+BKYdh0epXLLeRtzNIy0YyT6t9h HRyxROjkJ9KwLuowKQRkRSpS6lYnkz/5idJw/rLNQ22UXJXdKKROWtqEVfc5cTR8Q7wW AyyPOXtuCB50bXQ0XNiSwumWF4tLrIJ/CmUs5TSRx7p0krl10HUve+vCZoj6CvWvhwoL 1fPsfWtbGk/29mmBaIvsN8JrqumAGyAIJrsORCpiYEMpFATXZsgqgBLl1cNxv55qZfpe z4p2AeDXt4f6Oj92OwUhs+s8ROgqt5cqrWk2yK6BQphlxocN9sRpyNGmGsJQ4K2y9SyV NqQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043405; x=1776648205; 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=I6cwCi85nL+UMzH5dHBjsjgh7zFGt951FXHMXIOHqdc=; b=EGIooy5LyE3w55w4McP24GLDvO02TrydZ/7vmWw/5LlsIe5XEA8t939hkESQHxjzSb cbB2FCXrDz/+JvpN5nOUDjZym9YW4hYjfjA/sqknzoBhMVO5jxbn7PgnvQxmTSrafl4M /NlzcSX07p0KXggvkJqW0yC0F9Ubjt5+yzYm0Zto1SRnj4mlZvy5tew5F5s4aXb1OAb5 Xb2RsjO0zG2KDQ3vCwih6euFmBsqkVUMiKLwIAWKrROQMy2DgWwXZJ+DzFTwwtkKiEfV fcKvFX+CQV6tYv3gfaqmONdDRVb6EO1LwCSxhhLmTNQsSq19s6zwj0PPBdoeXJBM0MLL rM+Q== X-Forwarded-Encrypted: i=1; AJvYcCVM07kYj0yeQlgiKd01VMEWylj7IoGYTN+6Ahqo7CswRhyZFlg1SvwABpzCxL2uRIw81Jq5f7yhlaMc/qQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz41/o9/Eq/52H0VCT/2f5BS6mMN3fNjg5dmHi0QtyEGxjQa05I zzZrWLCawSDIATJEVmLYF6F4XfRtUXbeozWqPixyadMPP2ahtyLJHI9zszlOWGlkSWDV2U1wHAX 0qU1947+8oQ== X-Received: from dlbur20.prod.google.com ([2002:a05:7022:ea54:b0:12b:fc23:6fcb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:411:b0:128:c9fa:4c32 with SMTP id a92af1059eb24-12c34eec551mr6848923c88.28.1776043404371; Sun, 12 Apr 2026 18:23:24 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:18 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-25-irogers@google.com> Subject: [PATCH v11 24/33] perf lock: Avoid segv if event is missing a callchain From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Sashiko recognized a potential segv if a sample is missing a callchain. Return NULL for this case just as a memory allocation failure does. In the verbose pr_debug output describe the error and rather than fail the entire file just skip the event (return 0 rather than -ENOMEM). Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 89a40d385b27..064b3aa4bad7 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -938,9 +938,16 @@ static u64 *get_callstack(struct perf_sample *sample, = int max_stack) u64 i; int c; =20 + if (!sample->callchain) { + pr_debug("Sample unexpectedly missing callchain\n"); + return NULL; + } + callstack =3D calloc(max_stack, sizeof(*callstack)); - if (callstack =3D=3D NULL) + if (callstack =3D=3D NULL) { + pr_debug("Failed to allocate callstack\n"); return NULL; + } =20 for (i =3D 0, c =3D 0; i < sample->callchain->nr && c < max_stack; i++) { u64 ip =3D sample->callchain->ips[i]; @@ -1059,7 +1066,7 @@ static int report_lock_contention_begin_event(struct = perf_sample *sample) if (needs_callstack()) { u64 *callstack =3D get_callstack(sample, max_stack_depth); if (callstack =3D=3D NULL) - return -ENOMEM; + return 0; =20 if (!match_callstack_filter(machine, callstack, max_stack_depth)) { free(callstack); --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.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 6CB1E277C9E for ; Mon, 13 Apr 2026 01:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043408; cv=none; b=gwyTYwREIDVtU0FGyPMYiKp/FQB2rp0rv24hPCqKexCmZuSWsYQYPv43IdhRxfnbIndxm3GNRChlPCmT3A7IBpposLR9GGdZUfnY37z6S9MaGakYtBIr34sgAuXtlW0KyWyQN0KmLCa5651dz7r5Ctcq7KkS7tZbdZuPLArlqjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043408; c=relaxed/simple; bh=har6PWz44n64Z/nOCmGTv6uCWfmF5LTdLFTZJWF2aH0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EopJ+zOpsmtwfSkEW7mHnorG72o7eBT388aHq4PCZG7pjm2Uj82eQhFoW5BJD79y3ewudGaVpb84E+EgRvInlfhyfgusmhMaTpX9bI0NbIzqkXTyZgvcyZJrSacyPGJPE6i4C1dy3ErnyIOT968YaxL5GDqCjz/6pZTnP6OuW0s= 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=l3kMXnze; arc=none smtp.client-ip=209.85.216.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="l3kMXnze" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-35842aa350fso7087968a91.0 for ; Sun, 12 Apr 2026 18:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043407; x=1776648207; 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=Ua2zhmG8fqK0z5FCerxKbCIotrtAFCVPNoRET7C/8tc=; b=l3kMXnze0Q+fq2bbT6yf4G6edCeRpYoE8AzKTvNKozBoWC8HolLXVszwaB2+9OQNct 7AniNcNfgDnuY+FUnzwwF4AqkncsVhcPupVpaLL0HyaWyc13hATcgyjy8ebKLudI2BLE SEY8e3nr8+kwjox3avMndIIp+VeoVSu26ccI56fCCWKkzX7snMz08KavVQi0ggiflYTo 04TyHDFy18SKCvvnc9JmPVypQqaLV4C6bntn6vpPQZbly8FVW0tkJLVtclQPyc8YUJ9y YijK1YfcHsDMSO+a3wMcGGVQS74gap4B83Ei0QQG5T5lPUc4CJ7oE6X27iVG3/OB2Hp4 BMIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043407; x=1776648207; 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=Ua2zhmG8fqK0z5FCerxKbCIotrtAFCVPNoRET7C/8tc=; b=i4jtQxx/LwTKttVfRSwiTgWDz7dmftEzWtqjxhIbid9IenWgvKUFinRDo7luKzgJPc Sew600lOVMF+9dDG8RbD1DijXv9/5WFYh/tM/9fSDHK5UZR+7bgDF8/vxzoaBX4qwXik S/EffGh/vCz9SqqogXlu6nGQyl3P1H5hls6LI7bN3R1+bn76KIzf6N6zitQ64izysF28 ENwN0H5TH5XqxxwUd2eGqMJs7Qp4HQfoxSXmU4dPdy5jxajCpIyK+tCPiilnKFM/UhP8 m7Wa+8J/ZkIy6k+yxN5PsEE+sV6xn8/e1ndPbiocqqHgXlV6RF/mfTNln0ZJfoY6Jnys 20TQ== X-Forwarded-Encrypted: i=1; AFNElJ/3OyqREG7SEHJOQeQ7wjKoBwT6vIPyS2ccTGwb0CiHnJLgcgP2ks04u53incP6mZgUfxbY58LFweYX3vs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6bu9LB3E0tN4QhW4fXwOnvqCNQemX3q4B54I2fH2JglCy9bhB aezCw95quIurphV1LF21FCzJQoMvnorl8CUQ16GmpokF2uNGcoHE6FGSet07xLxtiEUQs3rfza9 53nne4K7nUw== X-Received: from pjug23.prod.google.com ([2002:a17:90a:ce97:b0:35c:1a37:ace]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:118f:b0:35e:5aa5:ae38 with SMTP id 98e67ed59e1d1-35e5aa5b2ecmr2427534a91.9.1776043406502; Sun, 12 Apr 2026 18:23:26 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:19 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-26-irogers@google.com> Subject: [PATCH v11 25/33] perf timechart: Fix memory leaks From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Fix missing free from cat_backtrace, which requires copies of the backtrace being made in functions that save it. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 1d24d8738519..64f69bd67c6b 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -299,7 +299,7 @@ static void pid_put_sample(struct timechart *tchart, in= t pid, int type, sample->type =3D type; sample->next =3D c->samples; sample->cpu =3D cpu; - sample->backtrace =3D backtrace; + sample->backtrace =3D backtrace ? strdup(backtrace) : NULL; c->samples =3D sample; =20 if (sample->type =3D=3D TYPE_RUNNING && end > start && start > 0) { @@ -433,7 +433,7 @@ static void sched_wakeup(struct timechart *tchart, int = cpu, u64 timestamp, =20 we->time =3D timestamp; we->waker =3D waker; - we->backtrace =3D backtrace; + we->backtrace =3D backtrace ? strdup(backtrace) : NULL; =20 if ((flags & TRACE_FLAG_HARDIRQ) || (flags & TRACE_FLAG_SOFTIRQ)) we->waker =3D -1; @@ -489,9 +489,9 @@ static void sched_switch(struct timechart *tchart, int = cpu, u64 timestamp, } } =20 -static const char *cat_backtrace(union perf_event *event, - struct perf_sample *sample, - struct machine *machine) +static char *cat_backtrace(union perf_event *event, + struct perf_sample *sample, + struct machine *machine) { struct addr_location al; unsigned int i; @@ -544,8 +544,10 @@ static const char *cat_backtrace(union perf_event *eve= nt, * It seems the callchain is corrupted. * Discard all. */ - zfree(&p); - goto exit; + addr_location__exit(&al); + fclose(f); + free(p); + return NULL; } continue; } @@ -577,6 +579,7 @@ static int process_sample_event(const struct perf_tool = *tool, { struct timechart *tchart =3D container_of(tool, struct timechart, tool); struct evsel *evsel =3D sample->evsel; + int ret =3D 0; =20 if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) { if (!tchart->first_time || tchart->first_time > sample->time) @@ -587,11 +590,13 @@ static int process_sample_event(const struct perf_too= l *tool, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; + char *backtrace =3D cat_backtrace(event, sample, machine); =20 - return f(tchart, sample, cat_backtrace(event, sample, machine)); + ret =3D f(tchart, sample, backtrace); + free(backtrace); } =20 - return 0; + return ret; } =20 static int --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 A46B82820A9 for ; Mon, 13 Apr 2026 01:23:29 +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=1776043410; cv=none; b=taaSkY/83nJxRSc9A/dTaAmXG8wzBluye0VgfS39HSIR4LwcUKqZiLm7S4zxofbKPlgrVfEz7uvuSgBRiimzB9JpGQAFVDd5l/cA79M0vrNJ3Uccw70mvaKCP7Rky3FW4E7Kcb9bYA4gD9Ilz+CERitregsNavc/pHhqULW17gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043410; c=relaxed/simple; bh=EIb6tJcKoSqkpkMiIWHT8GXSEcQ8tARRtV2V9HnrXoI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bMNTvC5HgYZ1Sf5KIGIsfgFVNWMo+xAIOAO+xCyjwbS7lvKM3DnJNeb2myuO0Th2blYSRBKmbuqyrJkwOZK+N7/3z/NyG7P7fVfcS1tsM0yWo/YSVjA6nGrzmuvdJzJJ1eYwyqgKvenqY45Bx7BNztGMNNwJOEzT3vITDZk2Ue4= 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=U4gbsRf2; 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="U4gbsRf2" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d443c3b094so8551184eec.1 for ; Sun, 12 Apr 2026 18:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043409; x=1776648209; 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=k0NBhXTshGbMXUhORX+eVN1pO2rFpCDmkzuCKC25Nuc=; b=U4gbsRf2qL6W1us9qhLvY5HiUc/UIapgVSuKGNqffMFSu/r+1u62+DAK/PYKZgAN4n ORln2Lz1ad0D8yDjrNhLQtSpFhmaw0hh75ahnCZyFVMXf9pkKwTgAiAE35gbL04uwMq6 B8K3CA7Lte+SMVLgl9EFDA76F/gVN/8dhYIMzHQrK0eff5eVmmCYY2rXmNcpW+vHDFXo 1AcYpLRU+hjhtJ4exIfgjMFrMyJ8AYTKfEyJptdKyxsHIyq3y1bHbEhwaGPOoklViBkz WAqyw5NRDeVkSyOzRtL+4nKkJBpkhpbBYbitAKYe07DY8EGo6hlgR0AiYEZWrf1ZRW8Z zwRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043409; x=1776648209; 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=k0NBhXTshGbMXUhORX+eVN1pO2rFpCDmkzuCKC25Nuc=; b=A5rCl2DlswNmryJ3m6fKsnZdAJyrKYU2yjhV5YrP5cQCDBEZim1twyYiq0jdMQKg+C mf20Bb4ZlLWBM1JtjWBvGpFj8yA9o49DC1s6QnGUcZ2zMLjm4Q1fkn98kH4dREhG2pdI 3r6EzOK4d9OGwKN0rtQ/vK2TSdVweETWGoBLg8hJObS7dhs3vOO8p3MbF/CpBIM3IjNX ccGRRXVMMQGBzSNYfmcxMmQUZkIFrK4BIdytNU2dblt1d/RBvYyu+EL8V3EfWalXl9I1 oeCtmfsSbd2GFQA13wItemV8Ih1jetHHknFgJy2zKg7McxzTMPaOCqUbWC8T/h9dCNqC pZlw== X-Forwarded-Encrypted: i=1; AFNElJ9KFGamNgN/APnzIGX/RjZ7+aG2P6Zw2UuubckTuv/UHakJe7qejLoUPnCgoSKUSMPuFsUYgFVCbrDDtxc=@vger.kernel.org X-Gm-Message-State: AOJu0YwDDZ7nhRrndWfeq+MdvfQTvfI01a4SNEWfHfxdi09FsuUnrl7/ EJ+LyewONm6IB0ICn1ZnRCxC8HehdLdVwGoIriSJzne/eALvZRHejcdHXIDNHWt4f88t5eBIMiO zVTDQNLZxFg== X-Received: from dybtv6.prod.google.com ([2002:a05:7300:f486:b0:2d8:5b05:964b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:e82c:b0:2cb:990a:b5e with SMTP id 5a478bee46e88-2d5881acd8dmr5868305eec.15.1776043408615; Sun, 12 Apr 2026 18:23:28 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:20 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-27-irogers@google.com> Subject: [PATCH v11 26/33] perf kmem: Fix memory leaks on error path and when skipping From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Add missing frees and thread__put as necessary. An issue detected by Sashiko code review. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 68a39f56204d..daf2272c7337 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -783,17 +783,21 @@ static int parse_gfp_flags(struct perf_sample *sample= , unsigned int gfp_flags) =20 new =3D realloc(gfps, (nr_gfps + 1) * sizeof(*gfps)); if (new =3D=3D NULL) - return -ENOMEM; + goto err_out; =20 gfps =3D new; - new +=3D nr_gfps++; + new +=3D nr_gfps; =20 new->flags =3D gfp_flags; new->human_readable =3D strdup(str + 10); + if (!new->human_readable) + goto err_out; new->compact_str =3D compact_gfp_flags(str + 10); - if (!new->human_readable || !new->compact_str) - return -ENOMEM; - + if (!new->compact_str) { + free(new->human_readable); + goto err_out; + } + nr_gfps++; qsort(gfps, nr_gfps, sizeof(*gfps), gfpcmp); } =20 @@ -802,6 +806,9 @@ static int parse_gfp_flags(struct perf_sample *sample, = unsigned int gfp_flags) =20 trace_seq_destroy(&seq); return 0; +err_out: + trace_seq_destroy(&seq); + return -ENOMEM; } =20 static int evsel__process_page_alloc_event(struct perf_sample *sample) @@ -971,6 +978,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, } =20 if (perf_kmem__skip_sample(sample)) { + thread__put(thread); return 0; } =20 --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 BD6C4282F0A for ; Mon, 13 Apr 2026 01:23:31 +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=1776043413; cv=none; b=lqgJx2q02Ecfhr97LWJcPT/eWESRkqRZnF+oMjPwXvB+R8EUjrVT1s3IZ8ZNNEXlVrxWwFCSMr7oLypWyzkwh+EqvPSyT6KBQc2sSNyOzFqS98aejduNqvsCks8oW+AJ/TTY/yL0lCd1sIsoPCxYoq31doRr+CLl/pynA2rqp9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043413; c=relaxed/simple; bh=bwZsKPXpFj0EagILS74wobtw3QdQZQfP3x9LOTF4xSw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=V8HXSX4PDmo4S0wQBp6mWOR+LfMkfj0G+FJuli14zrp8SP4mhoeeDNhHUwsgCpmMnrmVkPxnZ5EUKtDnYhwvjAv1rgFoMSsz7VrzARUrDsB1VVek1lpPZU/QJDbi/3HZD0lZnLXEJeAsoVWsgvn3/ZEJf42PuFiR6AO0SarHRuE= 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=Ixku8520; 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="Ixku8520" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2bdf75bc88fso5539426eec.0 for ; Sun, 12 Apr 2026 18:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043411; x=1776648211; 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=KJsfPYVO08tCC/QkaQf/uBEFF+74z2Xz18vy6UCdEwM=; b=Ixku8520Mm1SuL6kJdrjYDdegySkdKrXLwg6kew+mc0UNHBH3DQPDtCGYZsrhxvpQG Y/OsgLtKRJrNrtzfdpXbDTiBZZ5675v0fvXeBEs+137vJAKrPsX4HzOZhMtZe1KsaAcA iCeMmyDnjE6JDMTMscSg+n8JFH7/JnEQNhXmGhP3qioPXdArL7zCv0vS5/W0yosZX4NA 3PfkMt4QXOy0wPXYYxzRHO4vK080E9K3I9waEsDJgYY0PXKoGkJPVkB9KXGwRkOlIQEK EVJEbtjomgSk277hZsEm9IbCsvgyukTMlXl2T7G3BmQokF3VH9FCC7JBc1DfK5hEql2u RlFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043411; x=1776648211; 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=KJsfPYVO08tCC/QkaQf/uBEFF+74z2Xz18vy6UCdEwM=; b=Y4hYprC9Q8xNiFKdfQRmN++ajapSaioanit9zf1Ded3ymMCDi9lKbKfLR1jLNBuI2T jRA9U2v/+EAhj0ZrvACiYf54NIEwU2cDetJA/LPfZcVzf/emUcBROurcj0Uq8BFKQofI 8vWJ1wwmcGaSPMI3pp1btSgot6GTBqpAx0hNVPg/VdEt64s+huoH3u8mmGaHNrTjUX/v mqOzOnkbLrpcqtiQjsSa5H1u9j15ffjxoeWLKFtp5tYsVY5fmltiO7PKwNiuYqvfE/cq unveEdfDlsSI74cDVsgX7afHOkVQzVn1pHFI5otSKszg9DbL8RywK+XmIqvitdT19yVO xQjg== X-Forwarded-Encrypted: i=1; AFNElJ/gDLlJV6ikP3ayumWwwgIAj2j5vgOwo3phJL2kMBJL3eJXC9eMZnmbO/wr03FH7D2uz+uTrTddYZsEwGk=@vger.kernel.org X-Gm-Message-State: AOJu0Yzoh+CvkhH/89xXRVT3HqPUaA8AthDr9CoaCctNFGLXulHRaOun XbFYHojB3f43QdJRudHYU0ohIAabQ+lyS1iM4s4KqSTHx07za4u910o/wZQIubyFt5h9gir/Zqk tpHqV5FMKUg== X-Received: from dykp36.prod.google.com ([2002:a05:7300:ca4:b0:2d1:54d:3d96]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:2c84:b0:2c5:d833:a4f3 with SMTP id 5a478bee46e88-2d58907b4admr6496179eec.18.1776043410741; Sun, 12 Apr 2026 18:23:30 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:21 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-28-irogers@google.com> Subject: [PATCH v11 27/33] perf synthetic-events: Bound check when synthesizing mmap2 and build_id events From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Prompted by Sashiko code review, add bound checks when synthesize mmap2 and build_id events to make sure the filename doesn't overflow the event and lead to stack corruption. Signed-off-by: Ian Rogers --- tools/perf/util/synthetic-events.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index de812a2befbc..a7fef7ac3da6 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -2257,14 +2257,20 @@ int perf_event__synthesize_build_id(const struct pe= rf_tool *tool, const char *filename) { union perf_event ev; - size_t len; + size_t len, filename_len =3D strlen(filename); u64 sample_type =3D sample->evsel ? sample->evsel->core.attr.sample_type = : 0; void *array =3D &ev; int ret; =20 - len =3D sizeof(ev.build_id) + strlen(filename) + 1; + if (filename_len >=3D sizeof(ev.mmap2.filename)) + return -EINVAL; + + len =3D sizeof(ev.build_id) + filename_len + 1; len =3D PERF_ALIGN(len, sizeof(u64)); =20 + if (len + MAX_ID_HDR_ENTRIES * sizeof(__u64) > sizeof(ev)) + return -E2BIG; + memset(&ev, 0, len); =20 ev.build_id.size =3D bid->size; @@ -2303,14 +2309,21 @@ int perf_event__synthesize_mmap2_build_id(const str= uct perf_tool *tool, const char *filename) { union perf_event ev; + size_t filename_len =3D strlen(filename); size_t ev_len; u64 sample_type =3D sample->evsel ? sample->evsel->core.attr.sample_type = : 0; void *array; int ret; =20 - ev_len =3D sizeof(ev.mmap2) - sizeof(ev.mmap2.filename) + strlen(filename= ) + 1; + if (filename_len >=3D sizeof(ev.mmap2.filename)) + return -EINVAL; + + ev_len =3D sizeof(ev.mmap2) - sizeof(ev.mmap2.filename) + filename_len + = 1; ev_len =3D PERF_ALIGN(ev_len, sizeof(u64)); =20 + if (ev_len + MAX_ID_HDR_ENTRIES * sizeof(__u64) > sizeof(ev)) + return -E2BIG; + memset(&ev, 0, ev_len); =20 ev.mmap2.header.type =3D PERF_RECORD_MMAP2; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 14CBE28F948 for ; Mon, 13 Apr 2026 01:23:34 +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=1776043415; cv=none; b=SN6VeuV6LdU0EfyAaQ94HaTxYvzMWZ2Puq8qxBj4PFHhzPUh2F1jiz5g7YwvoYMVA6UsDC9KV/KshddfC0nPKOmD4V2oxTCDN2eRUwlLrE1pIVEkP3HF5cSWcwWDjeMsO0noZe1OxgiDHB+vYGhD1sQC39QQ/OJwN9gcgLHhP/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043415; c=relaxed/simple; bh=TORHr2hwj56t1K+9uUsjLQo6KHkuVY+QoSlV3b0luUk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=G1pI7JAb+F0lMlbxA5m+a0t6HKFJpMSCuuEIJVxnT6EH8xNd0wlEdo0mtNOYvpndx1oa3jOeUu3ITVKaWrIJvVrvYHu6Z5KjSIeBMdfW71HByBsfDU1XxYb1lhKJ3DZxg0C+a+OceWLMBZKxHe/Q7NvPSp+iLyffWYYkas9HdCA= 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=TAAxnVc4; 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="TAAxnVc4" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2d8a677cdfaso677270eec.1 for ; Sun, 12 Apr 2026 18:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043413; x=1776648213; 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=hQS4P5hyltqhKwRzLCXyq1MWFkkdWjplTUZAMK0ialE=; b=TAAxnVc4OZkPaYoxtwsq8pjbRkohZPjaUf+DqnioPZm0/PxgBD+1fY51boY//4Y5l3 ljiqVGR07f+oW7srt+tKz4JzYQCX0FmN5Iw4ilK9sLsocHZJto0uyvvcbkH6xbJybBok e78kMNCDi/89sBuutnNivPY7CSgOXuKfDeccThlEoW22gmbsARh46clTJ1QfCxasjkII 8s9h9WqJ8VNGmZsZreJ5cWeNxtA4VArw5Ac08ES8WAAkUIG302T1TTQDSmor+HrREeEz cdjY03JMzydwJTJdaXqQSNv3LPzAZx3c7FrsN80tHmNwIpQeQOCwTe440aKSi5+QTShF BGjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043413; x=1776648213; 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=hQS4P5hyltqhKwRzLCXyq1MWFkkdWjplTUZAMK0ialE=; b=nBd2p6LrgTT0WpLOYf1TaVoeX0WBrj1Kv59yzMFh6Lqf0cw45f3aH+xLZSnY1Q/r3w e3JqqBoENGotv3SKHNQHL1zMHLp5PXUYPIIh4OkTLHgCaih/AZB0xls+F7lfYQ2vcvl+ 3ajKJSXkgyhtee2nvphkkc3wD0chFdhLp7avOdibcUX3mtvWt4OhVq8VlVFcyjW/Fc+l 5nFJUllNQ5CaFb7jd7WAMO4c5JDkLbSgl09ilOVHiNN54olNkd3vTRzfX461iJmRCKRB 11TB+iWkY+nqobLbLXl7/LVUIjI/HP+4qD5/vBxvnWq/Rybt0KAe1ZoDKwv2CdS6rkm2 QOYQ== X-Forwarded-Encrypted: i=1; AFNElJ9KYu486y097rsI9mN804bPOwhZK3k3pzWBy/mgDFz0ZwST+2ZIv8S8Q4omx0UsYMalJWBREbmtveFNM+U=@vger.kernel.org X-Gm-Message-State: AOJu0YzCD+HtNe2WXI6GDnOwdSh0LuXgOp7uPO1AOPezX5LTGXDVzJR/ rJFYuiJzctEeKspOfZnl7iiUyk9bwh68rZ25yWU/c7zaJpt12+BbyFOceHT+u3NwA8nzuWAf80R czHAjLXADmw== X-Received: from dycsd9.prod.google.com ([2002:a05:693c:3109:b0:2ca:f172:3f06]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:6788:b0:2c4:acef:292a with SMTP id 5a478bee46e88-2d587d82e73mr6443685eec.12.1776043413071; Sun, 12 Apr 2026 18:23:33 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:22 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-29-irogers@google.com> Subject: [PATCH v11 28/33] perf kmem: Add bounds checks to tracepoint read values From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Avoid out-of-bound memory accesses by bound checking order and migrate_type when coming from page_alloc_event and page_free_event. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index daf2272c7337..33585e353efe 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -826,6 +826,16 @@ static int evsel__process_page_alloc_event(struct perf= _sample *sample) .migrate_type =3D migrate_type, }; =20 + if (order >=3D MAX_PAGE_ORDER) { + pr_debug("Out-of-bounds order %u\n", order); + return -1; + } + + if (migrate_type >=3D MAX_MIGRATE_TYPES) { + pr_debug("Out-of-bounds migratetype %u\n", migrate_type); + return -1; + } + if (use_pfn) page =3D perf_sample__intval(sample, "pfn"); else @@ -892,6 +902,11 @@ static int evsel__process_page_free_event(struct perf_= sample *sample) .order =3D order, }; =20 + if (order >=3D MAX_PAGE_ORDER) { + pr_debug("Out-of-bounds order %u\n", order); + return -1; + } + if (use_pfn) page =3D perf_sample__intval(sample, "pfn"); else --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01: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 1BF5929D260 for ; Mon, 13 Apr 2026 01:23:37 +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=1776043418; cv=none; b=DtpRhgjXsEae8jyRNaq4vUqS1BLgrV3mKtp1SiLN7OmctDYBC7CMXhWAsIsTsG+Tsu+OrAfVjKFl9s8f4gsJye8/oRAhSfmZLHKiwB2ZMEZyJm6/tWwPmpnfZyzj7DJFwo+Ycbr+2ZEfbovU/NZIm6/6Ptel9+6tguPLkKORrHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043418; c=relaxed/simple; bh=yx8AkPPpD2Sp+st/2098+LZAGIagjG0tVwYWsU2O4GA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rVymXKUU4Z8uwlGx9dOotXIg5T93byETsagZKmN2FOZIEOixF9/hC4wH3DqSyXfOc6osOouklvH5/PQvXcoQ+mxND3MYfrcew5X89LVjXltkWSWqWDSuLcAHwMz/zgMujD9MH3md+Ktv/y7wDERbfFzymoqfiTCZosyqp5f4ifI= 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=NVhmzWyT; 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="NVhmzWyT" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2bdc1b30ac8so6842647eec.1 for ; Sun, 12 Apr 2026 18:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043416; x=1776648216; 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=2iFG1V1ADs66SaGcnWhOCIW8PxKEBsq18U8S+fNjRdU=; b=NVhmzWyTgxKn1eLEwF3tKLIvUH9V9IbIUTh1ouwgJQ+opsFrZKatAAU9VUJjD0nfuD 1Sg7KCxlaHJx703jIxiUVaBYSH9Jg1ihKLBak7BmdHdNuOczMl5F/sJ6Lfh0Rix7Oy0a ReiFzhUIC0ayDhcuZy7WKhTkn4xiGvucfxbeV5cdo2sDZ33+cTL9Lu4O70SEfsfKxVQa 7Zv2U5sBg6FMkjkWwXxAI5nKy7SrcxTYlTO1UvfBdlRfgBsV4THXtyx8qsa7pABvT9q2 VKaNzbCt6ss9o3I8NQiWculchmqBz7HYmw5aWFbtQ9TL8665vlzaP+SFslwDTMiys26A CPqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043416; x=1776648216; 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=2iFG1V1ADs66SaGcnWhOCIW8PxKEBsq18U8S+fNjRdU=; b=L1otjEmeoru5Chz/2VjKq2CiXEx1kZVBmIhiIWulfF/qVuzJVpFEt8kcxFDm0eiDEg IFBw4HjtIFcBXJwQ/ZvFE1QOYcXyngE3Gywj5eoQ6YE5/sg321FCaNn8EyeFhjW5UQx+ YEGsldIf7+WdIa0WTQHmTAM0VOOkcnljamUh6VJaT110Idj7P26MwrSW0xn7PAeVWT+i 7QC/U8I1Z1C3eFgYdU4xeUAa43qqVjJ6+Kh/OtiWSQlw8ZTB7d2/f+hTag/FRCVby9tM ufuV54aXAWITrc7F/XgkT8IsiKUQz83D4KrMq20Olr3LkxrvhQOuEdHVJYbNV2q9FFWh 98Gw== X-Forwarded-Encrypted: i=1; AFNElJ+1d8GGKJFnNjQra5F5ChqwaZEgipQZ9dqLNq/3+RXTb97Sk+9KeYa+cv5gfYOyQbh/saNVjq0CyAU7s4Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwgrQ1QG6WniK/QIi5q4RtlTD+8Yp3Sa00T52NKHWG5FpbVrImI DAJMm8Um6vBGcap7o/6yeRAA7NfR5349DKGK2/Tc5ihaUXtyLNt1pxdS3x2gzfh1xUS0Gns1IDL 0JZEKNN5MEQ== X-Received: from dybeb10.prod.google.com ([2002:a05:7300:a2ca:b0:2d5:d26c:d4bc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:4290:b0:2d8:7302:d37 with SMTP id 5a478bee46e88-2d873021507mr1286149eec.1.1776043416162; Sun, 12 Apr 2026 18:23:36 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:23 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-30-irogers@google.com> Subject: [PATCH v11 29/33] perf sched: Bounds check CPU in sched switch events From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Prompted by Sashiko in code reviews. Ensure the CPU is within expected bounds to avoid out of bound memory accesses. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 45439e2af8ff..008e3bb0ad6e 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1791,6 +1791,11 @@ static int process_sched_switch_event(const struct p= erf_tool *tool, u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), next_pid =3D perf_sample__intval(sample, "next_pid"); =20 + if (this_cpu < 0 || this_cpu >=3D MAX_CPUS) { + pr_warning("Out-of-bound sample CPU %d. Skipping sample\n", this_cpu); + return 0; + } + if (sched->curr_pid[this_cpu] !=3D (u32)-1) { /* * Are we trying to switch away a PID that is @@ -1813,6 +1818,11 @@ static int process_sched_runtime_event(const struct = perf_tool *tool, { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 + if (sample->cpu < 0 || sample->cpu >=3D MAX_CPUS) { + pr_warning("Out-of-bound sample CPU %d. Skipping sample\n", sample->cpu); + return 0; + } + if (sched->tp_handler->runtime_event) return sched->tp_handler->runtime_event(sched, sample, machine); =20 @@ -2775,6 +2785,11 @@ static int timehist_sched_change_event(const struct = perf_tool *tool, int rc =3D 0; const char state =3D perf_sample__taskstate(sample, "prev_state"); =20 + if (sample->cpu < 0 || sample->cpu >=3D MAX_CPUS) { + pr_warning("Out-of-bound sample CPU %d. Skipping sample\n", sample->cpu); + return 0; + } + addr_location__init(&al); if (machine__resolve(machine, &al, sample) < 0) { pr_err("problem processing %d event. skipping it\n", --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 30E62239E6C for ; Mon, 13 Apr 2026 01:23:39 +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=1776043420; cv=none; b=EPDnNSRGITahXa+Am7rmIx+sMUw0cNW8pq+HUktpowg6iQOjU/x1GH88MdE+mDiI2l78lTkoDcxw/30W1cfQcZ5wLLe56QFx3b0qaxMATS6DRI4Rrmdx0BTuLOtD9UGdfpsnEN4N2JoQhuUG0goCxeQR9Mh1eQHEuAP0haQjh9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043420; c=relaxed/simple; bh=dVAsi7bYYPJqnhbBpPHXGd5q5Za/B/TINrLvFtzpiD8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WFuJOFbo5mCGp1g8ItauZeMIo6lbrRqaP0YVBCUQVi+2tTMaZevBUMQBDinkCCMhVrXofGXQsz4R4BBU/9LSTvkb32VDbayXT5q2qQ1gLTKO/JQ5oBFUlEx7EDhhOkPShm73DKBGgH76rRts6DdJp/m+b8slCj5twWVYjwxe47o= 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=L31H7SOC; 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="L31H7SOC" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c20a91932so7453516c88.1 for ; Sun, 12 Apr 2026 18:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043418; x=1776648218; 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=3gAJ13cmq58H8ae4d4LEnv5+lFu4mwDfSGGPkW/FQa0=; b=L31H7SOChWwDyjEg+UbCEohLLemGQnX6x+3Ry40En7fRbWt9hrOCSYu3Bb9Mhk2Viw s5bANx4AkcIm3iifbnlx6GCb/rdgRUquZri39yd3M1gEQQcu+Ixx2/Km/YoZS0NG+ykC 68mO8OVruRtfFx9SjIXTZvChglx3iMncLJ1XHPP/NBWyy9TEb/cKnq6iGz361UQLyhz5 fEUYEo2EWPfEzwDAfKrvU0Lf6LVdYcloE+NlnZgBM5CeGDoE0U+kSCTFSrXHQnj9EUTF toV9i0bzhkIMzwrSN0u6bh3Frfve4H2zySZa+//3z7ylkYTxRmdicNcyY1DiJz6BHC1N Ry8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043418; x=1776648218; 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=3gAJ13cmq58H8ae4d4LEnv5+lFu4mwDfSGGPkW/FQa0=; b=m6/kUeRdb3rfM+ObOCEHpxWH0V8jPAp7U4TtZfR6QVlQHg04ceZvhJZo7PIkDf5aNW M6ICWxqyfUe/lkcvy465TWE6kGxJ/o/RdrsPNZqYwSm0zzOGWVunafCaNNB3H/lO/zRC NV2DCmFwvoHkL7WE5Ly3wQGIDLNiR761t+jLySA2Z9BsbsCAT2gAhFeAI79QFVIWEhKO 2i7EVIjME0jy2dAgRip7oVuLvxiHa2imq5LeRpHxn4hUdogEN0H7DRSJBgdu/Saw5GfK JgJ7rWxoq3Bp11tuMGChNmIoLNOH7JzAyWQw9IgCFvJOxFCf/CYd6WP36PhHJpPQv+dk O+Vg== X-Forwarded-Encrypted: i=1; AJvYcCVeuXUSXrEN3FQmNAwhZ3ABmfFwFDNb+29PxOcnhEkNoQiWd4CgPTpXpJee+PyJRANl5IMo5vnTvUHwJes=@vger.kernel.org X-Gm-Message-State: AOJu0YyH2py0r8LTB9z8RxRNXLOyy2VOKrPC7/k3I21E2ZNzkT46M2nZ 85J1bLRS3flbyBlsEUEmxW3M3RpPx0f6wGRn0PIBhu72ECIZUkbjDPaq/frSE5y5sjipn9AVmI7 BbKc/vu1ATA== X-Received: from dlcip13.prod.google.com ([2002:a05:7023:c08d:b0:12c:3dd4:fcf5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b97:b0:121:dea2:d54d with SMTP id a92af1059eb24-12c34ececbfmr7698351c88.20.1776043418300; Sun, 12 Apr 2026 18:23:38 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:24 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-31-irogers@google.com> Subject: [PATCH v11 30/33] perf timechart: Bounds check CPU From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Ensure the CPU is within expected bounds to avoid out of bound memory accesses in arrays tracking CPU state. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 64f69bd67c6b..64903b54e8a7 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -607,6 +607,10 @@ process_sample_cpu_idle(struct timechart *tchart __may= be_unused, u32 state =3D perf_sample__intval(sample, "state"); u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 + if (cpu_id >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu_id %u\n", cpu_id); + return -1; + } if (state =3D=3D (u32)PWR_EVENT_EXIT) c_state_end(tchart, cpu_id, sample->time); else @@ -622,6 +626,10 @@ process_sample_cpu_frequency(struct timechart *tchart, u32 state =3D perf_sample__intval(sample, "state"); u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 + if (cpu_id >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu_id %u\n", cpu_id); + return -1; + } p_state_change(tchart, cpu_id, sample->time, state); return 0; } @@ -635,6 +643,10 @@ process_sample_sched_wakeup(struct timechart *tchart, int waker =3D perf_sample__intval(sample, "common_pid"); int wakee =3D perf_sample__intval(sample, "pid"); =20 + if (sample->cpu >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu %u\n", sample->cpu); + return -1; + } sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, back= trace); return 0; } @@ -648,6 +660,10 @@ process_sample_sched_switch(struct timechart *tchart, int next_pid =3D perf_sample__intval(sample, "next_pid"); u64 prev_state =3D perf_sample__intval(sample, "prev_state"); =20 + if (sample->cpu >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu %u\n", sample->cpu); + return -1; + } sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, prev_state, backtrace); return 0; @@ -662,6 +678,10 @@ process_sample_power_start(struct timechart *tchart __= maybe_unused, u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); u64 value =3D perf_sample__intval(sample, "value"); =20 + if (cpu_id >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu_id %llu\n", (unsigned long long)cpu_id); + return -1; + } c_state_start(cpu_id, sample->time, value); return 0; } @@ -671,6 +691,10 @@ process_sample_power_end(struct timechart *tchart, struct perf_sample *sample, const char *backtrace __maybe_unused) { + if (sample->cpu >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu %u\n", sample->cpu); + return -1; + } c_state_end(tchart, sample->cpu, sample->time); return 0; } @@ -683,6 +707,10 @@ process_sample_power_frequency(struct timechart *tchar= t, u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); u64 value =3D perf_sample__intval(sample, "value"); =20 + if (cpu_id >=3D MAX_CPUS) { + pr_debug("Out-of-bounds cpu_id %llu\n", (unsigned long long)cpu_id); + return -1; + } p_state_change(tchart, cpu_id, sample->time, value); return 0; } @@ -694,10 +722,9 @@ process_sample_power_frequency(struct timechart *tchar= t, */ static void end_sample_processing(struct timechart *tchart) { - u64 cpu; - struct power_event *pwr; + for (u64 cpu =3D 0; cpu < tchart->numcpus; cpu++) { + struct power_event *pwr; =20 - for (cpu =3D 0; cpu <=3D tchart->numcpus; cpu++) { /* C state */ #if 0 pwr =3D zalloc(sizeof(*pwr)); @@ -1517,6 +1544,8 @@ static int process_header(struct perf_file_section *s= ection __maybe_unused, switch (feat) { case HEADER_NRCPUS: tchart->numcpus =3D ph->env.nr_cpus_avail; + if (tchart->numcpus > MAX_CPUS) + tchart->numcpus =3D MAX_CPUS; break; =20 case HEADER_CPU_TOPOLOGY: --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 60CE32C21F2 for ; Mon, 13 Apr 2026 01:23:41 +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=1776043423; cv=none; b=YVxBCBZXQbqF68E6WhS1wd+BP9Tz4wMLtRvpcwz1njac27owXDBLMwSiwfhIcxKFII8fVqFaaO8ip08bOjRjQKaZdOWs483rgtSmdz4q0HuKGIviWHrLORB+NL6GcZt8fPV4NvSOgpLdJ1k9/VtiNHAGtYqrVGKbOiqnwXKYTwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043423; c=relaxed/simple; bh=lurA7V4e8q7j0hn+dXLUJ3lZ8gP/eRhJrX/92iBe+gM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=efiz2A24rG+hvZID7PZ9pn/EJEnkYJT/9OCi+Fi9CEE5TQy/WzU7gFT3NiITcMWx6NgX4T61D1jYeBxm3yfILSzhHKehmFdCMjFZdaWpKH8t/7ibOs0hnW8aKQynYiO7Ja2BQFiYnlcjuDXseDGe9J3bN/yc74LnP4QPOR79trg= 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=FDkjwRft; 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="FDkjwRft" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c20a91932so7453648c88.1 for ; Sun, 12 Apr 2026 18:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043421; x=1776648221; 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=QL5jBdw8qQX/M0tPrJ6CIQUkV0jfcuV2ZvO0gSC/Q1M=; b=FDkjwRftCD5W+pAsweKhyWR6L54+qJ9EjZRlDO367eNbhZ86/JuadMo9jom064/WFa 3Cp5qc9TuwWnzO/1GC6e45V3jqgvkFBMb5UPrYKedZBpc1f/equ8d0bwg/NTeogwAWBW vgFMsvz64YizOuoXOh5kE2e1vsXe+8alAPc9mpK6rWhwzY+FXQIXYERYyxiQ8hwDtqh1 DvSlvUiGuF9OUwBQc3UyaU5gABVQBUJ1A1tf/f/ypkfDxMunjLuJJMF0hmL/TEPtAUFY N9MhZ1wF/WdkEwhjl8l1ForZfyUX2CVI+0yWjhkp3R2j/EKww91z2/iWiv82xl/VDijr oHdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043421; x=1776648221; 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=QL5jBdw8qQX/M0tPrJ6CIQUkV0jfcuV2ZvO0gSC/Q1M=; b=Mysm0KCNS5Ihz8QVKfIBe0/ehDd8AAV6prw7HbaIBUU2rN1CKsdqfhgs7X1unTK9Xl CnRO60Ewg92o7ebNkjE2BaLjXLjnE84MaNblCPg9yE6XfIhbs55luoLvPoEayfljsmKE Op64iQV326Ktk1J4cMAsPq4W7jkuDnTrid+LqVNf+bucnvPZN6+UsKzCTUUwWkSX9UFZ jYAD9SUCV+mrB5eQardFkq20VUux3JDjLTMljFStNmH73uEuvUfkyahobCcwbCpdqSrB rjf//A50zpyFVhtMCDgZM+n0R6VKoVHX4JiE+RDxbsfnEWzrHB8LtTVbm+QHTxbdnfcO RsAA== X-Forwarded-Encrypted: i=1; AJvYcCVYYAx29d5qnO0Sji4ufpqn7TRv7OtANY/3F/1sgP/9BHmCJzQ+W1bSbD8tJqEttAuMh+IAsuqAbgJZhxs=@vger.kernel.org X-Gm-Message-State: AOJu0Yxd3K9vTVFHLTfC5utETMtLnuIF5dT//KxO2FnCf8yy/3J3cT9e NEhz80j9VnmoF/y8RdbwSmGdrPdJYQ25U2xEjQfDrWdjhn1cqVeF8EY6NbiLVFRJlJHS/3CVXho 9JE3lIucEYA== X-Received: from dlcip13.prod.google.com ([2002:a05:7023:c08d:b0:12c:3dd4:fcf5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:327:b0:128:ccaf:85d5 with SMTP id a92af1059eb24-12c34e75ef6mr6781933c88.15.1776043420340; Sun, 12 Apr 2026 18:23:40 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:25 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-32-irogers@google.com> Subject: [PATCH v11 31/33] perf evsel: Add bounds checking to trace point raw data accessors From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" Avoid a tracepoint field accidentally reading out of bounds by checking the size of read fits. This was prompted by Sashiko review feedback about the potential. Properly compute the size for dynamic fields using the high 16-bits. Signed-off-by: Ian Rogers --- I suspect the int field handling should also incorporate these changes, but I've stopped with just rawptr's (which also includes strings) as those are the only current fields that support dynamic and relative. --- tools/perf/util/evsel.c | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index bb48568b8101..a23bd28579b5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3700,22 +3700,59 @@ struct tep_format_field *evsel__common_field(struct= evsel *evsel, const char *na return tp_format ? tep_find_common_field(tp_format, name) : NULL; } =20 +static bool out_of_bounds(const struct tep_format_field *field, int offset= , int size, u32 raw_size) +{ + if (offset < 0) { + pr_warning("Negative trace point field offset %d in %s\n", + offset, field->name); + return true; + } + if (size < 0) { + pr_warning("Negative trace point field size %d in %s\n", + size, field->name); + return true; + } + if ((u32)offset + (u32)size > raw_size) { + pr_warning("Out of bound tracepoint field (%s) offset %d size %d in %u\n= ", + field->name, offset, size, raw_size); + return true; + } + return false; +} + void *perf_sample__rawptr(struct perf_sample *sample, const char *name) { struct tep_format_field *field =3D evsel__field(sample->evsel, name); - int offset; + int offset, size; =20 if (!field) return NULL; =20 offset =3D field->offset; - + size =3D field->size; if (field->flags & TEP_FIELD_IS_DYNAMIC) { - offset =3D *(int *)(sample->raw_data + field->offset); - offset &=3D 0xffff; - if (tep_field_is_relative(field->flags)) + int dynamic_data; + + if (out_of_bounds(field, offset, 4, sample->raw_size)) + return NULL; + + dynamic_data =3D *(int *)(sample->raw_data + field->offset); + offset =3D dynamic_data & 0xffff; + size =3D (dynamic_data >> 16) & 0xffff; + + if (tep_field_is_relative(field->flags)) { + /* + * Newer kernel feature: Relative offsets (__rel_loc). + * If the relative flag is set, the parsed offset is not + * absolute from the start of the record. Instead, it is + * relative to the *end* of the dynamic field descriptor + * itself. + */ offset +=3D field->offset + field->size; + } } + if (out_of_bounds(field, offset, size, sample->raw_size)) + return NULL; =20 return sample->raw_data + offset; } @@ -3726,6 +3763,9 @@ u64 format_field__intval(struct tep_format_field *fie= ld, struct perf_sample *sam u64 value; void *ptr =3D sample->raw_data + field->offset; =20 + if (out_of_bounds(field, field->offset, field->size, sample->raw_size)) + return 0; + switch (field->size) { case 1: return *(u8 *)ptr; --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 6A66C239E7F for ; Mon, 13 Apr 2026 01:23:43 +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=1776043424; cv=none; b=dfcx0Jwh48VADaFVKeEsGsDlm7FekNu3qvZHwa2FdW3LLxqJxj7JLAfkoV6Nsi1dSC12/Ur0AzkBB2V7nquj4M45aXsDEUj61q8etZVE0nL0047Epowe1pOsBhosp/OcxhcWN8cr5oFtSqZY0Vpr4uh0JJp9SQPxnzb6Sz93Qh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043424; c=relaxed/simple; bh=66xqwU8TdrCM+0qRvoOnzdTygtIXMVEt2vWeBM6SfY0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CtZZM4K8lwcMJkf6iRLjZTAk1f1oH2dbFxzsnPFJh6+aIwXfLFwsEvodYL4DC5n8zHLRw2utSwSZEbrEq+kSiwu9HIgI+zoxdK3VZFuFPgalAddZvCggf1jcHgWzBuwSrgamrvRxT0HnWCUCjBwyxOBWRs+DF+i/C/xmWionLEs= 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=Hehu/7oO; 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="Hehu/7oO" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12c21dbc9c1so12531856c88.0 for ; Sun, 12 Apr 2026 18:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043423; x=1776648223; 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=xiPToYQ7s8nRwPjlKmCIY6nHfGV8vY3NR0sUv4YSbrY=; b=Hehu/7oODL37Bk2iXltaHmIB/IjNhzf3Rh2NHDsOhBgApAOXhL134ejhbAJMWcw+Oz xcPdft28BgMWDZKaWFVsmNb/evbIoLj2q68H+u500f3dCf+ZxdBRC7wa4NOh0mpoTmut rPbPo1OPL530BGIo4Pj0MFyuBTBorgVmSnDdQ05bjRPzRu1vEgo2oKCSNzJnVm18mgFH wrEZM4TaUfZox/Y5cprV62CDESVXoeKURYb9Dd/h2JklacVsmH9moAV4UWmSWe6v6fz3 BqOJa/plhu/a1JpDMGfzWRGy47EvqPxa65kz2qy0taRsiJ6kaMBBI0WlhdDthw34adpD vUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043423; x=1776648223; 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=xiPToYQ7s8nRwPjlKmCIY6nHfGV8vY3NR0sUv4YSbrY=; b=f6fHyI1jIeXse9LzW8ImXoZWZo5B6LfayxcygBZnhUcxklwtBdcGFI7d3ZdXZQ0e3H rjNVXZ4FjrIjtKGokSb2P1+sJT7NwTcfTsUMMEyQWggl6ZTe9e1Uyf88ytJ1dNVQta2s JhkIWonbi6B0NISiHrqAH9LVz0gKuciWQ2pHGnXGhl2iuPGIm53/ittDwbgLmgPgny3z n10hYHhzWLSSDxa1UIHLJm4x+Ng2I3JTyVwZXqTH9Spw0Fl3ZZB19vLj9R+YVuFnjNXt yQ2v7uegqxpEsK30rcjdc2FIAxT8xatAWmZIoxEuH4EeSJqpnmbcaaYACtd5wr4ULo7A Ek6w== X-Forwarded-Encrypted: i=1; AFNElJ/0ydHY1hlw/RhmzmYQvff8VD4Hm6AVOjJdsDwKKyg7sYXrEWxaFvAlVzg+s4EzeHoP/DSrFnW0gk9Fnfk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxfu9NGJ5/1Or1OkBfcRvLHb0ehmVlmwHZeuk71h5GW5RVSaAZ9 6s3HrNA293Gg4vnL+spuc3hYMuM9sjooeG/nm0+YP3mlVWgpQ0s++/e6YaHfKa7tHA/uD0R5Cp3 D3SDjVUQbhg== X-Received: from dys21.prod.google.com ([2002:a05:693c:8015:b0:2be:4118:56f1]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:cb0e:b0:2ce:f3d7:221 with SMTP id 5a478bee46e88-2d589463e5cmr6290307eec.17.1776043422464; Sun, 12 Apr 2026 18:23:42 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:26 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-33-irogers@google.com> Subject: [PATCH v11 32/33] perf kwork: Fix address sanitizer issues From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" There is a double free in the record array due to how parse_options will mutate the array. Fix by keeping an array that isn't mutated. Ensure kwork_usage is freed on all paths. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 59a54d11f7fa..a4604e152002 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2258,7 +2258,7 @@ static void setup_event_list(struct perf_kwork *kwork, static int perf_kwork__record(struct perf_kwork *kwork, int argc, const char **argv) { - const char **rec_argv; + const char **rec_argv, **to_free =3D NULL; unsigned int rec_argc, i, j; struct kwork_class *class; int ret; @@ -2295,16 +2295,27 @@ static int perf_kwork__record(struct perf_kwork *kw= ork, =20 BUG_ON(i !=3D rec_argc); =20 + /* Save the pointers as the array will be mutated by cmd_record. */ + to_free =3D calloc(rec_argc + 1, sizeof(char *)); + if (to_free =3D=3D NULL) { + ret =3D -ENOMEM; + goto EXIT; + } + pr_debug("record comm: "); - for (j =3D 0; j < rec_argc; j++) + for (j =3D 0; j < rec_argc; j++) { pr_debug("%s ", rec_argv[j]); + to_free[j] =3D rec_argv[j]; + } pr_debug("\n"); =20 ret =3D cmd_record(i, rec_argv); =20 EXIT: for (i =3D 0; i < rec_argc; i++) - free((void *)rec_argv[i]); + free((void *)(to_free ? to_free[i] : rec_argv[i])); + + free(to_free); free(rec_argv); return ret; } @@ -2447,6 +2458,7 @@ int cmd_kwork(int argc, const char **argv) const char *const kwork_subcommands[] =3D { "record", "report", "latency", "timehist", "top", NULL }; + int ret =3D 0; =20 perf_tool__init(&kwork.tool, /*ordered_events=3D*/true); kwork.tool.mmap =3D perf_event__process_mmap; @@ -2463,7 +2475,7 @@ int cmd_kwork(int argc, const char **argv) =20 if (strlen(argv[0]) > 2 && strstarts("record", argv[0])) { setup_event_list(&kwork, kwork_options, kwork_usage); - return perf_kwork__record(&kwork, argc, argv); + ret =3D perf_kwork__record(&kwork, argc, argv); } else if (strlen(argv[0]) > 2 && strstarts("report", argv[0])) { kwork.sort_order =3D default_report_sort_order; if (argc > 1) { @@ -2474,7 +2486,7 @@ int cmd_kwork(int argc, const char **argv) kwork.report =3D KWORK_REPORT_RUNTIME; setup_sorting(&kwork, report_options, report_usage); setup_event_list(&kwork, kwork_options, kwork_usage); - return perf_kwork__report(&kwork); + ret =3D perf_kwork__report(&kwork); } else if (strlen(argv[0]) > 2 && strstarts("latency", argv[0])) { kwork.sort_order =3D default_latency_sort_order; if (argc > 1) { @@ -2485,7 +2497,7 @@ int cmd_kwork(int argc, const char **argv) kwork.report =3D KWORK_REPORT_LATENCY; setup_sorting(&kwork, latency_options, latency_usage); setup_event_list(&kwork, kwork_options, kwork_usage); - return perf_kwork__report(&kwork); + ret =3D perf_kwork__report(&kwork); } else if (strlen(argv[0]) > 2 && strstarts("timehist", argv[0])) { if (argc > 1) { argc =3D parse_options(argc, argv, timehist_options, timehist_usage, 0); @@ -2494,7 +2506,7 @@ int cmd_kwork(int argc, const char **argv) } kwork.report =3D KWORK_REPORT_TIMEHIST; setup_event_list(&kwork, kwork_options, kwork_usage); - return perf_kwork__timehist(&kwork); + ret =3D perf_kwork__timehist(&kwork); } else if (strlen(argv[0]) > 2 && strstarts("top", argv[0])) { kwork.sort_order =3D default_top_sort_order; if (argc > 1) { @@ -2507,12 +2519,12 @@ int cmd_kwork(int argc, const char **argv) kwork.event_list_str =3D "sched, irq, softirq"; setup_event_list(&kwork, kwork_options, kwork_usage); setup_sorting(&kwork, top_options, top_usage); - return perf_kwork__top(&kwork); + ret =3D perf_kwork__top(&kwork); } else usage_with_options(kwork_usage, kwork_options); =20 /* free usage string allocated by parse_options_subcommand */ free((void *)kwork_usage[0]); =20 - return 0; + return ret; } --=20 2.53.0.1213.gd9a14994de-goog From nobody Mon Jun 15 18:01:56 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 00C8423C39A for ; Mon, 13 Apr 2026 01:23:45 +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=1776043427; cv=none; b=GKFKWlus401PD64dxkzpqE1gvg9jgzJ1K74XgB8wvbte68IoaQUdxUy+zqs1jl49LL64zB0B2fee+ENcWZrELpUGtzJdBe1IaAtsjWngkrr2zPOz11rdMQM+qEqm/eFeVO8zKEJ9/kIBergdXSfR5xWCy7F6pyplfe0l7USa06w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776043427; c=relaxed/simple; bh=o+libGjGGnh0PZHJw+kVOgmbQh9zxpxsvn3EuaHS1hA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n1aEsJhlrRJvdtnUQtmMMnNAVJjspc4rGXyOHZGJAFD6DWuqfeXpYwDdcBYESGLuLP0FDKv+kGMGeNAFpafdSJdkJkYMjR3J//7mjWCBqomXrC32yYyw76k6V+4yI39wOpl7Ee572nTuyWTdvGlEQrovB1ElHjV/ym9r/vzoQFk= 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=IuRxP8da; 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="IuRxP8da" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127133794b6so16137456c88.1 for ; Sun, 12 Apr 2026 18:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776043425; x=1776648225; 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=qTdwOD5MvJj+i4G9bVPQNL0PRv4ibjmw6Xi5PZQFnqk=; b=IuRxP8dalch4/pZ6BHklpiP8VHEVv44H/ZvWIKA4eMuqMJ8wJ53a9lgixqJgF1J/Ps kyCd0l8S/UIYnalnEJaEgnkY/v1J5clqQd2ompaA9ULYBDqx84jxtLb8pRLkfuxyFFSD PzIrsGmRcC0onpfSU4vdOjmDH6+XebZuHsan8gGNR1sG4hwIAjbHa4UdrjyaDKXYfVEZ TzLZh+vOUHIsQ6QCnZKuvF3MYJ+ohASKpWJ/H2aXcBkY7HOfSiIOxKig8vN4iJ1I7EgV klCaiJ5fi89EyXqoPfbdATqymS7MkZcOKQ5y0sLms/NLAfHRdogPictn6Kfi4fdY2kOx fmfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776043425; x=1776648225; 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=qTdwOD5MvJj+i4G9bVPQNL0PRv4ibjmw6Xi5PZQFnqk=; b=hukUjFRwGR4bXWgTzj/1yN+Rz8bvGZpD2uuoM1BZN8TT9sMrKiLkG3d6MzRcjXxDNJ 2ZXPVi6W3ihY4zQzmCCNd+BzWZWD+QS472EB4fOzu/osvl6yRb/G9EAgEAJ8SuNzAxsf kFpRoVidQKKTc3Bxpje0x8PFRaOBa4ETp/rHBYQAus4+wu13r9gYvF15WdjUw6osZ0k6 ijGCGLEsPl5wRaLMkx8Ykd2C7oA4yljjSh9s45UKDXXTBTGe8HN0+iXoCbtj7ywGPhex c5y8DOTC/+6asrRVhj57nMAanHvlLL++zLLA2yMjzBfD0pzU9ZBEIhPDbmrmuEzvT9G8 TKmw== X-Forwarded-Encrypted: i=1; AJvYcCXSdQZ6lA6gW5qTNRpGxfzr0p9c+gskNyacSMZZs/kiAQTw//sqRDvPvWz1iPTpZ1qmtPtedix7pPEIDgg=@vger.kernel.org X-Gm-Message-State: AOJu0YzSgV1VRT9lMzeEw7KsBZwOHE/1IkfXgrP8zdB4lOT9fXgoThNH XEKDUqHhq50t5sJ3PZIEaHAFf7IEMe0UZe7vMuiR7Vgp5xzk4jApaaNCvHpjoDyVwZxHPnlbAR2 OsDMBLMwBnA== X-Received: from dybb21.prod.google.com ([2002:a05:693c:6095:b0:2d9:61d4:4d0e]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6726:b0:119:e56c:18ae with SMTP id a92af1059eb24-12c34ede8e2mr6175720c88.22.1776043424807; Sun, 12 Apr 2026 18:23:44 -0700 (PDT) Date: Sun, 12 Apr 2026 18:22:27 -0700 In-Reply-To: <20260413012227.1089445-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: <20260412020833.641177-1-irogers@google.com> <20260413012227.1089445-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260413012227.1089445-34-irogers@google.com> Subject: [PATCH v11 33/33] perf kwork: Fix memory management of kwork_work From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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" This commit addresses several memory management issues in builtin-kwork.c: 1. Implements a global cleanup function perf_kwork__exit to free all kwork_work and kwork_atom_page objects at the end of the command. 2. Ensures all 'name' fields in struct kwork_work are malloc-ed (or NULL) and properly freed by using strdup and zfree. 3. Fixes memory leaks in top_merge_tasks where kwork_work objects were dropped without being freed. 4. Adds robustness with NULL checks for name fields. 5. Fixes workqueue_work_init to correctly resolve and strdup kernel function names, preventing bad-free errors. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 125 ++++++++++++++++++++++++++++-------- tools/perf/util/bpf_kwork.c | 14 ++-- tools/perf/util/kwork.h | 2 + 3 files changed, 112 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index a4604e152002..75c50073c350 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -323,8 +323,8 @@ static struct kwork_work *work_search(struct rb_root_ca= ched *root, else if (cmp < 0) node =3D node->rb_right; else { - if (work->name =3D=3D NULL) - work->name =3D key->name; + if (work->name =3D=3D NULL && key->name !=3D NULL) + work->name =3D strdup(key->name); return work; } } @@ -371,11 +371,58 @@ static struct kwork_work *work_new(struct kwork_work = *key) =20 work->id =3D key->id; work->cpu =3D key->cpu; - work->name =3D key->name; + work->name =3D key->name ? strdup(key->name) : NULL; work->class =3D key->class; return work; } =20 +void work_exit(struct kwork_work *work) +{ + zfree(&work->name); +} + +static void work_delete(struct kwork_work *work) +{ + if (work) { + work_exit(work); + free(work); + } +} + +static void kwork_work__free_root(struct rb_root_cached *root) +{ + struct rb_node *next; + struct kwork_work *work; + + while ((next =3D rb_first_cached(root))) { + work =3D rb_entry(next, struct kwork_work, node); + rb_erase_cached(next, root); + work_delete(work); + } +} + +static void perf_kwork__exit(struct perf_kwork *kwork) +{ + struct kwork_class *class; + struct kwork_atom_page *page, *tmp_page; + + list_for_each_entry(class, &kwork->class_list, list) { + kwork_work__free_root(&class->work_root); + } + + kwork_work__free_root(&kwork->sorted_work_root); + + list_for_each_entry_safe(page, tmp_page, &kwork->atom_page_list, list) { + list_del_init(&page->list); + free(page); + } + + INIT_LIST_HEAD(&kwork->class_list); + INIT_LIST_HEAD(&kwork->atom_page_list); + INIT_LIST_HEAD(&kwork->sort_list); + INIT_LIST_HEAD(&kwork->cmp_id); +} + static struct kwork_work *work_findnew(struct rb_root_cached *root, struct kwork_work *key, struct list_head *sort_list) @@ -453,25 +500,29 @@ static int work_push_atom(struct perf_kwork *kwork, struct kwork_work **ret_work, bool overwrite) { - struct kwork_atom *atom, *dst_atom, *last_atom; + struct kwork_atom *atom =3D NULL, *dst_atom, *last_atom; struct kwork_work *work, key; + int ret =3D 0; =20 BUG_ON(class->work_init =3D=3D NULL); class->work_init(kwork, class, &key, src_type, sample, machine); =20 atom =3D atom_new(kwork, sample); - if (atom =3D=3D NULL) - return -1; + if (atom =3D=3D NULL) { + ret =3D -1; + goto out; + } =20 work =3D work_findnew(&class->work_root, &key, &kwork->cmp_id); if (work =3D=3D NULL) { atom_free(atom); - return -1; + ret =3D -1; + goto out; } =20 if (!profile_event_match(kwork, work, sample)) { atom_free(atom); - return 0; + goto out; } =20 if (dst_type < KWORK_TRACE_MAX) { @@ -498,8 +549,9 @@ static int work_push_atom(struct perf_kwork *kwork, } =20 list_add_tail(&atom->list, &work->atom_list[src_type]); - - return 0; +out: + work_exit(&key); + return ret; } =20 static struct kwork_atom *work_pop_atom(struct perf_kwork *kwork, @@ -510,7 +562,7 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, struct machine *machine, struct kwork_work **ret_work) { - struct kwork_atom *atom, *src_atom; + struct kwork_atom *atom =3D NULL, *src_atom; struct kwork_work *work, key; =20 BUG_ON(class->work_init =3D=3D NULL); @@ -521,15 +573,15 @@ static struct kwork_atom *work_pop_atom(struct perf_k= work *kwork, *ret_work =3D work; =20 if (work =3D=3D NULL) - return NULL; + goto out; =20 if (!profile_event_match(kwork, work, sample)) - return NULL; + goto out; =20 atom =3D list_last_entry_or_null(&work->atom_list[dst_type], struct kwork_atom, list); if (atom !=3D NULL) - return atom; + goto out; =20 src_atom =3D atom_new(kwork, sample); if (src_atom !=3D NULL) @@ -538,8 +590,9 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, if (ret_work !=3D NULL) *ret_work =3D NULL; } - - return NULL; +out: + work_exit(&key); + return atom; } =20 static struct kwork_work *find_work_by_id(struct rb_root_cached *root, @@ -1002,13 +1055,16 @@ static void irq_work_init(struct perf_kwork *kwork, work->name =3D NULL; } else { work->id =3D perf_sample__intval(sample, "irq"); - work->name =3D perf_sample__strval(sample, "name"); + work->name =3D strdup(perf_sample__strval(sample, "name") ?: ""= ); } } =20 static void irq_work_name(struct kwork_work *work, char *buf, int len) { - snprintf(buf, len, "%s:%" PRIu64 "", work->name, work->id); + if (work->name !=3D NULL) + snprintf(buf, len, "%s:%" PRIu64 "", work->name, work->id); + else + snprintf(buf, len, "%" PRIu64 "", work->id); } =20 static struct kwork_class kwork_irq =3D { @@ -1135,7 +1191,10 @@ static void softirq_work_init(struct perf_kwork *kwo= rk, =20 static void softirq_work_name(struct kwork_work *work, char *buf, int len) { - snprintf(buf, len, "(s)%s:%" PRIu64 "", work->name, work->id); + if (work->name !=3D NULL) + snprintf(buf, len, "(s)%s:%" PRIu64 "", work->name, work->id); + else + snprintf(buf, len, "(s)%" PRIu64 "", work->id); } =20 static struct kwork_class kwork_softirq =3D { @@ -1220,8 +1279,14 @@ static void workqueue_work_init(struct perf_kwork *k= work __maybe_unused, work->class =3D class; work->cpu =3D sample->cpu; work->id =3D perf_sample__intval(sample, "work"); - work->name =3D function_addr =3D=3D 0 ? NULL : - machine__resolve_kernel_addr(machine, &function_addr, &modp); + work->name =3D NULL; + + if (function_addr !=3D 0) { + const char *name =3D machine__resolve_kernel_addr(machine, &function_add= r, &modp); + + if (name) + work->name =3D strdup(name); + } } =20 static void workqueue_work_name(struct kwork_work *work, char *buf, int le= n) @@ -1284,16 +1349,16 @@ static void sched_work_init(struct perf_kwork *kwor= k __maybe_unused, =20 if (src_type =3D=3D KWORK_TRACE_EXIT) { work->id =3D perf_sample__intval(sample, "prev_pid"); - work->name =3D strdup(perf_sample__strval(sample, "prev_comm")); + work->name =3D strdup(perf_sample__strval(sample, "prev_comm") ?: ""); } else if (src_type =3D=3D KWORK_TRACE_ENTRY) { work->id =3D perf_sample__intval(sample, "next_pid"); - work->name =3D strdup(perf_sample__strval(sample, "next_comm")); + work->name =3D strdup(perf_sample__strval(sample, "next_comm") ?: ""); } } =20 static void sched_work_name(struct kwork_work *work, char *buf, int len) { - snprintf(buf, len, "%s", work->name); + snprintf(buf, len, "%s", work->name ?: ""); } =20 static struct kwork_class kwork_sched =3D { @@ -2100,8 +2165,10 @@ static void top_merge_tasks(struct perf_kwork *kwork) rb_erase_cached(node, &class->work_root); data =3D rb_entry(node, struct kwork_work, node); =20 - if (!profile_name_match(kwork, data)) + if (!profile_name_match(kwork, data)) { + work_delete(data); continue; + } =20 cpu =3D data->cpu; merged_work =3D find_work_by_id(&merged_root, data->id, @@ -2109,11 +2176,17 @@ static void top_merge_tasks(struct perf_kwork *kwor= k) if (!merged_work) { work_insert(&merged_root, data, &kwork->cmp_id); } else { + if (merged_work->name =3D=3D NULL && data->name !=3D NULL) + merged_work->name =3D strdup(data->name); + merged_work->total_runtime +=3D data->total_runtime; merged_work->cpu_usage +=3D data->cpu_usage; } =20 top_calc_load_runtime(kwork, data); + + if (merged_work) + work_delete(data); } =20 work_sort(kwork, class, &merged_root); @@ -2523,6 +2596,8 @@ int cmd_kwork(int argc, const char **argv) } else usage_with_options(kwork_usage, kwork_options); =20 + perf_kwork__exit(&kwork); + /* free usage string allocated by parse_options_subcommand */ free((void *)kwork_usage[0]); =20 diff --git a/tools/perf/util/bpf_kwork.c b/tools/perf/util/bpf_kwork.c index d3a2e548f2b6..2248f462a847 100644 --- a/tools/perf/util/bpf_kwork.c +++ b/tools/perf/util/bpf_kwork.c @@ -273,6 +273,7 @@ static int add_work(struct perf_kwork *kwork, .cpu =3D key->cpu, }; enum kwork_class_type type =3D key->type; + int ret =3D 0; =20 if (!valid_kwork_class_type(type)) { pr_debug("Invalid class type %d to add work\n", type); @@ -287,8 +288,10 @@ static int add_work(struct perf_kwork *kwork, return -1; =20 work =3D kwork->add_work(kwork, tmp.class, &tmp); - if (work =3D=3D NULL) - return -1; + if (work =3D=3D NULL) { + ret =3D -1; + goto out; + } =20 if (kwork->report =3D=3D KWORK_REPORT_RUNTIME) { work->nr_atoms =3D data->nr; @@ -304,13 +307,16 @@ static int add_work(struct perf_kwork *kwork, work->max_latency_end =3D data->max_time_end; } else { pr_debug("Invalid bpf report type %d\n", kwork->report); - return -1; + ret =3D -1; + goto out; } =20 kwork->timestart =3D (u64)ts_start.tv_sec * NSEC_PER_SEC + ts_start.tv_ns= ec; kwork->timeend =3D (u64)ts_end.tv_sec * NSEC_PER_SEC + ts_end.tv_nsec; =20 - return 0; +out: + work_exit(&tmp); + return ret; } =20 int perf_kwork__report_read_bpf(struct perf_kwork *kwork) diff --git a/tools/perf/util/kwork.h b/tools/perf/util/kwork.h index abf637d44794..c96f388b3159 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -164,6 +164,8 @@ struct kwork_class { char *buf, int len); }; =20 +void work_exit(struct kwork_work *work); + struct trace_kwork_handler { int (*raise_event)(struct perf_kwork *kwork, struct kwork_class *class, --=20 2.53.0.1213.gd9a14994de-goog