Skip to content

Commit b9d3267

Browse files
author
Alexei Starovoitov
committed
Merge branch 'local-vmtest-enhancement-and-rv64-enabled'
Pu Lehui says: ==================== Local vmtest enhancement and RV64 enabled Patch 1-3 fix some problem about bpf selftests. Patch 4 add local rootfs image support for vmtest. Patch 5 enable cross-platform testing for vmtest. Patch 6-10 enable vmtest on RV64. We can now perform cross platform testing for riscv64 bpf using the following command: PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \ tools/testing/selftests/bpf/vmtest.sh \ -l <path of local rootfs image> -- \ ./test_progs -d \ \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ | cut -d'#' -f1 \ | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ | tr -s '\n' ',' \ )\" For better regression, we rely on commit [0]. And since the work of riscv ftrace to remove stop_machine atomic replacement is in progress, we also need to revert commit [1] [2]. The test platform is x86_64 architecture, and the versions of relevant components are as follows: QEMU: 8.2.0 CLANG: 17.0.6 (align to BPF CI) ROOTFS: ubuntu noble (generated by [3]) Link: https://lore.kernel.org/all/[email protected]/ [0] Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3308172276db [1] Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7caa9765465f [2] Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [3] v3: - Use llvm static linking when detecting that feature-llvm is enabled - Add Acked-by by Eduard v2: https://lore.kernel.org/all/[email protected]/ - Drop patch about relaxing Zbb insns restrictions. - Add local rootfs image support - Add description about running vmtest on RV64 - Fix some problem about bpf selftests v1: https://lore.kernel.org/all/[email protected]/ ==================== Acked-by: Daniel Borkmann <[email protected]> Tested-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents bd4d67f + 95b1c5d commit b9d3267

File tree

7 files changed

+205
-45
lines changed

7 files changed

+205
-45
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# riscv64 deny list for BPF CI and local vmtest
2+
exceptions # JIT does not support exceptions
3+
tailcalls/tailcall_bpf2bpf* # JIT does not support mixing bpf2bpf and tailcalls

tools/testing/selftests/bpf/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,24 @@ FEATURE_TESTS := llvm
187187
FEATURE_DISPLAY := $(FEATURE_TESTS)
188188

189189
# Makefile.feature expects OUTPUT to end with a slash
190+
ifeq ($(shell expr $(MAKE_VERSION) \>= 4.4), 1)
190191
$(let OUTPUT,$(OUTPUT)/,\
191192
$(eval include ../../../build/Makefile.feature))
193+
else
194+
OUTPUT := $(OUTPUT)/
195+
$(eval include ../../../build/Makefile.feature)
196+
OUTPUT := $(patsubst %/,%,$(OUTPUT))
197+
endif
192198
endif
193199

194200
ifeq ($(feature-llvm),1)
195201
LLVM_CFLAGS += -DHAVE_LLVM_SUPPORT
196202
LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets
197203
# both llvm-config and lib.mk add -D_GNU_SOURCE, which ends up as conflict
198204
LLVM_CFLAGS += $(filter-out -D_GNU_SOURCE,$(shell $(LLVM_CONFIG) --cflags))
199-
LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --libs $(LLVM_CONFIG_LIB_COMPONENTS))
200-
ifeq ($(shell $(LLVM_CONFIG) --shared-mode),static)
201-
LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --system-libs $(LLVM_CONFIG_LIB_COMPONENTS))
202-
LLVM_LDLIBS += -lstdc++
203-
endif
205+
LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --libs $(LLVM_CONFIG_LIB_COMPONENTS))
206+
LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --system-libs $(LLVM_CONFIG_LIB_COMPONENTS))
207+
LLVM_LDLIBS += -lstdc++
204208
LLVM_LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags)
205209
endif
206210

tools/testing/selftests/bpf/README.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,37 @@ In case of linker errors when running selftests, try using static linking:
8585
If you want to change pahole and llvm, you can change `PATH` environment
8686
variable in the beginning of script.
8787

