[PATCH v1 12/26] perf trace: Use generic hashmap for bpf-trace-summary
From: Ian Rogers
Date: Fri Nov 13 2026 - 16:57:10 EST
Convert the syscall summary hashmaps in util/bpf-trace-summary.c to
DECLARE_HASHMAP(syscall_data_map, long, struct syscall_data *) and use
hashmap__for_each() instead of struct hashmap_entry iteration.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/bpf-trace-summary.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/tools/perf/util/bpf-trace-summary.c b/tools/perf/util/bpf-trace-summary.c
index 9a31dbf06cbb..2cc42f19d223 100644
--- a/tools/perf/util/bpf-trace-summary.c
+++ b/tools/perf/util/bpf-trace-summary.c
@@ -113,6 +113,8 @@ struct syscall_data {
struct syscall_node *nodes;
};
+DECLARE_HASHMAP(syscall_data_map, long, struct syscall_data *);
+
static int datacmp(const void *a, const void *b)
{
const struct syscall_data * const *sa = a;
@@ -169,7 +171,7 @@ static int print_common_stats(struct syscall_data *data, int max_summary, FILE *
return printed;
}
-static int update_thread_stats(struct hashmap *hash, struct syscall_key *map_key,
+static int update_thread_stats(struct syscall_data_map *hash, struct syscall_key *map_key,
struct syscall_stats *map_data)
{
struct syscall_data *data;
@@ -233,7 +235,7 @@ static int print_thread_stats(struct syscall_data **data, int nr_data, int max_s
return printed;
}
-static int update_total_stats(struct hashmap *hash, struct syscall_key *map_key,
+static int update_total_stats(struct syscall_data_map *hash, struct syscall_key *map_key,
struct syscall_stats *map_data)
{
struct syscall_data *data;
@@ -305,7 +307,7 @@ static int print_total_stats(struct syscall_data **data, int nr_data, int max_su
return printed;
}
-static int update_cgroup_stats(struct hashmap *hash, struct syscall_key *map_key,
+static int update_cgroup_stats(struct syscall_data_map *hash, struct syscall_key *map_key,
struct syscall_stats *map_data)
{
struct syscall_data *data;
@@ -379,12 +381,12 @@ int trace_print_bpf_summary(FILE *fp, int max_summary)
struct bpf_map *map = skel->maps.syscall_stats_map;
struct syscall_key *prev_key, key;
struct syscall_data **data = NULL;
- struct hashmap schash;
- struct hashmap_entry *entry;
+ struct syscall_data_map schash;
+ long entry_key;
+ struct syscall_data *entry_val;
int nr_data = 0;
int printed = 0;
int i;
- size_t bkt;
hashmap__init(&schash, sc_node_hash, sc_node_equal, /*ctx=*/NULL);
@@ -420,8 +422,8 @@ int trace_print_bpf_summary(FILE *fp, int max_summary)
goto out;
i = 0;
- hashmap__for_each_entry(&schash, entry, bkt)
- data[i++] = entry->pvalue;
+ hashmap__for_each(&schash, entry_key, entry_val)
+ data[i++] = entry_val;
qsort(data, nr_data, sizeof(*data), datacmp);
--
2.56.1.703.gf848ed807c-goog