BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: fix build with new LLVM
@ 2025-09-18  9:36 Anton Protopopov
  2025-09-18 15:02 ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Anton Protopopov @ 2025-09-18  9:36 UTC (permalink / raw)
  To: bpf; +Cc: Anton Protopopov, Puranjay Mohan

The progs/stream.c BPF program now uses arena helpers, so it includes
bpf_arena_common.h, which conflicts with the declarations generated
in vmlinux.h. This leads to the following build errors with the recent
LLVM:

    In file included from progs/stream.c:8:
    .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
       47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
          |               ^
    .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
     229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
            |              ^

    ... etc

Fix this by analogy with the 6a8260147745 ("bpf: selftests: Do not
use generated kfunc prototypes for arena progs") commit by adding the
BPF_NO_KFUNC_PROTOTYPES. As the test uses other kfuncs, declare them
specifically.

Fixes: 86f2225065be ("selftests/bpf: Add tests for arena fault reporting")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
---
 tools/testing/selftests/bpf/progs/stream.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/stream.c b/tools/testing/selftests/bpf/progs/stream.c
index 4a5bd852f10c..900da666d182 100644
--- a/tools/testing/selftests/bpf/progs/stream.c
+++ b/tools/testing/selftests/bpf/progs/stream.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
+
+#define BPF_NO_KFUNC_PROTOTYPES
 #include <vmlinux.h>
 #include <bpf/bpf_tracing.h>
 #include <bpf/bpf_helpers.h>
@@ -7,6 +9,13 @@
 #include "bpf_experimental.h"
 #include "bpf_arena_common.h"
 
+/*
+ * Declare kfuncs here, as BPF_NO_KFUNC_PROTOTYPES is used
+ * to exclude improper arena kfuncs declarations
+ */
+extern int bpf_res_spin_lock(struct bpf_res_spin_lock *lock) __weak __ksym;
+extern void bpf_res_spin_unlock(struct bpf_res_spin_lock *lock) __weak __ksym;
+
 struct arr_elem {
 	struct bpf_res_spin_lock lock;
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: fix build with new LLVM
  2025-09-18  9:36 [PATCH bpf-next] selftests/bpf: fix build with new LLVM Anton Protopopov
@ 2025-09-18 15:02 ` Alexei Starovoitov
  2025-09-18 16:27   ` Anton Protopopov
  0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2025-09-18 15:02 UTC (permalink / raw)
  To: Anton Protopopov; +Cc: bpf, Puranjay Mohan

On Thu, Sep 18, 2025 at 2:30 AM Anton Protopopov
<a.s.protopopov@gmail.com> wrote:
>
> The progs/stream.c BPF program now uses arena helpers, so it includes
> bpf_arena_common.h, which conflicts with the declarations generated
> in vmlinux.h. This leads to the following build errors with the recent
> LLVM:
>
>     In file included from progs/stream.c:8:
>     .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
>        47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
>           |               ^
>     .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
>      229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
>             |              ^
>
>     ... etc

I suspect you're using old pahole.
New one can transfer __arena tags into vmlinux.h

pw-bot: cr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: fix build with new LLVM
  2025-09-18 16:27   ` Anton Protopopov
@ 2025-09-18 16:26     ` Alexei Starovoitov
  2025-09-19 22:29       ` Andrii Nakryiko
  2025-10-20  9:06       ` Anton Protopopov
  0 siblings, 2 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2025-09-18 16:26 UTC (permalink / raw)
  To: Anton Protopopov; +Cc: bpf, Puranjay Mohan

On Thu, Sep 18, 2025 at 9:21 AM Anton Protopopov
<a.s.protopopov@gmail.com> wrote:
>
> On 25/09/18 08:02AM, Alexei Starovoitov wrote:
> > On Thu, Sep 18, 2025 at 2:30 AM Anton Protopopov
> > <a.s.protopopov@gmail.com> wrote:
> > >
> > > The progs/stream.c BPF program now uses arena helpers, so it includes
> > > bpf_arena_common.h, which conflicts with the declarations generated
> > > in vmlinux.h. This leads to the following build errors with the recent
> > > LLVM:
> > >
> > >     In file included from progs/stream.c:8:
> > >     .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
> > >        47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
> > >           |               ^
> > >     .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
> > >      229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
> > >             |              ^
> > >
> > >     ... etc
> >
> > I suspect you're using old pahole.
> > New one can transfer __arena tags into vmlinux.h
>
> Ok, TIL about CONFIG_PAHOLE_VERSION (before I've sent the patch,
> I've updated the pahole, re-built the kernel, but didn't do `make
> oldconfig` after updating pahole.)

Yeah. It's a footgun that few people are aware of :(
I was bitten by it too.
We have a small section about pahole in bpf_devel_QA.rst.
We should probably expand it and list the common issues and how to fix them.
Every week somebody sends a patch due to old pahole :(

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: fix build with new LLVM
  2025-09-18 15:02 ` Alexei Starovoitov
@ 2025-09-18 16:27   ` Anton Protopopov
  2025-09-18 16:26     ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Anton Protopopov @ 2025-09-18 16:27 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: bpf, Puranjay Mohan

On 25/09/18 08:02AM, Alexei Starovoitov wrote:
> On Thu, Sep 18, 2025 at 2:30 AM Anton Protopopov
> <a.s.protopopov@gmail.com> wrote:
> >
> > The progs/stream.c BPF program now uses arena helpers, so it includes
> > bpf_arena_common.h, which conflicts with the declarations generated
> > in vmlinux.h. This leads to the following build errors with the recent
> > LLVM:
> >
> >     In file included from progs/stream.c:8:
> >     .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
> >        47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
> >           |               ^
> >     .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
> >      229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
> >             |              ^
> >
> >     ... etc
> 
> I suspect you're using old pahole.
> New one can transfer __arena tags into vmlinux.h

Ok, TIL about CONFIG_PAHOLE_VERSION (before I've sent the patch,
I've updated the pahole, re-built the kernel, but didn't do `make
oldconfig` after updating pahole.)

> pw-bot: cr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: fix build with new LLVM
  2025-09-18 16:26     ` Alexei Starovoitov
@ 2025-09-19 22:29       ` Andrii Nakryiko
  2025-10-20  9:06       ` Anton Protopopov
  1 sibling, 0 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2025-09-19 22:29 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: Anton Protopopov, bpf, Puranjay Mohan

On Thu, Sep 18, 2025 at 9:29 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Thu, Sep 18, 2025 at 9:21 AM Anton Protopopov
> <a.s.protopopov@gmail.com> wrote:
> >
> > On 25/09/18 08:02AM, Alexei Starovoitov wrote:
> > > On Thu, Sep 18, 2025 at 2:30 AM Anton Protopopov
> > > <a.s.protopopov@gmail.com> wrote:
> > > >
> > > > The progs/stream.c BPF program now uses arena helpers, so it includes
> > > > bpf_arena_common.h, which conflicts with the declarations generated
> > > > in vmlinux.h. This leads to the following build errors with the recent
> > > > LLVM:
> > > >
> > > >     In file included from progs/stream.c:8:
> > > >     .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
> > > >        47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
> > > >           |               ^
> > > >     .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
> > > >      229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
> > > >             |              ^
> > > >
> > > >     ... etc
> > >
> > > I suspect you're using old pahole.
> > > New one can transfer __arena tags into vmlinux.h
> >
> > Ok, TIL about CONFIG_PAHOLE_VERSION (before I've sent the patch,
> > I've updated the pahole, re-built the kernel, but didn't do `make
> > oldconfig` after updating pahole.)
>
> Yeah. It's a footgun that few people are aware of :(
> I was bitten by it too.
> We have a small section about pahole in bpf_devel_QA.rst.
> We should probably expand it and list the common issues and how to fix them.
> Every week somebody sends a patch due to old pahole :(
>

There is some magical CC_VERSION_TEXT that is supposed to fix a
similar problem for the compiler version. I didn't completely
understand how it's done, but perhaps we can use the same idea to
update pahole version when it changes?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: fix build with new LLVM
  2025-09-18 16:26     ` Alexei Starovoitov
  2025-09-19 22:29       ` Andrii Nakryiko
@ 2025-10-20  9:06       ` Anton Protopopov
  1 sibling, 0 replies; 6+ messages in thread
From: Anton Protopopov @ 2025-10-20  9:06 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: bpf, Puranjay Mohan

On 25/09/18 09:26AM, Alexei Starovoitov wrote:
> On Thu, Sep 18, 2025 at 9:21 AM Anton Protopopov
> <a.s.protopopov@gmail.com> wrote:
> >
> > On 25/09/18 08:02AM, Alexei Starovoitov wrote:
> > > On Thu, Sep 18, 2025 at 2:30 AM Anton Protopopov
> > > <a.s.protopopov@gmail.com> wrote:
> > > >
> > > > The progs/stream.c BPF program now uses arena helpers, so it includes
> > > > bpf_arena_common.h, which conflicts with the declarations generated
> > > > in vmlinux.h. This leads to the following build errors with the recent
> > > > LLVM:
> > > >
> > > >     In file included from progs/stream.c:8:
> > > >     .../tools/testing/selftests/bpf/bpf_arena_common.h:47:15: error: conflicting types for 'bpf_arena_alloc_pages'
> > > >        47 | void __arena* bpf_arena_alloc_pages(void *map, void __arena *addr, __u32 page_cnt,
> > > >           |               ^
> > > >     .../tools/testing/selftests/bpf/tools/include/vmlinux.h:229284:14: note: previous declaration is here
> > > >      229284 | extern void *bpf_arena_alloc_pages(void *p__map, void *addr__ign, u32 page_cnt, int node_id, u64 flags) __weak __ksym;
> > > >             |              ^
> > > >
> > > >     ... etc
> > >
> > > I suspect you're using old pahole.
> > > New one can transfer __arena tags into vmlinux.h
> >
> > Ok, TIL about CONFIG_PAHOLE_VERSION (before I've sent the patch,
> > I've updated the pahole, re-built the kernel, but didn't do `make
> > oldconfig` after updating pahole.)
> 
> Yeah. It's a footgun that few people are aware of :(
> I was bitten by it too.
> We have a small section about pahole in bpf_devel_QA.rst.
> We should probably expand it and list the common issues and how to fix them.
> Every week somebody sends a patch due to old pahole :(

And today I also learned about the "next" branch of the pahole repo.
The "master" branch was too old to generate kfunc header for a kfunc
compiled with a .cold part (namely, bpf_dynptr_slice).

As the "old pahole" thing happens to so many people, maybe there is
a way to in-source it into kernel?..

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-20  9:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18  9:36 [PATCH bpf-next] selftests/bpf: fix build with new LLVM Anton Protopopov
2025-09-18 15:02 ` Alexei Starovoitov
2025-09-18 16:27   ` Anton Protopopov
2025-09-18 16:26     ` Alexei Starovoitov
2025-09-19 22:29       ` Andrii Nakryiko
2025-10-20  9:06       ` Anton Protopopov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox