Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'bpf-prog-build'

Jiong Wang says:

====================
This set improves bpf object file related rules in selftests Makefile.
- tell git to ignore the build dir "alu32".
- extend sub-register mode compilation to all bpf object files to give
LLVM compiler bpf back-end more exercise.
- auto-generate bpf kernel object file list.
- relax sub-register mode compilation criteria.

v1 -> v2:
- rename "kern_progs" to "progs". (Alexei)
- spin a new patch to remove build server kernel requirement for
sub-register mode compilation (Alexei)
- rebase on top of KaFai’s latest "test_sock_fields" patch set.
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+11 -33
+1
tools/testing/selftests/bpf/.gitignore
··· 29 29 test_section_names 30 30 test_tcpnotify_user 31 31 test_libbpf 32 + alu32
+10 -33
tools/testing/selftests/bpf/Makefile
··· 25 25 test_socket_cookie test_cgroup_storage test_select_reuseport test_section_names \ 26 26 test_netcnt test_tcpnotify_user test_sock_fields 27 27 28 - BPF_OBJ_FILES = \ 29 - test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \ 30 - sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o \ 31 - test_tcpnotify_kern.o sample_map_ret0.o test_tcpbpf_kern.o \ 32 - sockmap_tcp_msg_prog.o connect4_prog.o connect6_prog.o \ 33 - test_btf_haskv.o test_btf_nokv.o test_sockmap_kern.o \ 34 - test_tunnel_kern.o test_sockhash_kern.o test_lwt_seg6local.o \ 35 - sendmsg4_prog.o sendmsg6_prog.o test_lirc_mode2_kern.o \ 36 - get_cgroup_id_kern.o socket_cookie_prog.o test_select_reuseport_kern.o \ 37 - test_skb_cgroup_id_kern.o bpf_flow.o netcnt_prog.o test_xdp_vlan.o \ 38 - xdp_dummy.o test_map_in_map.o test_spin_lock.o test_map_lock.o \ 39 - test_sock_fields_kern.o 28 + BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c))) 29 + TEST_GEN_FILES = $(BPF_OBJ_FILES) 40 30 41 - # Objects are built with default compilation flags and with sub-register 42 - # code-gen enabled. 43 - BPF_OBJ_FILES_DUAL_COMPILE = \ 44 - test_pkt_access.o test_pkt_access.o test_xdp.o test_adjust_tail.o \ 45 - test_l4lb.o test_l4lb_noinline.o test_xdp_noinline.o test_tcp_estats.o \ 46 - test_obj_id.o test_pkt_md_access.o test_tracepoint.o \ 47 - test_stacktrace_map.o test_stacktrace_map.o test_stacktrace_build_id.o \ 48 - test_stacktrace_build_id.o test_get_stack_rawtp.o \ 49 - test_get_stack_rawtp.o test_tracepoint.o test_sk_lookup_kern.o \ 50 - test_queue_map.o test_stack_map.o 51 - 52 - TEST_GEN_FILES = $(BPF_OBJ_FILES) $(BPF_OBJ_FILES_DUAL_COMPILE) 53 - 54 - # Also test sub-register code-gen if LLVM + kernel both has eBPF v3 processor 55 - # support which is the first version to contain both ALU32 and JMP32 56 - # instructions. 31 + # Also test sub-register code-gen if LLVM has eBPF v3 processor support which 32 + # contains both ALU32 and JMP32 instructions. 57 33 SUBREG_CODEGEN := $(shell echo "int cal(int a) { return a > 0; }" | \ 58 34 $(CLANG) -target bpf -O2 -emit-llvm -S -x c - -o - | \ 59 - $(LLC) -mattr=+alu32 -mcpu=probe 2>&1 | \ 35 + $(LLC) -mattr=+alu32 -mcpu=v3 2>&1 | \ 60 36 grep 'if w') 61 37 ifneq ($(SUBREG_CODEGEN),) 62 - TEST_GEN_FILES += $(patsubst %.o,alu32/%.o, $(BPF_OBJ_FILES_DUAL_COMPILE)) 38 + TEST_GEN_FILES += $(patsubst %.o,alu32/%.o, $(BPF_OBJ_FILES)) 63 39 endif 64 40 65 41 # Order correspond to 'make run_tests' order ··· 166 190 $(CC) $(CFLAGS) -o $(ALU32_BUILD_DIR)/test_progs_32 $< \ 167 191 trace_helpers.c $(OUTPUT)/libbpf.a $(LDLIBS) 168 192 169 - $(ALU32_BUILD_DIR)/%.o: %.c $(ALU32_BUILD_DIR) $(ALU32_BUILD_DIR)/test_progs_32 193 + $(ALU32_BUILD_DIR)/%.o: progs/%.c $(ALU32_BUILD_DIR) \ 194 + $(ALU32_BUILD_DIR)/test_progs_32 170 195 $(CLANG) $(CLANG_FLAGS) \ 171 196 -O2 -target bpf -emit-llvm -c $< -o - | \ 172 197 $(LLC) -march=bpf -mattr=+alu32 -mcpu=$(CPU) $(LLC_FLAGS) \ ··· 179 202 180 203 # Have one program compiled without "-target bpf" to test whether libbpf loads 181 204 # it successfully 182 - $(OUTPUT)/test_xdp.o: test_xdp.c 205 + $(OUTPUT)/test_xdp.o: progs/test_xdp.c 183 206 $(CLANG) $(CLANG_FLAGS) \ 184 207 -O2 -emit-llvm -c $< -o - | \ 185 208 $(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@ ··· 187 210 $(BTF_PAHOLE) -J $@ 188 211 endif 189 212 190 - $(OUTPUT)/%.o: %.c 213 + $(OUTPUT)/%.o: progs/%.c 191 214 $(CLANG) $(CLANG_FLAGS) \ 192 215 -O2 -target bpf -emit-llvm -c $< -o - | \ 193 216 $(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
tools/testing/selftests/bpf/bpf_flow.c tools/testing/selftests/bpf/progs/bpf_flow.c
tools/testing/selftests/bpf/connect4_prog.c tools/testing/selftests/bpf/progs/connect4_prog.c
tools/testing/selftests/bpf/connect6_prog.c tools/testing/selftests/bpf/progs/connect6_prog.c
tools/testing/selftests/bpf/dev_cgroup.c tools/testing/selftests/bpf/progs/dev_cgroup.c
tools/testing/selftests/bpf/get_cgroup_id_kern.c tools/testing/selftests/bpf/progs/get_cgroup_id_kern.c
tools/testing/selftests/bpf/netcnt_prog.c tools/testing/selftests/bpf/progs/netcnt_prog.c
tools/testing/selftests/bpf/sample_map_ret0.c tools/testing/selftests/bpf/progs/sample_map_ret0.c
tools/testing/selftests/bpf/sample_ret0.c tools/testing/selftests/bpf/progs/sample_ret0.c
tools/testing/selftests/bpf/sendmsg4_prog.c tools/testing/selftests/bpf/progs/sendmsg4_prog.c
tools/testing/selftests/bpf/sendmsg6_prog.c tools/testing/selftests/bpf/progs/sendmsg6_prog.c
tools/testing/selftests/bpf/sockmap_parse_prog.c tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
tools/testing/selftests/bpf/sockmap_tcp_msg_prog.c tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c
tools/testing/selftests/bpf/sockmap_verdict_prog.c tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c
tools/testing/selftests/bpf/test_adjust_tail.c tools/testing/selftests/bpf/progs/test_adjust_tail.c
tools/testing/selftests/bpf/test_btf_haskv.c tools/testing/selftests/bpf/progs/test_btf_haskv.c
tools/testing/selftests/bpf/test_btf_nokv.c tools/testing/selftests/bpf/progs/test_btf_nokv.c
tools/testing/selftests/bpf/test_get_stack_rawtp.c tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c
tools/testing/selftests/bpf/test_l4lb.c tools/testing/selftests/bpf/progs/test_l4lb.c
tools/testing/selftests/bpf/test_l4lb_noinline.c tools/testing/selftests/bpf/progs/test_l4lb_noinline.c
tools/testing/selftests/bpf/test_lirc_mode2_kern.c tools/testing/selftests/bpf/progs/test_lirc_mode2_kern.c
tools/testing/selftests/bpf/test_lwt_seg6local.c tools/testing/selftests/bpf/progs/test_lwt_seg6local.c
tools/testing/selftests/bpf/test_map_in_map.c tools/testing/selftests/bpf/progs/test_map_in_map.c
tools/testing/selftests/bpf/test_map_lock.c tools/testing/selftests/bpf/progs/test_map_lock.c
tools/testing/selftests/bpf/test_obj_id.c tools/testing/selftests/bpf/progs/test_obj_id.c
tools/testing/selftests/bpf/test_pkt_access.c tools/testing/selftests/bpf/progs/test_pkt_access.c
tools/testing/selftests/bpf/test_pkt_md_access.c tools/testing/selftests/bpf/progs/test_pkt_md_access.c
tools/testing/selftests/bpf/test_queue_map.c tools/testing/selftests/bpf/progs/test_queue_map.c
tools/testing/selftests/bpf/test_select_reuseport_kern.c tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c
tools/testing/selftests/bpf/test_sk_lookup_kern.c tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
tools/testing/selftests/bpf/test_skb_cgroup_id_kern.c tools/testing/selftests/bpf/progs/test_skb_cgroup_id_kern.c
tools/testing/selftests/bpf/test_sock_fields_kern.c tools/testing/selftests/bpf/progs/test_sock_fields_kern.c
tools/testing/selftests/bpf/test_sockhash_kern.c tools/testing/selftests/bpf/progs/test_sockhash_kern.c
tools/testing/selftests/bpf/test_sockmap_kern.c tools/testing/selftests/bpf/progs/test_sockmap_kern.c
tools/testing/selftests/bpf/test_spin_lock.c tools/testing/selftests/bpf/progs/test_spin_lock.c
tools/testing/selftests/bpf/test_stack_map.c tools/testing/selftests/bpf/progs/test_stack_map.c
tools/testing/selftests/bpf/test_stacktrace_build_id.c tools/testing/selftests/bpf/progs/test_stacktrace_build_id.c
tools/testing/selftests/bpf/test_stacktrace_map.c tools/testing/selftests/bpf/progs/test_stacktrace_map.c
tools/testing/selftests/bpf/test_tcp_estats.c tools/testing/selftests/bpf/progs/test_tcp_estats.c
tools/testing/selftests/bpf/test_tcpbpf_kern.c tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
tools/testing/selftests/bpf/test_tcpnotify_kern.c tools/testing/selftests/bpf/progs/test_tcpnotify_kern.c
tools/testing/selftests/bpf/test_tracepoint.c tools/testing/selftests/bpf/progs/test_tracepoint.c
tools/testing/selftests/bpf/test_tunnel_kern.c tools/testing/selftests/bpf/progs/test_tunnel_kern.c
tools/testing/selftests/bpf/test_xdp.c tools/testing/selftests/bpf/progs/test_xdp.c
tools/testing/selftests/bpf/test_xdp_meta.c tools/testing/selftests/bpf/progs/test_xdp_meta.c
tools/testing/selftests/bpf/test_xdp_noinline.c tools/testing/selftests/bpf/progs/test_xdp_noinline.c
tools/testing/selftests/bpf/test_xdp_redirect.c tools/testing/selftests/bpf/progs/test_xdp_redirect.c
tools/testing/selftests/bpf/test_xdp_vlan.c tools/testing/selftests/bpf/progs/test_xdp_vlan.c
tools/testing/selftests/bpf/xdp_dummy.c tools/testing/selftests/bpf/progs/xdp_dummy.c