88-
.. note:: The script currently only supports x86_64 and s390x architectures.
88+
Running vmtest on RV64
89+
======================
90+
To speed up testing and avoid various dependency issues, it is recommended to
91+
run vmtest in a Docker container. Before running vmtest, we need to prepare
92+
Docker container and local rootfs image. The overall steps are as follows:
93+
94+
1. Create Docker container as shown in link [0].
95+
96+
2. Use mkrootfs_debian.sh script [1] to build local rootfs image:
97+
98+
.. code-block:: console
99+
100+
$ sudo ./mkrootfs_debian.sh --arch riscv64 --distro noble
101+
102+
3. Start Docker container [0] and run vmtest in the container:
103+
104+
.. code-block:: console
105+
106+
$ PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \
107+
tools/testing/selftests/bpf/vmtest.sh \
108+
-l <path of local rootfs image> -- \
109+
./test_progs -d \
110+
\"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
111+
| cut -d'#' -f1 \
112+
| sed -e 's/^[[:space:]]*//' \
113+
-e 's/[[:space:]]*$//' \
114+
| tr -s '\n' ',' \
115+
)\"
116+
117+
Link: https://github.com/pulehui/riscv-bpf-vmtest.git [0]
118+
Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [1]
89119

90120
Additional information about selftest failures are
91121
documented here.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CONFIG_AUDIT=y
2+
CONFIG_BLK_CGROUP=y
3+
CONFIG_BLK_DEV_INITRD=y
4+
CONFIG_BLK_DEV_RAM=y
5+
CONFIG_BONDING=y
6+
CONFIG_BPF_JIT_ALWAYS_ON=y
7+
CONFIG_BPF_PRELOAD=y
8+
CONFIG_BPF_PRELOAD_UMD=y
9+
CONFIG_CGROUPS=y
10+
CONFIG_CGROUP_CPUACCT=y
11+
CONFIG_CGROUP_DEVICE=y
12+
CONFIG_CGROUP_FREEZER=y
13+
CONFIG_CGROUP_HUGETLB=y
14+
CONFIG_CGROUP_NET_CLASSID=y
15+
CONFIG_CGROUP_PERF=y
16+
CONFIG_CGROUP_PIDS=y
17+
CONFIG_CGROUP_SCHED=y
18+
CONFIG_CPUSETS=y
19+
CONFIG_DEBUG_ATOMIC_SLEEP=y
20+
CONFIG_DEBUG_FS=y
21+
CONFIG_DETECT_HUNG_TASK=y
22+
CONFIG_DEVTMPFS=y
23+
CONFIG_DEVTMPFS_MOUNT=y
24+
CONFIG_EXPERT=y
25+
CONFIG_EXT4_FS=y
26+
CONFIG_EXT4_FS_POSIX_ACL=y
27+
CONFIG_EXT4_FS_SECURITY=y
28+
CONFIG_FRAME_POINTER=y
29+
CONFIG_HARDLOCKUP_DETECTOR=y
30+
CONFIG_HIGH_RES_TIMERS=y
31+
CONFIG_HUGETLBFS=y
32+
CONFIG_INET=y
33+
CONFIG_IPV6_SEG6_LWTUNNEL=y
34+
CONFIG_IP_ADVANCED_ROUTER=y
35+
CONFIG_IP_MULTICAST=y
36+
CONFIG_IP_MULTIPLE_TABLES=y
37+
CONFIG_JUMP_LABEL=y
38+
CONFIG_KALLSYMS_ALL=y
39+
CONFIG_KPROBES=y
40+
CONFIG_MEMCG=y
41+
CONFIG_NAMESPACES=y
42+
CONFIG_NET=y
43+
CONFIG_NETDEVICES=y
44+
CONFIG_NETFILTER_XT_MATCH_BPF=y
45+
CONFIG_NET_ACT_BPF=y
46+
CONFIG_NET_L3_MASTER_DEV=y
47+
CONFIG_NET_VRF=y
48+
CONFIG_NONPORTABLE=y
49+
CONFIG_NO_HZ_IDLE=y
50+
CONFIG_NR_CPUS=256
51+
CONFIG_PACKET=y
52+
CONFIG_PANIC_ON_OOPS=y
53+
CONFIG_PARTITION_ADVANCED=y
54+
CONFIG_PCI=y
55+
CONFIG_PCI_HOST_GENERIC=y
56+
CONFIG_POSIX_MQUEUE=y
57+
CONFIG_PRINTK_TIME=y
58+
CONFIG_PROC_KCORE=y
59+
CONFIG_PROFILING=y
60+
CONFIG_RCU_CPU_STALL_TIMEOUT=60
61+
CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS=y
62+
CONFIG_RISCV_ISA_C=y
63+
CONFIG_RISCV_PMU=y
64+
CONFIG_RISCV_PMU_SBI=y
65+
CONFIG_RT_GROUP_SCHED=y
66+
CONFIG_SECURITY_NETWORK=y
67+
CONFIG_SERIAL_8250=y
68+
CONFIG_SERIAL_8250_CONSOLE=y
69+
CONFIG_SERIAL_OF_PLATFORM=y
70+
CONFIG_SMP=y
71+
CONFIG_SOC_VIRT=y
72+
CONFIG_SYSVIPC=y
73+
CONFIG_TCP_CONG_ADVANCED=y
74+
CONFIG_TLS=y
75+
CONFIG_TMPFS=y
76+
CONFIG_TMPFS_POSIX_ACL=y
77+
CONFIG_TUN=y
78+
CONFIG_UNIX=y
79+
CONFIG_UPROBES=y
80+
CONFIG_USER_NS=y
81+
CONFIG_VETH=y
82+
CONFIG_VLAN_8021Q=y
83+
CONFIG_VSOCKETS_LOOPBACK=y
84+
CONFIG_XFRM_USER=y

tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void test_dctcp_fallback(void)
285285
dctcp_skel = bpf_dctcp__open();
286286
if (!ASSERT_OK_PTR(dctcp_skel, "dctcp_skel"))
287287
return;
288-
strcpy(dctcp_skel->rodata->fallback, "cubic");
288+
strcpy(dctcp_skel->rodata->fallback_cc, "cubic");
289289
if (!ASSERT_OK(bpf_dctcp__load(dctcp_skel), "bpf_dctcp__load"))
290290
goto done;
291291

tools/testing/selftests/bpf/progs/bpf_dctcp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static bool before(__u32 seq1, __u32 seq2)
2626

2727
char _license[] SEC("license") = "GPL";
2828

29-
volatile const char fallback[TCP_CA_NAME_MAX];
29+
volatile const char fallback_cc[TCP_CA_NAME_MAX];
3030
const char bpf_dctcp[] = "bpf_dctcp";
3131
const char tcp_cdg[] = "cdg";
3232
char cc_res[TCP_CA_NAME_MAX];
@@ -71,10 +71,10 @@ void BPF_PROG(bpf_dctcp_init, struct sock *sk)
7171
struct bpf_dctcp *ca = inet_csk_ca(sk);
7272
int *stg;
7373

74-
if (!(tp->ecn_flags & TCP_ECN_OK) && fallback[0]) {
74+
if (!(tp->ecn_flags & TCP_ECN_OK) && fallback_cc[0]) {
7575
/* Switch to fallback */
7676
if (bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION,
77-
(void *)fallback, sizeof(fallback)) == -EBUSY)
77+
(void *)fallback_cc, sizeof(fallback_cc)) == -EBUSY)
7878
ebusy_cnt++;
7979

8080
/* Switch back to myself and the recurred bpf_dctcp_init()
@@ -87,7 +87,7 @@ void BPF_PROG(bpf_dctcp_init, struct sock *sk)
8787

8888
/* Switch back to fallback */
8989
if (bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION,
90-
(void *)fallback, sizeof(fallback)) == -EBUSY)
90+
(void *)fallback_cc, sizeof(fallback_cc)) == -EBUSY)
9191
ebusy_cnt++;
9292

9393
/* Expecting -ENOTSUPP for tcp_cdg_res */

0 commit comments

Comments
 (0)