]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf buildid-list: Use perf_tool__init
authorIan Rogers <irogers@google.com>
Mon, 12 Aug 2024 20:46:59 +0000 (13:46 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 12 Aug 2024 21:07:10 +0000 (18:07 -0300)
Reduce scope of build_id__mark_dso_hit_ops() to the scope of function
perf_session__list_build_ids, its only use, and use perf_tool__init()
for the default values. Move perf_event__exit_del_thread() to event.[ch]
so it can be used in builtin-buildid-list.c.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Sun Haiyong <sunhaiyong@loongson.cn>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20240812204720.631678-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-buildid-list.c
tools/perf/util/build-id.c
tools/perf/util/build-id.h
tools/perf/util/event.c
tools/perf/util/event.h

index 383d5de36ce49f41b66acd78d57677b8dac0cd8a..52dfacaff8e39f6de2dc60fb8095bc2393ed5e21 100644 (file)
@@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
                .mode  = PERF_DATA_MODE_READ,
                .force = force,
        };
+       struct perf_tool build_id__mark_dso_hit_ops;
 
        symbol__elf_init();
        /*
@@ -97,6 +98,15 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
        if (filename__fprintf_build_id(input_name, stdout) > 0)
                goto out;
 
+       perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=*/true);
+       build_id__mark_dso_hit_ops.sample       = build_id__mark_dso_hit;
+       build_id__mark_dso_hit_ops.mmap         = perf_event__process_mmap;
+       build_id__mark_dso_hit_ops.mmap2        = perf_event__process_mmap2;
+       build_id__mark_dso_hit_ops.fork         = perf_event__process_fork;
+       build_id__mark_dso_hit_ops.exit         = perf_event__exit_del_thread;
+       build_id__mark_dso_hit_ops.attr         = perf_event__process_attr;
+       build_id__mark_dso_hit_ops.build_id     = perf_event__process_build_id;
+
        session = perf_session__new(&data, &build_id__mark_dso_hit_ops);
        if (IS_ERR(session))
                return PTR_ERR(session);
index 098fcc625d9196f8d2c85885a76f1b81662d8733..451d145fa4ed3339a66aa288b5c929925d09f3fd 100644 (file)
@@ -67,38 +67,6 @@ int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused,
        return 0;
 }
 
-static int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused,
-                                      union perf_event *event,
-                                      struct perf_sample *sample
-                                      __maybe_unused,
-                                      struct machine *machine)
-{
-       struct thread *thread = machine__findnew_thread(machine,
-                                                       event->fork.pid,
-                                                       event->fork.tid);
-
-       dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
-                   event->fork.ppid, event->fork.ptid);
-
-       if (thread) {
-               machine__remove_thread(machine, thread);
-               thread__put(thread);
-       }
-
-       return 0;
-}
-
-struct perf_tool build_id__mark_dso_hit_ops = {
-       .sample = build_id__mark_dso_hit,
-       .mmap   = perf_event__process_mmap,
-       .mmap2  = perf_event__process_mmap2,
-       .fork   = perf_event__process_fork,
-       .exit   = perf_event__exit_del_thread,
-       .attr            = perf_event__process_attr,
-       .build_id        = perf_event__process_build_id,
-       .ordered_events  = true,
-};
-
 int build_id__sprintf(const struct build_id *build_id, char *bf)
 {
        char *bid = bf;
index ae87c4c58d5b5f356f9edd727919ee70ef2950f2..a212497bfdb0a56e9424f847e5769e33bf54fac8 100644 (file)
@@ -16,11 +16,9 @@ struct build_id {
        size_t  size;
 };
 
-struct nsinfo;
-
-extern struct perf_tool build_id__mark_dso_hit_ops;
 struct dso;
 struct feat_fd;
+struct nsinfo;
 
 void build_id__init(struct build_id *bid, const u8 *data, size_t size);
 int build_id__sprintf(const struct build_id *build_id, char *bf);
index c2f0e7f40ad589762c5cbeac9dafca3502028afa..aac96d5d19170091438a4c9a063faec360934361 100644 (file)
@@ -426,6 +426,26 @@ int perf_event__process_exit(const struct perf_tool *tool __maybe_unused,
        return machine__process_exit_event(machine, event, sample);
 }
 
+int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused,
+                               union perf_event *event,
+                               struct perf_sample *sample __maybe_unused,
+                               struct machine *machine)
+{
+       struct thread *thread = machine__findnew_thread(machine,
+                                                       event->fork.pid,
+                                                       event->fork.tid);
+
+       dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
+                   event->fork.ppid, event->fork.ptid);
+
+       if (thread) {
+               machine__remove_thread(machine, thread);
+               thread__put(thread);
+       }
+
+       return 0;
+}
+
 size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp)
 {
        return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PRI_lx64" [%s%s%s]\n",
index 4b24f1c580fd570c5768e6c4c3808b72c9dbcfd1..f8742e6230a5ab0cbcd8e2fa8d04fefb70767780 100644 (file)
@@ -319,6 +319,10 @@ int perf_event__process_exit(const struct perf_tool *tool,
                             union perf_event *event,
                             struct perf_sample *sample,
                             struct machine *machine);
+int perf_event__exit_del_thread(const struct perf_tool *tool,
+                               union perf_event *event,
+                               struct perf_sample *sample,
+                               struct machine *machine);
 int perf_event__process_ksymbol(const struct perf_tool *tool,
                                union perf_event *event,
                                struct perf_sample *sample,