diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2026-10-17 14:44:32 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-17 14:44:33 +0000 |
| commit | ab21f979d6f2351db7f6b6f0e5e026eefd9965e8 (patch) | |
| tree | 50acda71545da25a684853c2f6500df627e8eb0b /tools/perf/scripts/python/stackcollapse.py | |
| parent | 458575e1f2ddea944d679fe778c92e370a9b61a4 (diff) | |
| parent | 631fee3f5a18b13f6d89df4e1c1146e71e420ea1 (diff) | |
Merge branch 'bpftool-fail-map-dump-for-maps-that-can-t-be-iterated'
Maxim Skokov says:
====================
bpftool: Fail map dump for maps that can't be iterated
"bpftool map dump" treats only ENOENT from bpf_map_get_next_key() as the
end of the map. Map types that can't be iterated (local storage, ringbuf,
bloom filter, arena, queue, stack) fail on the first key, and bpftool
prints an empty dump, "[]" or "Found 0 elements", with only a non-zero
exit status.
Patch 1 adds a helper that prints ENOTSUPP (524), which the kernel
returns from some BPF commands, as "Operation not supported" instead of
"Unknown error 524", and uses it for map create, map element
operations, map freeze and prog run. Patch 2 asks for the first key
before printing anything and fails with the map type and the error.
Patch 3 adds a test_progs case on a socket storage map, and on a queue
map without BTF for the plain output path.
The new test fails without patches 1-2 and passes with them; the other
bpftool_* selftests pass. v5 was tested on x86_64 under a bpf-next
kernel (d2141481a764e). The ENOTSUPP message was also checked by hand
for map getnext, lookup and dump on ringbuf and socket storage maps,
map create of an LRU hash without preallocation, and prog run on a
kprobe program; map delete, pop and freeze use the same helper but
were not checked by hand.
Changes in v5 (patches 1-2 of v4 are now patches 2-3):
- new patch 1: helper for ENOTSUPP, used in map dump and the other
places where bpftool prints the result of a command that can return
it (Daniel)
- patch 2 (map dump) uses the helper; kept Quentin's Acked-by as the
change is only the error string
- selftests: check the full error text for socket storage
- rebase on current bpf-next
Changes in v4:
- selftests: socket storage always has BTF, so the "Found" check could
never fail there; check the count on a queue map without BTF instead,
and fix the comment on create_sk_storage_map() (bpf-ci)
- selftests: split into sk_storage and queue subtests, new subject
- rebase on current bpf-next, patch 1 unchanged
Changes in v3:
- shorter comment on the probe (Quentin)
- selftests: unlink the pin on every exit path, so a killed run doesn't
leave a stale pin that fails every later run with EEXIST (Sashiko)
- collect Acked-by on patch 1
Changes in v2:
- probe the first key before any output instead of printing a hint for
ENOTSUPP only, so every non-iterable type gets an error and stdout gets
no "[]" (Alexei)
- drop the Fixes tag and use a neutral example map (Alexei)
- selftests: check that JSON output is only the error object and plain
stdout has no elements or count; clear the output buffer before each
run (Sashiko)
- multi-line comment style (bpf-ci)
v4: https://lore.kernel.org/bpf/20260928001513.7072-1-skokovmaksimevg@gmail.com/
v3: https://lore.kernel.org/bpf/20260926170149.541352-1-skokovmaksimevg@gmail.com/
v2: https://lore.kernel.org/bpf/20260925162031.27259-1-skokovmaksimevg@gmail.com/
v1: https://lore.kernel.org/bpf/20260924160732.485650-1-skokovmaksimevg@gmail.com/
====================
Link: https://patch.msgid.link/20261016194825.230433-1-skokovmaksimevg@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
