Skip to contentSkip to conversation

perf: Deadcode removal

PATCH Applied [email protected] 3 participants 4 messages Feb 4, 2025 – Feb 12, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Deadcode removal

From: "Dr. David Alan Gilbert" <[email protected]>

The last use of machine__fprintf_vmlinux_path() was removed in 2011 by commit ab81f3fd350c ("perf top: Reuse the 'report' hist_entry/hists classes")

mmap_cpu_mask__duplicate() was added in 2021 by
commit 6bd006c6eb7f ("perf mmap: Introduce mmap_cpu_mask__duplicate()") but hasn't been used since.

Remove them.

---
 tools/perf/util/machine.c | 20 --------------------
 tools/perf/util/machine.h |  2 --
 tools/perf/util/mmap.c    | 11 -----------
 tools/perf/util/mmap.h    |  3 ---
 4 files changed, 36 deletions(-)
tools/perf/util/machine.c +0 -20
index 2d51badfbf2e..321cc110698c 100644
@@ -886,26 +886,6 @@ size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp,
 	return ret;
 }
 
-size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp)
-{
-	int i;
-	size_t printed = 0;
-	struct dso *kdso = machine__kernel_dso(machine);
-
-	if (dso__has_build_id(kdso)) {
-		char filename[PATH_MAX];
-
-		if (dso__build_id_filename(kdso, filename, sizeof(filename), false))
-			printed += fprintf(fp, "[0] %s\n", filename);
-	}
-
-	for (i = 0; i < vmlinux_path__nr_entries; ++i) {
-		printed += fprintf(fp, "[%d] %s\n", i + dso__has_build_id(kdso),
-				   vmlinux_path[i]);
-	}
-	return printed;
-}
-
 struct machine_fprintf_cb_args {
 	FILE *fp;
 	size_t printed;
tools/perf/util/machine.h +0 -2
index 2e5a4cb342d8..ae3e5542d57d 100644
@@ -266,8 +266,6 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid);
 int machines__create_guest_kernel_maps(struct machines *machines);
 void machines__destroy_kernel_maps(struct machines *machines);
 
-size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
-
 typedef int (*machine__dso_t)(struct dso *dso, struct machine *machine, void *priv);
 
 int machine__for_each_dso(struct machine *machine, machine__dso_t fn,
tools/perf/util/mmap.c +0 -11
index 43b02293f1d2..a7ef4d8d57d8 100644
@@ -356,14 +356,3 @@ int perf_mmap__push(struct mmap *md, void *to,
 out:
 	return rc;
 }
-
-int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original, struct mmap_cpu_mask *clone)
-{
-	clone->nbits = original->nbits;
-	clone->bits  = bitmap_zalloc(original->nbits);
-	if (!clone->bits)
-		return -ENOMEM;
-
-	memcpy(clone->bits, original->bits, MMAP_CPU_MASK_BYTES(original));
-	return 0;
-}
tools/perf/util/mmap.h +0 -3
index 0df6e1621c7e..4d72c5fa5084 100644
@@ -61,7 +61,4 @@ size_t mmap__mmap_len(struct mmap *map);
 
 void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
 
-int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original,
-				struct mmap_cpu_mask *clone);
-
 #endif /*__PERF_MMAP_H */
Signature · 1 line
2.48.1
reviewer Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Tue, Feb 4, 2025 at 2:05 PM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The last use of machine__fprintf_vmlinux_path() was removed in 2011 by commit ab81f3fd350c ("perf top: Reuse the 'report' hist_entry/hists classes")

Quoted 7 lines

mmap_cpu_mask__duplicate() was added in 2021 by
commit 6bd006c6eb7f ("perf mmap: Introduce mmap_cpu_mask__duplicate()") but hasn't been used since.

Remove them.

Thanks!
Ian

Quoted 85 lines
---
 tools/perf/util/machine.c | 20 --------------------
 tools/perf/util/machine.h |  2 --
 tools/perf/util/mmap.c    | 11 -----------
 tools/perf/util/mmap.h    |  3 ---
 4 files changed, 36 deletions(-)
tools/perf/util/machine.c +0 -20
index 2d51badfbf2e..321cc110698c 100644
@@ -886,26 +886,6 @@ size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp,
        return ret;
 }
 
-size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp)
-{
-       int i;
-       size_t printed = 0;
-       struct dso *kdso = machine__kernel_dso(machine);
-
-       if (dso__has_build_id(kdso)) {
-               char filename[PATH_MAX];
-
-               if (dso__build_id_filename(kdso, filename, sizeof(filename), false))
-                       printed += fprintf(fp, "[0] %s\n", filename);
-       }
-
-       for (i = 0; i < vmlinux_path__nr_entries; ++i) {
-               printed += fprintf(fp, "[%d] %s\n", i + dso__has_build_id(kdso),
-                                  vmlinux_path[i]);
-       }
-       return printed;
-}
-
 struct machine_fprintf_cb_args {
        FILE *fp;
        size_t printed;
tools/perf/util/machine.h +0 -2
index 2e5a4cb342d8..ae3e5542d57d 100644
@@ -266,8 +266,6 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid);
 int machines__create_guest_kernel_maps(struct machines *machines);
 void machines__destroy_kernel_maps(struct machines *machines);
 
-size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
-
 typedef int (*machine__dso_t)(struct dso *dso, struct machine *machine, void *priv);
 
 int machine__for_each_dso(struct machine *machine, machine__dso_t fn,
tools/perf/util/mmap.c +0 -11
index 43b02293f1d2..a7ef4d8d57d8 100644
@@ -356,14 +356,3 @@ int perf_mmap__push(struct mmap *md, void *to,
 out:
        return rc;
 }
-
-int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original, struct mmap_cpu_mask *clone)
-{
-       clone->nbits = original->nbits;
-       clone->bits  = bitmap_zalloc(original->nbits);
-       if (!clone->bits)
-               return -ENOMEM;
-
-       memcpy(clone->bits, original->bits, MMAP_CPU_MASK_BYTES(original));
-       return 0;
-}
tools/perf/util/mmap.h +0 -4
index 0df6e1621c7e..4d72c5fa5084 100644
@@ -61,7 +61,4 @@ size_t mmap__mmap_len(struct mmap *map);
 
 void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
 
-int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original,
-                               struct mmap_cpu_mask *clone);
-
 #endif /*__PERF_MMAP_H */
--

2.48.1

reviewer
#2 lore raw
Quoted 13 lines · Ian Rogers
Quoted 11 lines · On Tue, Feb 4, 2025 at 2:05 PM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The last use of machine__fprintf_vmlinux_path() was removed in 2011 by commit ab81f3fd350c ("perf top: Reuse the 'report' hist_entry/hists classes")

mmap_cpu_mask__duplicate() was added in 2021 by
commit 6bd006c6eb7f ("perf mmap: Introduce mmap_cpu_mask__duplicate()") but hasn't been used since.

Quoted 5 lines
Quoted 3 lines

Remove them.

Ping.

Thanks,
Ian

maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Tue, 04 Feb 2025 22:05:45 +0000, [email protected] wrote:

The last use of machine__fprintf_vmlinux_path() was removed in 2011 by commit ab81f3fd350c ("perf top: Reuse the 'report' hist_entry/hists classes")

mmap_cpu_mask__duplicate() was added in 2021 by
commit 6bd006c6eb7f ("perf mmap: Introduce mmap_cpu_mask__duplicate()") but hasn't been used since.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung