summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-05-20 12:05:19 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-05-20 16:39:40 -0300
commit511bcd0ca0fff7c47658eb80faff867830a24148 (patch)
tree25e82919805a1c5b872fc66bd0f999283e90a061
parented9475b215d5fbe8412fb9c52cf34dd6a3f2f350 (diff)
perf kmem: Don't pass evsel with sample
As struct perf_sample now directly contains its own resolved evsel pointer, passing the evsel separately is redundant and clutters the interface. Remove the redundant evsel parameter from kmem-specific handlers and structures, ensuring the tool always directly accesses the evsel bound to the sample. This simplifies the API signatures and eliminates the risk of passing an inconsistent evsel. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Jones <ajones@ventanamicro.com> Cc: Anup Patel <anup@brainfault.org> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Blake Jones <blakejones@google.com> Cc: Chen Ni <nichen@iscas.ac.cn> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Derek Foreman <derek.foreman@collabora.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Howard Chu <howardchu95@gmail.com> Cc: Hrishikesh Suresh <hrishikesh123s@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Krzysztof Ɓopatowski <krzysztof.m.lopatowski@gmail.com> Cc: Leo Yan <leo.yan@arm.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quan Zhou <zhouquan@iscas.ac.cn> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Swapnil Sapkal <swapnil.sapkal@amd.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Tianyou Li <tianyou.li@intel.com> Cc: Yujie Liu <yujie.liu@intel.com> Cc: tanze <tanze@kylinos.cn> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-kmem.c26
1 files 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;
}
-static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sample *sample)
+static int evsel__process_alloc_event(struct perf_sample *sample)
{
unsigned long ptr = perf_sample__intval(sample, "ptr"),
call_site = perf_sample__intval(sample, "call_site");
@@ -198,7 +198,7 @@ static int evsel__process_alloc_event(struct evsel *evsel, 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;
node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu});
@@ -243,7 +243,7 @@ static struct alloc_stat *search_alloc_stat(unsigned long ptr,
return NULL;
}
-static int evsel__process_free_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample)
+static int evsel__process_free_event(struct perf_sample *sample)
{
unsigned long ptr = 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;
}
-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_flags)
{
struct tep_record record = {
.cpu = sample->cpu,
@@ -773,7 +772,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct perf_sample *sample,
}
trace_seq_init(&seq);
- tp_format = evsel__tp_format(evsel);
+ tp_format = evsel__tp_format(sample->evsel);
if (tp_format)
tep_print_event(tp_format->tep, &seq, &record, "%s", TEP_PRINT_INFO);
@@ -805,7 +804,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct perf_sample *sample,
return 0;
}
-static int evsel__process_page_alloc_event(struct evsel *evsel, struct perf_sample *sample)
+static int evsel__process_page_alloc_event(struct perf_sample *sample)
{
u64 page;
unsigned int order = perf_sample__intval(sample, "order");
@@ -835,7 +834,7 @@ static int evsel__process_page_alloc_event(struct evsel *evsel, struct perf_samp
return 0;
}
- if (parse_gfp_flags(evsel, sample, gfp_flags) < 0)
+ if (parse_gfp_flags(sample, gfp_flags) < 0)
return -1;
callsite = find_callsite(sample);
@@ -876,8 +875,7 @@ static int evsel__process_page_alloc_event(struct evsel *evsel, struct perf_samp
return 0;
}
-static int evsel__process_page_free_event(struct evsel *evsel __maybe_unused,
- struct perf_sample *sample)
+static int evsel__process_page_free_event(struct perf_sample *sample)
{
u64 page;
unsigned int order = perf_sample__intval(sample, "order");
@@ -954,8 +952,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *sample)
return false;
}
-typedef int (*tracepoint_handler)(struct evsel *evsel,
- struct perf_sample *sample);
+typedef int (*tracepoint_handler)(struct perf_sample *sample);
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
union perf_event *event,
@@ -973,14 +970,15 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
return -1;
}
- if (perf_kmem__skip_sample(sample))
+ if (perf_kmem__skip_sample(sample)) {
return 0;
+ }
dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread__tid(thread));
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
- err = f(evsel, sample);
+ err = f(sample);
}
thread__put(thread);