Skip to content

'bpf_fastcall' attribute in vmlinux.h and bpf_helper_defs.h

Eduard Zingerman bpf 1 version Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 3 repliesApplied 4/4

Patches in v1 All 4 applied

#Subject and filesSizeRepliesApplied
1/4bpf: allow specifying bpf_fastcall attribute for BPF helpersscripts/bpf_doc.py+48 -22 repliesApplied
2/4bpf: __bpf_fastcall for bpf_get_smp_processor_id in uapiinclude/uapi/linux/bpf.h tools/include/uapi/linux/bpf.h+4 -00 repliesApplied
3/4bpf: use KF_FASTCALL to mark kfuncs supporting fastcall contractinclude/linux/btf.h kernel/bpf/helpers.c kernel/bpf/verifier.c+4 -60 repliesApplied
4/4bpftool: __bpf_fastcall for kfuncs marked with special decl_tagtools/bpf/bpftool/btf.c+88 -100 repliesApplied

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 v1 0/4] 'bpf_fastcall' attribute in vmlinux.h and bpf_helper_defs.h

The goal of this patch-set is to reflect attribute bpf_fastcall for supported helpers and kfuncs in generated header files. For helpers this requires a tweak for scripts/bpf_doc.py and an update to uapi/linux/bpf.h doc-comment.
For kfuncs this requires:
- introduction of a new KF_FASTCALL flag;
- modification to pahole to read kfunc flags and generate DECL_TAG "bpf_fastcall" for marked kfuncs;
- modification to bpftool to scan for DECL_TAG "bpf_fastcall" presence.

In both cases the following helper macro is defined in the generated header:

    #ifndef __bpf_fastcall
    #if __has_attribute(bpf_fastcall)
    #define __bpf_fastcall __attribute__((bpf_fastcall))
    #else
    #define __bpf_fastcall
    #endif
    #endif

And is used to mark appropriate function prototypes. More information about bpf_fastcall attribute could be found in [1] and [2].

Modifications to pahole are submitted separately.

[1] LLVM source tree commit:

    64e464349bfc ("[BPF] introduce __attribute__((bpf_fastcall))")

[2] Linux kernel tree commit (note: feature was renamed from no_caller_saved_registers to bpf_fastcall after this commit):
52839f31cece ("Merge branch 'no_caller_saved_registers-attribute-for-helper-calls'")

Eduard Zingerman (4):
bpf: allow specifying bpf_fastcall attribute for BPF helpers
bpf: __bpf_fastcall for bpf_get_smp_processor_id in uapi
bpf: use KF_FASTCALL to mark kfuncs supporting fastcall contract
bpftool: __bpf_fastcall for kfuncs marked with special decl_tag

 include/linux/btf.h            |  1 +
 include/uapi/linux/bpf.h       |  2 +
 kernel/bpf/helpers.c           |  4 +-
 kernel/bpf/verifier.c          |  5 +-
 scripts/bpf_doc.py             | 50 ++++++++++++++++-
 tools/bpf/bpftool/btf.c        | 98 ++++++++++++++++++++++++++++++----
 tools/include/uapi/linux/bpf.h |  2 +
 7 files changed, 144 insertions(+), 18 deletions(-)
Signature · 1 line
2.46.0