selftests/bpf: Use vmlinux.h for BPF programs
Subsystems (3)
PATCH 1/1 selftests/bpf: Use vmlinux.h for BPF programs
Some of the bpf test progs still use linux/libc headers. Let's use vmlinux.h instead like the rest of test progs. This will also ease cross compiling.
No functional changes intended.
--- tools/testing/selftests/bpf/progs/loop1.c | 7 +------ tools/testing/selftests/bpf/progs/loop2.c | 7 +------ tools/testing/selftests/bpf/progs/loop3.c | 7 +------ tools/testing/selftests/bpf/progs/loop6.c | 10 +--------- tools/testing/selftests/bpf/progs/test_overhead.c | 5 +---- 5 files changed, 5 insertions(+), 31 deletions(-)
tools/testing/selftests/bpf/progs/loop1.c +1 -6
@@ -1,11 +1,6 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Facebook -#include <linux/sched.h> -#include <linux/ptrace.h> -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h>
tools/testing/selftests/bpf/progs/loop2.c +1 -6
@@ -1,11 +1,6 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Facebook -#include <linux/sched.h> -#include <linux/ptrace.h> -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h>
tools/testing/selftests/bpf/progs/loop3.c +1 -6
@@ -1,11 +1,6 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Facebook -#include <linux/sched.h> -#include <linux/ptrace.h> -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h>
tools/testing/selftests/bpf/progs/loop6.c +1 -9
@@ -1,8 +1,6 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/ptrace.h> -#include <stddef.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> #include "bpf_misc.h"
@@ -26,12 +24,6 @@ char _license[] SEC("license") = "GPL";#define SG_CHAIN 0x01UL#define SG_END 0x02UL -struct scatterlist { -unsigned long page_link; -unsigned int offset; -unsigned int length; -}; -#define sg_is_chain (sg) ((sg)->page_link & SG_CHAIN)#define sg_is_last (sg) ((sg)->page_link & SG_END)#define sg_chain_ptr (sg) \
tools/testing/selftests/bpf/progs/test_overhead.c +1 -4
@@ -1,9 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2019 Facebook */ -#include <stdbool.h> -#include <stddef.h> -#include <linux/bpf.h> -#include <linux/ptrace.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h>
Signature · 1 line
2.43.5
Quoted 4 lines · Hengqi Chen
Some of the bpf test progs still use linux/libc headers. Let's use
vmlinux.hinstead like the rest of test progs. This will also ease cross compiling.
only if...
Quoted 15 lines
tools/testing/selftests/bpf/progs/loop6.c +1
-3@@ -1,8 +1,6 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/ptrace.h> -#include <stddef.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> #include "bpf_misc.h"
tools/testing/selftests/bpf/progs/loop6.c char _license[] SEC("license") = "GPL"; · line 34
Quoted 9 lines
tools/testing/selftests/bpf/progs/loop6.c +0
-6@@ -26,12 +24,6 @@ char _license[] SEC("license") = "GPL";#define SG_CHAIN 0x01UL#define SG_END 0x02UL -struct scatterlist { -unsigned long page_link; -unsigned int offset; -unsigned int length; -}; -
Pls test your patch before submitting, so that maintainers don't need to point to CI that complains about this.
scetterlist here is not the same as in vmlinux.h which causes issues.
--
pw-bot: cr
Quoted 27 lines · Alexei Starovoitov
Quoted 4 lines · Hengqi Chen
Some of the bpf test progs still use linux/libc headers. Let's use
vmlinux.hinstead like the rest of test progs. This will also ease cross compiling.only if...
Quoted 18 lines
tools/testing/selftests/bpf/progs/loop6.c +1
-3@@ -1,8 +1,6 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/ptrace.h> -#include <stddef.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> #include "bpf_misc.h" @@ -26,12 +24,6 @@ char _license[] SEC("license") = "GPL";#define SG_CHAIN 0x01UL#define SG_END 0x02UL
Quoted 10 lines
tools/testing/selftests/bpf/progs/loop6.c char _license[] SEC("license") = "GPL"; · line 34
Quoted 6 lines
tools/testing/selftests/bpf/progs/loop6.c +0
-6-struct scatterlist { -unsigned long page_link; -unsigned int offset; -unsigned int length; -}; -Pls test your patch before submitting, so that maintainers don't need to point to CI that complains about this.
Sorry, my bad.
Quoted 2 lines
scetterlist here is not the same as in
vmlinux.hwhich causes issues.
After some investigation (with GPT 5), it seems like the issue is raised by __attribute__((preserve_access_index)) not struct size.
Quoted 2 lines
--
pw-bot: cr