Message ID | cover.1721713597.git.tony.ambardar@gmail.com |
---|---|
Headers | show |
Series | selftests/bpf: Improve libc portability / musl support (part 1) | expand |
On Mon, 2024-07-22 at 22:54 -0700, Tony Ambardar wrote: > Add a "bpf_util.h" include to avoid the following error seen > compiling for > mips64el with musl libc: > > bench.c: In function 'find_benchmark': > bench.c:590:25: error: implicit declaration of function > 'ARRAY_SIZE' [-Werror=implicit-function-declaration] > 590 | for (i = 0; i < ARRAY_SIZE(benchs); i++) { > | ^~~~~~~~~~ > cc1: all warnings being treated as errors I'm curious why this error doesn't occur on other platforms. ARRAY_SIZE is actually defined in linux/kernel.h (tools/include/linux/kernel.h). I think you should find out why this file is not included on your platform. > > Fixes: 8e7c2a023ac0 ("selftests/bpf: Add benchmark runner > infrastructure") > Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com> > --- > tools/testing/selftests/bpf/bench.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/bpf/bench.c > b/tools/testing/selftests/bpf/bench.c > index 627b74ae041b..90dc3aca32bd 100644 > --- a/tools/testing/selftests/bpf/bench.c > +++ b/tools/testing/selftests/bpf/bench.c > @@ -10,6 +10,7 @@ > #include <sys/sysinfo.h> > #include <signal.h> > #include "bench.h" > +#include "bpf_util.h" > #include "testing_helpers.h" > > struct env env = {
On Mon, Jul 22, 2024 at 10:55 PM Tony Ambardar <tony.ambardar@gmail.com> wrote: > > Hello all, > > This series includes the bulk of libc-related compile fixes accumulated to > support systems using musl, with smaller numbers to follow. These patches > are simple and straightforward, and the series has been tested with the > kernel-patches/bpf CI and locally using mips64el-gcc/musl-libc and QEMU > with an OpenWrt rootfs. > > The patches address a few general categories of libc portability issues: > > - missing, redundant or incorrect include headers > - disabled GNU header extensions (i.e. missing #define _GNU_SOURCE) > - issues with types and casting > > Feedback and suggestions for improvement are welcome! > > Thanks, > Tony > > Tony Ambardar (19): > selftests/bpf: Use pid_t consistently in test_progs.c > selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c > selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl > libc > selftests/bpf: Drop unneeded include in unpriv_helpers.c > selftests/bpf: Drop unneeded include in sk_lookup.c > selftests/bpf: Drop unneeded include in flow_dissector.c I squashed the above three patches into one, as they are the same kind of fix with the same reasoning. The rest at least have a specific error example, so I didn't touch them. But generally speaking, I think it's fair to combine the same kind of fixes across a few files (for the future). Applied to bpf-next, thanks. > selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c > selftests/bpf: Fix missing UINT_MAX definitions in benchmarks > selftests/bpf: Fix missing BUILD_BUG_ON() declaration > selftests/bpf: Fix include of <sys/fcntl.h> > selftests/bpf: Fix compiling parse_tcp_hdr_opt.c with musl-libc > selftests/bpf: Fix compiling kfree_skb.c with musl-libc > selftests/bpf: Fix compiling flow_dissector.c with musl-libc > selftests/bpf: Fix compiling tcp_rtt.c with musl-libc > selftests/bpf: Fix compiling core_reloc.c with musl-libc > selftests/bpf: Fix errors compiling lwt_redirect.c with musl libc > selftests/bpf: Fix errors compiling decap_sanity.c with musl libc > selftests/bpf: Fix errors compiling crypto_sanity.c with musl libc > selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc > > tools/testing/selftests/bpf/bench.c | 1 + > tools/testing/selftests/bpf/bench.h | 1 + > tools/testing/selftests/bpf/map_tests/sk_storage_map.c | 2 +- > tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c | 2 +- > tools/testing/selftests/bpf/prog_tests/core_reloc.c | 1 + > tools/testing/selftests/bpf/prog_tests/crypto_sanity.c | 1 - > tools/testing/selftests/bpf/prog_tests/decap_sanity.c | 1 - > tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 2 +- > tools/testing/selftests/bpf/prog_tests/kfree_skb.c | 1 + > tools/testing/selftests/bpf/prog_tests/lwt_redirect.c | 1 - > tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 2 +- > tools/testing/selftests/bpf/prog_tests/parse_tcp_hdr_opt.c | 1 + > tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 1 - > tools/testing/selftests/bpf/prog_tests/tcp_rtt.c | 1 + > tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 1 + > tools/testing/selftests/bpf/progs/cg_storage_multi.h | 2 -- > tools/testing/selftests/bpf/test_progs.c | 2 +- > tools/testing/selftests/bpf/unpriv_helpers.c | 1 - > 18 files changed, 12 insertions(+), 12 deletions(-) > > -- > 2.34.1 >
Hello: This series was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <andrii@kernel.org>: On Mon, 22 Jul 2024 22:54:27 -0700 you wrote: > Hello all, > > This series includes the bulk of libc-related compile fixes accumulated to > support systems using musl, with smaller numbers to follow. These patches > are simple and straightforward, and the series has been tested with the > kernel-patches/bpf CI and locally using mips64el-gcc/musl-libc and QEMU > with an OpenWrt rootfs. > > [...] Here is the summary with links: - [bpf-next,v1,01/19] selftests/bpf: Use pid_t consistently in test_progs.c https://git.kernel.org/bpf/bpf-next/c/afd8169d2724 - [bpf-next,v1,02/19] selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c https://git.kernel.org/bpf/bpf-next/c/bb3b965ee3a0 - [bpf-next,v1,03/19] selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl libc https://git.kernel.org/bpf/bpf-next/c/6c3a808171a2 - [bpf-next,v1,04/19] selftests/bpf: Drop unneeded include in unpriv_helpers.c https://git.kernel.org/bpf/bpf-next/c/80fd6c991e95 - [bpf-next,v1,05/19] selftests/bpf: Drop unneeded include in sk_lookup.c (no matching commit) - [bpf-next,v1,06/19] selftests/bpf: Drop unneeded include in flow_dissector.c (no matching commit) - [bpf-next,v1,07/19] selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c https://git.kernel.org/bpf/bpf-next/c/9dc46fdb679b - [bpf-next,v1,08/19] selftests/bpf: Fix missing UINT_MAX definitions in benchmarks https://git.kernel.org/bpf/bpf-next/c/6898506ee0ae - [bpf-next,v1,09/19] selftests/bpf: Fix missing BUILD_BUG_ON() declaration https://git.kernel.org/bpf/bpf-next/c/b855ef609329 - [bpf-next,v1,10/19] selftests/bpf: Fix include of <sys/fcntl.h> https://git.kernel.org/bpf/bpf-next/c/f9d6628b2f54 - [bpf-next,v1,11/19] selftests/bpf: Fix compiling parse_tcp_hdr_opt.c with musl-libc https://git.kernel.org/bpf/bpf-next/c/81c60e36c31b - [bpf-next,v1,12/19] selftests/bpf: Fix compiling kfree_skb.c with musl-libc https://git.kernel.org/bpf/bpf-next/c/787a2e4f1b9e - [bpf-next,v1,13/19] selftests/bpf: Fix compiling flow_dissector.c with musl-libc https://git.kernel.org/bpf/bpf-next/c/c2e6d8c605ac - [bpf-next,v1,14/19] selftests/bpf: Fix compiling tcp_rtt.c with musl-libc https://git.kernel.org/bpf/bpf-next/c/2a6a6956f616 - [bpf-next,v1,15/19] selftests/bpf: Fix compiling core_reloc.c with musl-libc https://git.kernel.org/bpf/bpf-next/c/231c5446bfbc - [bpf-next,v1,16/19] selftests/bpf: Fix errors compiling lwt_redirect.c with musl libc https://git.kernel.org/bpf/bpf-next/c/7ce34ba2b21a - [bpf-next,v1,17/19] selftests/bpf: Fix errors compiling decap_sanity.c with musl libc https://git.kernel.org/bpf/bpf-next/c/352d541fae2d - [bpf-next,v1,18/19] selftests/bpf: Fix errors compiling crypto_sanity.c with musl libc https://git.kernel.org/bpf/bpf-next/c/a88580ba22aa - [bpf-next,v1,19/19] selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc https://git.kernel.org/bpf/bpf-next/c/56b0ab53657b You are awesome, thank you!
On Wed, Jul 24, 2024 at 5:28 PM Tony Ambardar <tony.ambardar@gmail.com> wrote: > > Hi Andrii, > > On Wed, Jul 24, 2024 at 04:52:57PM -0700, Andrii Nakryiko wrote: > > On Mon, Jul 22, 2024 at 10:55 PM Tony Ambardar <tony.ambardar@gmail.com> wrote: > [...] > > > > > > Tony Ambardar (19): > > > selftests/bpf: Use pid_t consistently in test_progs.c > > > selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c > > > selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl > > > libc > > > selftests/bpf: Drop unneeded include in unpriv_helpers.c > > > selftests/bpf: Drop unneeded include in sk_lookup.c > > > selftests/bpf: Drop unneeded include in flow_dissector.c > > > > I squashed the above three patches into one, as they are the same kind > > of fix with the same reasoning. The rest at least have a specific > > error example, so I didn't touch them. > > > > But generally speaking, I think it's fair to combine the same kind of > > fixes across a few files (for the future). > > Thanks for clarifying this and reviewing. My concern earlier was that > squashing "Fixes:" tags could hinder backporting. Is that a non-issue? > The fixes are small, so probably not. It's also fixes for selftests, so I'm not even sure how much that matters (for backporting). > > Applied to bpf-next, thanks. > > > > And thanks to Geliang Tang, YiFei Zhu, and Vadim Fedorenko for their > feedback. > > Cheers, > Tony Ambardar > > [...]