[PATCH bpf-next] bpftool: Print map_extra in map show
From: chenyuan_fl
Date: Fri Oct 16 2026 - 03:20:27 EST
From: Yuan Chen <chenyuan@xxxxxxxxxx>
bpf_map_info::map_extra carries per-map-type creation attributes
(hash function count for bloom filter, VMA start for arena). The
kernel prints it in fdinfo, but bpftool does not. Print the raw
value in plain and JSON output when non-zero, without interpreting
it per map type, like map_flags. The attribute is already overloaded
per map type, and bpftool must not grow per-type knowledge of it.
Example (bloom filter with 7 hash functions):
117665: bloom_filter name featu_bloom flags 0x0
key 0B value 8B max_entries 128 map_extra 0x7 memlock 520B
pids fixture(3543054)
Signed-off-by: Yuan Chen <chenyuan@xxxxxxxxxx>
---
tools/bpf/bpftool/map.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 20d59eab09a1..62e36c7934ff 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -483,6 +483,8 @@ static int show_map_close_json(int fd, struct bpf_map_info *info)
jsonw_uint_field(json_wtr, "bytes_key", info->key_size);
jsonw_uint_field(json_wtr, "bytes_value", info->value_size);
jsonw_uint_field(json_wtr, "max_entries", info->max_entries);
+ if (info->map_extra)
+ jsonw_lluint_field(json_wtr, "map_extra", info->map_extra);
if (memlock)
jsonw_int_field(json_wtr, "bytes_memlock", atoll(memlock));
@@ -570,6 +572,8 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
show_map_header_plain(info);
printf("\tkey %uB value %uB max_entries %u",
info->key_size, info->value_size, info->max_entries);
+ if (info->map_extra)
+ printf(" map_extra %#llx", (unsigned long long)info->map_extra);
if (memlock)
printf(" memlock %sB", memlock);
--
2.54.0