From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Eric Biggers <ebiggers@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Haibo Xu <haibo1.xu@intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH v1 4/5] perf bpf_map: Remove unused code
Date: Sat, 7 Feb 2026 00:24:27 -0800 [thread overview]
Message-ID: <20260207082428.1742209-5-irogers@google.com> (raw)
In-Reply-To: <20260207082428.1742209-1-irogers@google.com>
bpf_map__fprintf is unused so delete it, the header file declaring it
and the now unused static helper functions.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/builtin-trace.c | 1 -
tools/perf/util/Build | 1 -
tools/perf/util/bpf_map.c | 70 --------------------------------------
tools/perf/util/bpf_map.h | 23 -------------
4 files changed, 95 deletions(-)
delete mode 100644 tools/perf/util/bpf_map.c
delete mode 100644 tools/perf/util/bpf_map.h
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 311d9da9896a..2aaa3ff452ac 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -21,7 +21,6 @@
#include <bpf/libbpf.h>
#include <bpf/btf.h>
#endif
-#include "util/bpf_map.h"
#include "util/rlimit.h"
#include "builtin.h"
#include "util/cgroup.h"
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 89de23dec401..70cc91d00804 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -170,7 +170,6 @@ perf-util-y += mutex.o
perf-util-y += sharded_mutex.o
perf-util-y += intel-tpebs.o
-perf-util-$(CONFIG_LIBBPF) += bpf_map.o
perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter.o
perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter_cgroup.o
perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_ftrace.o
diff --git a/tools/perf/util/bpf_map.c b/tools/perf/util/bpf_map.c
deleted file mode 100644
index 442f91b4e8e1..000000000000
--- a/tools/perf/util/bpf_map.c
+++ /dev/null
@@ -1,70 +0,0 @@
-// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
-
-#include "util/bpf_map.h"
-#include <bpf/bpf.h>
-#include <bpf/libbpf.h>
-#include <linux/err.h>
-#include <linux/kernel.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static bool bpf_map__is_per_cpu(enum bpf_map_type type)
-{
- return type == BPF_MAP_TYPE_PERCPU_HASH ||
- type == BPF_MAP_TYPE_PERCPU_ARRAY ||
- type == BPF_MAP_TYPE_LRU_PERCPU_HASH ||
- type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE;
-}
-
-static void *bpf_map__alloc_value(const struct bpf_map *map)
-{
- if (bpf_map__is_per_cpu(bpf_map__type(map)))
- return malloc(round_up(bpf_map__value_size(map), 8) *
- sysconf(_SC_NPROCESSORS_CONF));
-
- return malloc(bpf_map__value_size(map));
-}
-
-int bpf_map__fprintf(struct bpf_map *map, FILE *fp)
-{
- void *prev_key = NULL, *key, *value;
- int fd = bpf_map__fd(map), err;
- int printed = 0;
-
- if (fd < 0)
- return fd;
-
- err = -ENOMEM;
- key = malloc(bpf_map__key_size(map));
- if (key == NULL)
- goto out;
-
- value = bpf_map__alloc_value(map);
- if (value == NULL)
- goto out_free_key;
-
- while ((err = bpf_map_get_next_key(fd, prev_key, key) == 0)) {
- int intkey = *(int *)key;
-
- if (!bpf_map_lookup_elem(fd, key, value)) {
- bool boolval = *(bool *)value;
- if (boolval)
- printed += fprintf(fp, "[%d] = %d,\n", intkey, boolval);
- } else {
- printed += fprintf(fp, "[%d] = ERROR,\n", intkey);
- }
-
- prev_key = key;
- }
-
- if (err == ENOENT)
- err = printed;
-
- free(value);
-out_free_key:
- free(key);
-out:
- return err;
-}
diff --git a/tools/perf/util/bpf_map.h b/tools/perf/util/bpf_map.h
deleted file mode 100644
index c2f7c13cba23..000000000000
--- a/tools/perf/util/bpf_map.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
-#ifndef __PERF_BPF_MAP_H
-#define __PERF_BPF_MAP_H 1
-
-#include <stdio.h>
-struct bpf_map;
-
-#ifdef HAVE_LIBBPF_SUPPORT
-
-int bpf_map__fprintf(struct bpf_map *map, FILE *fp);
-
-#else
-
-#include <linux/compiler.h>
-
-static inline int bpf_map__fprintf(struct bpf_map *map __maybe_unused, FILE *fp __maybe_unused)
-{
- return 0;
-}
-
-#endif // HAVE_LIBBPF_SUPPORT
-
-#endif // __PERF_BPF_MAP_H
--
2.53.0.239.g8d8fc8a987-goog
next prev parent reply other threads:[~2026-02-07 8:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-07 8:24 [PATCH v1 0/5] perf tool: Minor code clean ups Ian Rogers
2026-02-07 8:24 ` [PATCH v1 1/5] perf symbol: Reduce scope of elf__needs_adjust_symbols Ian Rogers
2026-02-07 8:24 ` [PATCH v1 2/5] perf dump-insn: Remove dump-insn.c Ian Rogers
2026-02-07 8:24 ` [PATCH v1 3/5] perf tool: Constify the command and option arrays Ian Rogers
2026-02-07 8:24 ` Ian Rogers [this message]
2026-02-07 8:24 ` [PATCH v1 5/5] perf record: Remove unused cpu-set-sched.h Ian Rogers
2026-03-12 20:40 ` [PATCH v1 0/5] perf tool: Minor code clean ups Ian Rogers
2026-03-13 21:26 ` Namhyung Kim
2026-03-14 17:42 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260207082428.1742209-5-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ebiggers@kernel.org \
--cc=haibo1.xu@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=stephen.s.brennan@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox