From: Ian Rogers Date: Tue, 19 Nov 2024 01:16:39 +0000 (-0800) Subject: perf kwork: Make perf_kwork_add_work a callback X-Git-Tag: v6.14-rc1~120^2~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9cf133c25cc261cd6c30ed0af55e22ac11cebbe4;p=thirdparty%2Flinux.git perf kwork: Make perf_kwork_add_work a callback perf_kwork_add_work is declared in builtin-kwork, whereas much kwork code is in util. To avoid needing to stub perf_kwork_add_work in python.c, add a callback to struct perf_kwork and initialize it in builtin-kwork to perf_kwork_add_work - this is the only struct perf_kwork. This removes the need for the stub in python.c. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Athira Rajeev Cc: Colin Ian King Cc: Dapeng Mi Cc: Howard Chu Cc: Ilya Leoshkevich Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Josh Poimboeuf Cc: Kan Liang Cc: Mark Rutland Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Richter Cc: Veronika Molnarova Cc: Weilin Wang Link: https://lore.kernel.org/r/20241119011644.971342-18-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 878c93c026b1d..c41a68d073deb 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1848,7 +1848,7 @@ static void process_skipped_events(struct perf_kwork *kwork, } } -struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork, +static struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *key) { @@ -2346,6 +2346,7 @@ int cmd_kwork(int argc, const char **argv) .all_runtime = 0, .all_count = 0, .nr_skipped_events = { 0 }, + .add_work = perf_kwork_add_work, }; static const char default_report_sort_order[] = "runtime, max, count"; static const char default_latency_sort_order[] = "avg, max, count"; diff --git a/tools/perf/util/bpf_kwork.c b/tools/perf/util/bpf_kwork.c index 6c7126b7670dd..5cff755c71fae 100644 --- a/tools/perf/util/bpf_kwork.c +++ b/tools/perf/util/bpf_kwork.c @@ -285,7 +285,7 @@ static int add_work(struct perf_kwork *kwork, (bpf_trace->get_work_name(key, &tmp.name))) return -1; - work = perf_kwork_add_work(kwork, tmp.class, &tmp); + work = kwork->add_work(kwork, tmp.class, &tmp); if (work == NULL) return -1; diff --git a/tools/perf/util/bpf_kwork_top.c b/tools/perf/util/bpf_kwork_top.c index 7261cad43468d..b6f187dd9136d 100644 --- a/tools/perf/util/bpf_kwork_top.c +++ b/tools/perf/util/bpf_kwork_top.c @@ -255,7 +255,7 @@ static int add_work(struct perf_kwork *kwork, struct work_key *key, bpf_trace = kwork_class_bpf_supported_list[type]; tmp.class = bpf_trace->class; - work = perf_kwork_add_work(kwork, tmp.class, &tmp); + work = kwork->add_work(kwork, tmp.class, &tmp); if (!work) return -1; diff --git a/tools/perf/util/kwork.h b/tools/perf/util/kwork.h index 596595946a060..db00269b73f24 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -252,12 +252,14 @@ struct perf_kwork { * perf kwork top data */ struct kwork_top_stat top_stat; -}; -struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork, + /* Add work callback. */ + struct kwork_work *(*add_work)(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *key); +}; + #ifdef HAVE_BPF_SKEL int perf_kwork__trace_prepare_bpf(struct perf_kwork *kwork); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 5e6db4b143a11..3e32a502a41c0 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -16,7 +16,6 @@ #include "thread_map.h" #include "trace-event.h" #include "mmap.h" -#include "util/kwork.h" #include "util/sample.h" #include @@ -1297,14 +1296,3 @@ error: PyErr_SetString(PyExc_ImportError, "perf: Init failed!"); return module; } - - -/* The following are stubs to avoid dragging in builtin-* objects. */ -/* TODO: move the code out of the builtin-* file into util. */ - -struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork __maybe_unused, - struct kwork_class *class __maybe_unused, - struct kwork_work *key __maybe_unused) -{ - return NULL; -}