bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/3] Convert BPF UAPI constants into enum values
@ 2020-03-01  6:24 Andrii Nakryiko
  2020-03-01  6:24 ` [PATCH v2 bpf-next 1/3] bpf: switch BPF UAPI #define constants to enums Andrii Nakryiko
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Andrii Nakryiko @ 2020-03-01  6:24 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Convert BPF-related UAPI constants, currently defined as #define macro, into
anonymous enums. This has no difference in terms of usage of such constants in
C code (they are still could be used in all the compile-time contexts that
`#define`s can), but they are recorded as part of DWARF type info, and
subsequently get recorded as part of kernel's BTF type info. This allows those
constants to be emitted as part of vmlinux.h auto-generated header file and be
used from BPF programs. Which is especially convenient for all kinds of BPF
helper flags and makes CO-RE BPF programs nicer to write.

libbpf's btf_dump logic currently assumes enum values are signed 32-bit
values, but that doesn't match a typical case, so switch it to emit unsigned
values. Once BTF encoding of BTF_KIND_ENUM is extended to capture signedness
properly, this will be made more flexible.

As an immediate validation of the approach, runqslower's copy of
BPF_F_CURRENT_CPU #define is dropped in favor of its enum variant from
vmlinux.h.

v1->v2:
- fix up btf_dump test to use max 32-bit unsigned value instead of negative one.

Andrii Nakryiko (3):
  bpf: switch BPF UAPI #define constants to enums
  libbpf: assume unsigned values for BTF_KIND_ENUM
  tools/runqslower: drop copy/pasted BPF_F_CURRENT_CPU definiton

 include/uapi/linux/bpf.h                      | 272 ++++++++++-------
 include/uapi/linux/bpf_common.h               |  86 +++---
 include/uapi/linux/btf.h                      |  60 ++--
 tools/bpf/runqslower/runqslower.bpf.c         |   3 -
 tools/include/uapi/linux/bpf.h                | 274 +++++++++++-------
 tools/include/uapi/linux/bpf_common.h         |  86 +++---
 tools/include/uapi/linux/btf.h                |  60 ++--
 tools/lib/bpf/btf_dump.c                      |   8 +-
 .../bpf/progs/btf_dump_test_case_syntax.c     |   2 +-
 9 files changed, 502 insertions(+), 349 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-03-02 23:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-01  6:24 [PATCH v2 bpf-next 0/3] Convert BPF UAPI constants into enum values Andrii Nakryiko
2020-03-01  6:24 ` [PATCH v2 bpf-next 1/3] bpf: switch BPF UAPI #define constants to enums Andrii Nakryiko
2020-03-02 16:22   ` Yonghong Song
2020-03-02 18:25     ` Andrii Nakryiko
2020-03-02 18:33       ` Yonghong Song
2020-03-02 19:14         ` Andrii Nakryiko
2020-03-02 20:48         ` Daniel Borkmann
2020-03-02 22:37   ` Alexei Starovoitov
2020-03-02 23:14     ` Andrii Nakryiko
2020-03-01  6:24 ` [PATCH v2 bpf-next 2/3] libbpf: assume unsigned values for BTF_KIND_ENUM Andrii Nakryiko
2020-03-01  6:24 ` [PATCH v2 bpf-next 3/3] tools/runqslower: drop copy/pasted BPF_F_CURRENT_CPU definiton Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).