]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Allow specifying bpf_fastcall attribute for BPF helpers
authorEduard Zingerman <eddyz87@gmail.com>
Mon, 16 Sep 2024 09:17:09 +0000 (02:17 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Oct 2024 00:47:53 +0000 (17:47 -0700)
commit48b13cab1e7cb77def27cb89711fb5e3b04db972
tree0238a2ac2f6849e78399b96773776d8846a87391
parentd1334e88e10d483072eb123d3c383f681d151c3a
bpf: Allow specifying bpf_fastcall attribute for BPF helpers

Allow a new optional 'Attributes' section to be specified for helper
functions description, e.g.:

 * u32 bpf_get_smp_processor_id(void)
 *  ...
 *  Return
 *  ...
 *  Attributes
 *  __bpf_fastcall
 *

Generated header for the example above:

  #ifndef __bpf_fastcall
  #if __has_attribute(__bpf_fastcall)
  #define __bpf_fastcall __attribute__((bpf_fastcall))
  #else
  #define __bpf_fastcall
  #endif
  #endif
  ...
  __bpf_fastcall
  static __u32 (* const bpf_get_smp_processor_id)(void) = (void *) 8;

The following rules apply:
- when present, section must follow 'Return' section;
- attribute names are specified on the line following 'Attribute'
  keyword;
- attribute names are separated by spaces;
- section ends with an "empty" line (" *\n").

Valid attribute names are recorded in the ATTRS map.
ATTRS maps shortcut attribute name to correct C syntax.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240916091712.2929279-2-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
scripts/bpf_doc.py