History

Merge tag 'bpf-next-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Pull bpf updates from Alexei Starovoitov: - Add BPF uprobe session support (Jiri Olsa) - Optimize uprobe performance (Andrii Nakryiko) - Add bpf_fastcall support to helpers and kfuncs (Eduard Zingerman) - Avoid calling free_htab_elem() under hash map bucket lock (Hou Tao) - Prevent tailcall infinite loop caused by freplace (Leon Hwang) - Mark raw_tracepoint arguments as nullable (Kumar Kartikeya Dwivedi) - Introduce uptr support in the task local storage map (Martin KaFai Lau) - Stringify errno log messages in libbpf (Mykyta Yatsenko) - Add kmem_cache BPF iterator for perf's lock profiling (Namhyung Kim) - Support BPF objects of either endianness in libbpf (Tony Ambardar) - Add ksym to struct_ops trampoline to fix stack trace (Xu Kuohai) - Introduce private stack for eligible BPF programs (Yonghong Song) - Migrate samples/bpf tests to selftests/bpf test_progs (Daniel T. Lee) - Migrate test_sock to selftests/bpf test_progs (Jordan Rife) * tag 'bpf-next-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (152 commits) libbpf: Change hash_combine parameters from long to unsigned long selftests/bpf: Fix build error with llvm 19 libbpf: Fix memory leak in bpf_program__attach_uprobe_multi bpf: use common instruction history across all states bpf: Add necessary migrate_disable to range_tree. bpf: Do not alloc arena on unsupported arches selftests/bpf: Set test path for token/obj_priv_implicit_token_envvar selftests/bpf: Add a test for arena range tree algorithm bpf: Introduce range_tree data structure and use it in bpf arena samples/bpf: Remove unused variable in xdp2skb_meta_kern.c samples/bpf: Remove unused variables in tc_l2_redirect_kern.c bpftool: Cast variable `var` to long long bpf, x86: Propagate tailcall info only for subprogs bpf: Add kernel symbol for struct_ops trampoline bpf: Use function pointers count as struct_ops links count bpf: Remove unused member rcu from bpf_struct_ops_map selftests/bpf: Add struct_ops prog private stack tests bpf: Support private stack for struct_ops progs selftests/bpf: Add tracing prog private stack tests bpf, x86: Support private stack in jit ...

Linus Torvalds committed 1 year ago

Commit 6e95ef02 parents 43fb83c 2c8b09a211 files · +6961 −3473Browse files

Showing the changes to scripts (2 of 211 files). Show all

Unified · Split

2 files
  1. scripts/Makefile.btf +4 −2
  2. scripts/bpf_doc.py +50 −3
scripts/Makefile.btf+4−2
@@ -3,6 +3,8 @@ · 2 unmodified lines
33 pahole-ver := $(CONFIG_PAHOLE_VERSION)
44 pahole-flags-y :=
55
6+JOBS := $(patsubst -j%,%,$(filter -j%,$(MAKEFLAGS)))
7+
68 ifeq ($(call test-le, $(pahole-ver), 125),y)
79
810 # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
@@ -12,14 +14,14 @@ endif · 3 unmodified lines
1214
1315 pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats
1416
15−pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j
17+pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j$(JOBS)
1618
1719 pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized
1820
1921 else
2022
2123 # Switch to using --btf_features for v1.26 and later.
22−pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
24+pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
2325
2426 ifneq ($(KBUILD_EXTMOD),)
2527 module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base
scripts/bpf_doc.py+50−3
@@ -37,10 +37,11 @@ class APIElement(object): · 36 unmodified lines
3737 @desc: textual description of the symbol
3838 @ret: (optional) description of any associated return value
3939 """
40− def __init__(self, proto='', desc='', ret=''):
40+ def __init__(self, proto='', desc='', ret='', attrs=[]):
4141 self.proto = proto
4242 self.desc = desc
4343 self.ret = ret
44+ self.attrs = attrs
4445
4546
4647 class Helper(APIElement):
@@ -81,6 +82,11 @@ class Helper(APIElement): · 34 unmodified lines
8182 return res
8283
8384
85+ATTRS = {
86+ '__bpf_fastcall': 'bpf_fastcall'
87+}
88+
89+
8490 class HeaderParser(object):
8591 """
8692 An object used to parse a file in order to extract the documentation of a
@@ -111,7 +117,8 @@ class HeaderParser(object): · 24 unmodified lines
111117 proto = self.parse_proto()
112118 desc = self.parse_desc(proto)
113119 ret = self.parse_ret(proto)
114− return Helper(proto=proto, desc=desc, ret=ret)
120+ attrs = self.parse_attrs(proto)
121+ return Helper(proto=proto, desc=desc, ret=ret, attrs=attrs)
115122
116123 def parse_symbol(self):
117124 p = re.compile(r' \* ?(BPF\w+)$')
@@ -192,6 +199,28 @@ class HeaderParser(object): · 74 unmodified lines
192199 raise Exception("No return found for " + proto)
193200 return ret
194201
202+ def parse_attrs(self, proto):
203+ p = re.compile(r' \* ?(?:\t| {5,8})Attributes$')
204+ capture = p.match(self.line)
205+ if not capture:
206+ return []
207+ # Expect a single line with mnemonics for attributes separated by spaces
208+ self.line = self.reader.readline()
209+ p = re.compile(r' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
210+ capture = p.match(self.line)
211+ if not capture:
212+ raise Exception("Incomplete 'Attributes' section for " + proto)
213+ attrs = capture.group(1).split(' ')
214+ for attr in attrs:
215+ if attr not in ATTRS:
216+ raise Exception("Unexpected attribute '" + attr + "' specified for " + proto)
217+ self.line = self.reader.readline()
218+ if self.line != ' *\n':
219+ raise Exception("Expecting empty line after 'Attributes' section for " + proto)
220+ # Prepare a line for next self.parse_* to consume
221+ self.line = self.reader.readline()
222+ return attrs
223+
195224 def seek_to(self, target, help_message, discard_lines = 1):
196225 self.reader.seek(0)
197226 offset = self.reader.read().find(target)
@@ -789,6 +818,21 @@ class PrinterHelpers(Printer): · 591 unmodified lines
789818 print('%s;' % fwd)
790819 print('')
791820
821+ used_attrs = set()
822+ for helper in self.elements:
823+ for attr in helper.attrs:
824+ used_attrs.add(attr)
825+ for attr in sorted(used_attrs):
826+ print('#ifndef %s' % attr)
827+ print('#if __has_attribute(%s)' % ATTRS[attr])
828+ print('#define %s __attribute__((%s))' % (attr, ATTRS[attr]))
829+ print('#else')
830+ print('#define %s' % attr)
831+ print('#endif')
832+ print('#endif')
833+ if used_attrs:
834+ print('')
835+
792836 def print_footer(self):
793837 footer = ''
794838 print(footer)
@@ -827,7 +871,10 @@ class PrinterHelpers(Printer): · 32 unmodified lines
827871 print(' *{}{}'.format(' \t' if line else '', line))
828872
829873 print(' */')
830− print('static %s %s(* const %s)(' % (self.map_type(proto['ret_type']),
874+ print('static ', end='')
875+ if helper.attrs:
876+ print('%s ' % (" ".join(helper.attrs)), end='')
877+ print('%s %s(* const %s)(' % (self.map_type(proto['ret_type']),
831878 proto['ret_star'], proto['name']), end='')
832879 comma = ''
833880 for i, a in enumerate(proto['args']):