[PATCH v1 13/26] perf lock: Use generic hashmap for slab_hash
From: Ian Rogers
Date: Fri Nov 13 2026 - 17:05:27 EST
Convert slab_hash in util/bpf_lock_contention.c to
DECLARE_HASHMAP(slab_cache_map, u32, struct slab_cache_data *) and use
hashmap__for_each() during cleanup.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/bpf_lock_contention.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/bpf_lock_contention.c b/tools/perf/util/bpf_lock_contention.c
index c20bd075664e..2bd8e62d3265 100644
--- a/tools/perf/util/bpf_lock_contention.c
+++ b/tools/perf/util/bpf_lock_contention.c
@@ -20,9 +20,11 @@
#include "bpf_skel/lock_contention.skel.h"
#include "bpf_skel/lock_data.h"
+DECLARE_HASHMAP(slab_cache_map, u32, struct slab_cache_data *);
+
static struct lock_contention_bpf *skel;
static bool has_slab_iter;
-static struct hashmap slab_hash;
+static struct slab_cache_map slab_hash;
static size_t slab_cache_hash(long key, void *ctx __maybe_unused)
{
@@ -99,11 +101,11 @@ static void run_slab_cache_iter(void)
static void exit_slab_cache_iter(void)
{
- struct hashmap_entry *cur;
- unsigned bkt;
+ u32 id;
+ struct slab_cache_data *val;
- hashmap__for_each_entry(&slab_hash, cur, bkt)
- free(cur->pvalue);
+ hashmap__for_each(&slab_hash, id, val)
+ free(val);
hashmap__clear(&slab_hash);
}
--
2.56.1.703.gf848ed807c-goog