Skip to content

libbpf: Support uniform BTF-defined key/value specification across all BPF maps

Hengqi Chen bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2libbpf: Support uniform BTF-defined key/value specification across all BPF mapstools/lib/bpf/libbpf.c+24 -00 replies
2/2selftests/bpf: Use BTF-defined key/value for map definitionstools/testing/selftests/bpf/progs/kfree_skb.c tools/testing/selftests/bpf/progs/perf_event_stackmap.c tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c +10 more+38 -400 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/2] libbpf: Support uniform BTF-defined key/value specification across all BPF maps

Currently a bunch of (usually pretty specialized) BPF maps do not support specifying BTF types for they key and value. For such maps, specifying their definition like this:

  struct {
      __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
      __type(key, int);
      __type(value, int);
  } my_perf_buf SEC(".maps");

Would actually produce warnings about retrying BPF map creation without BTF. Users are forced to know such nuances and use __uint(key_size, 4) instead. This is non-uniform, annoying, and inconvenient.

This patch set teaches libbpf to recognize those specialized maps and removes BTF type IDs when creating BPF map. Also, update existing BPF selftests to exericse this change.

Hengqi Chen (2):
libbpf: Support uniform BTF-defined key/value specification across all
BPF maps
selftests/bpf: Use BTF-defined key/value for map definitions

 tools/lib/bpf/libbpf.c                        | 24 +++++++++++++++++++
 tools/testing/selftests/bpf/progs/kfree_skb.c |  4 ++--
 .../selftests/bpf/progs/perf_event_stackmap.c |  4 ++--
 .../bpf/progs/sockmap_verdict_prog.c          | 12 +++++-----
 .../selftests/bpf/progs/test_btf_map_in_map.c | 14 +++++------
 .../selftests/bpf/progs/test_map_in_map.c     | 10 ++++----
 .../bpf/progs/test_map_in_map_invalid.c       |  2 +-
 .../bpf/progs/test_pe_preserve_elems.c        |  8 +++----
 .../selftests/bpf/progs/test_perf_buffer.c    |  4 ++--
 .../bpf/progs/test_select_reuseport_kern.c    |  4 ++--
 .../bpf/progs/test_stacktrace_build_id.c      |  4 ++--
 .../selftests/bpf/progs/test_stacktrace_map.c |  4 ++--
 .../selftests/bpf/progs/test_tcpnotify_kern.c |  4 ++--
 .../selftests/bpf/progs/test_xdp_bpf2bpf.c    |  4 ++--
 14 files changed, 62 insertions(+), 40 deletions(-)

--
2.30.2