BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
@ 2025-10-29 18:36 Yonghong Song
  2025-10-30  1:00 ` Menglong Dong
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yonghong Song @ 2025-10-29 18:36 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
	Martin KaFai Lau, Menglong Dong, Ihor Solodrai

With latest bpf/bpf-next tree and latest pahole master, I got the following
build failure:

  $ make LLVM=1 -j
    ...
    LD      vmlinux.o
    GEN     .vmlinux.objs
    ...
    BTF     .tmp_vmlinux1.btf.o
    ...
    AS      .tmp_vmlinux2.kallsyms.o
    LD      vmlinux.unstripped
    BTFIDS  vmlinux.unstripped
  WARN: resolve_btfids: unresolved symbol migrate_enable
  WARN: resolve_btfids: unresolved symbol migrate_disable
  make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
  make[2]: *** Deleting file 'vmlinux.unstripped'
  make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
  make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2

In pahole patch [1], if two functions having identical names but different
addresses, then this function name is considered ambiguous and later on
this function will not be added to vmlinux/module BTF.

Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") changed
original global funcitons migrate_{enable,disable} to
  - in kernel/sched/core.c, migrate_{enable,disable} are global funcitons.
  - in other places, migrate_{enable,disable} may survive as static functions
    since they are marked as 'inline' in include/linux/sched.h and the
    'inline' attribute does not garantee inlining.

If I build with clang compiler (make LLVM=1 -j) (llvm21 and llvm22), I found
there are four symbols for migrate_{enable,disable} respectively, three
static functions and one global function. With the above pahole patch [1],
migrate_{enable,disable} are not in vmlinux BTF and this will cause
later resolve_btfids failure.

Making migrate_{enable,disable} always inline in include/linux/sched.h
can fix the problem.

  [1] https://lore.kernel.org/dwarves/79a329ef-9bb3-454e-9135-731f2fd51951@oracle.com/

Fixes: 378b7708194f ("sched: Make migrate_{en,dis}able() inline")
Cc: Menglong Dong <menglong8.dong@gmail.com>
Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
 include/linux/sched.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index cbb7340c5866..b469878de25c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2407,12 +2407,12 @@ static inline void __migrate_enable(void) { }
  * be defined in kernel/sched/core.c.
  */
 #ifndef INSTANTIATE_EXPORTED_MIGRATE_DISABLE
-static inline void migrate_disable(void)
+static __always_inline void migrate_disable(void)
 {
 	__migrate_disable();
 }
 
-static inline void migrate_enable(void)
+static __always_inline void migrate_enable(void)
 {
 	__migrate_enable();
 }
-- 
2.47.3


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

* Re: [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
  2025-10-29 18:36 [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file Yonghong Song
@ 2025-10-30  1:00 ` Menglong Dong
  2025-10-30  1:13 ` Alexei Starovoitov
  2025-10-31 18:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Menglong Dong @ 2025-10-30  1:00 UTC (permalink / raw)
  To: bpf, Yonghong Song
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
	Martin KaFai Lau, Menglong Dong, Ihor Solodrai

On 2025/10/30 02:36, Yonghong Song wrote:
> With latest bpf/bpf-next tree and latest pahole master, I got the following
> build failure:
> 
>   $ make LLVM=1 -j
>     ...
>     LD      vmlinux.o
>     GEN     .vmlinux.objs
>     ...
>     BTF     .tmp_vmlinux1.btf.o
>     ...
>     AS      .tmp_vmlinux2.kallsyms.o
>     LD      vmlinux.unstripped
>     BTFIDS  vmlinux.unstripped
>   WARN: resolve_btfids: unresolved symbol migrate_enable
>   WARN: resolve_btfids: unresolved symbol migrate_disable
>   make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
>   make[2]: *** Deleting file 'vmlinux.unstripped'
>   make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
>   make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2
> 
> In pahole patch [1], if two functions having identical names but different
> addresses, then this function name is considered ambiguous and later on
> this function will not be added to vmlinux/module BTF.
> 
> Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") changed
> original global funcitons migrate_{enable,disable} to
>   - in kernel/sched/core.c, migrate_{enable,disable} are global funcitons.
>   - in other places, migrate_{enable,disable} may survive as static functions
>     since they are marked as 'inline' in include/linux/sched.h and the
>     'inline' attribute does not garantee inlining.
> 
> If I build with clang compiler (make LLVM=1 -j) (llvm21 and llvm22), I found
> there are four symbols for migrate_{enable,disable} respectively, three
> static functions and one global function. With the above pahole patch [1],
> migrate_{enable,disable} are not in vmlinux BTF and this will cause
> later resolve_btfids failure.
> 
> Making migrate_{enable,disable} always inline in include/linux/sched.h
> can fix the problem.
> 
>   [1] https://lore.kernel.org/dwarves/79a329ef-9bb3-454e-9135-731f2fd51951@oracle.com/
> 
> Fixes: 378b7708194f ("sched: Make migrate_{en,dis}able() inline")
> Cc: Menglong Dong <menglong8.dong@gmail.com>
> Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> ---
>  include/linux/sched.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index cbb7340c5866..b469878de25c 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2407,12 +2407,12 @@ static inline void __migrate_enable(void) { }
>   * be defined in kernel/sched/core.c.
>   */
>  #ifndef INSTANTIATE_EXPORTED_MIGRATE_DISABLE
> -static inline void migrate_disable(void)
> +static __always_inline void migrate_disable(void)
>  {
>  	__migrate_disable();
>  }

Thanks for the fixing :)

Acked-by: Menglong Dong <menglong.dong@linux.dev>

>  
> -static inline void migrate_enable(void)
> +static __always_inline void migrate_enable(void)
>  {
>  	__migrate_enable();
>  }
> 





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

* Re: [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
  2025-10-29 18:36 [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file Yonghong Song
  2025-10-30  1:00 ` Menglong Dong
@ 2025-10-30  1:13 ` Alexei Starovoitov
  2025-10-30 10:53   ` Peter Zijlstra
  2025-10-31 18:20 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2025-10-30  1:13 UTC (permalink / raw)
  To: Yonghong Song, Peter Zijlstra
  Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Kernel Team, Martin KaFai Lau, Menglong Dong, Ihor Solodrai

On Wed, Oct 29, 2025 at 11:37 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>
> With latest bpf/bpf-next tree and latest pahole master, I got the following
> build failure:
>
>   $ make LLVM=1 -j
>     ...
>     LD      vmlinux.o
>     GEN     .vmlinux.objs
>     ...
>     BTF     .tmp_vmlinux1.btf.o
>     ...
>     AS      .tmp_vmlinux2.kallsyms.o
>     LD      vmlinux.unstripped
>     BTFIDS  vmlinux.unstripped
>   WARN: resolve_btfids: unresolved symbol migrate_enable
>   WARN: resolve_btfids: unresolved symbol migrate_disable
>   make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
>   make[2]: *** Deleting file 'vmlinux.unstripped'
>   make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
>   make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2
>
> In pahole patch [1], if two functions having identical names but different
> addresses, then this function name is considered ambiguous and later on
> this function will not be added to vmlinux/module BTF.
>
> Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") changed
> original global funcitons migrate_{enable,disable} to
>   - in kernel/sched/core.c, migrate_{enable,disable} are global funcitons.
>   - in other places, migrate_{enable,disable} may survive as static functions
>     since they are marked as 'inline' in include/linux/sched.h and the
>     'inline' attribute does not garantee inlining.
>
> If I build with clang compiler (make LLVM=1 -j) (llvm21 and llvm22), I found
> there are four symbols for migrate_{enable,disable} respectively, three
> static functions and one global function. With the above pahole patch [1],
> migrate_{enable,disable} are not in vmlinux BTF and this will cause
> later resolve_btfids failure.
>
> Making migrate_{enable,disable} always inline in include/linux/sched.h
> can fix the problem.
>
>   [1] https://lore.kernel.org/dwarves/79a329ef-9bb3-454e-9135-731f2fd51951@oracle.com/
>
> Fixes: 378b7708194f ("sched: Make migrate_{en,dis}able() inline")
> Cc: Menglong Dong <menglong8.dong@gmail.com>
> Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> ---
>  include/linux/sched.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index cbb7340c5866..b469878de25c 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2407,12 +2407,12 @@ static inline void __migrate_enable(void) { }
>   * be defined in kernel/sched/core.c.
>   */
>  #ifndef INSTANTIATE_EXPORTED_MIGRATE_DISABLE
> -static inline void migrate_disable(void)
> +static __always_inline void migrate_disable(void)
>  {
>         __migrate_disable();
>  }
>
> -static inline void migrate_enable(void)
> +static __always_inline void migrate_enable(void)
>  {
>         __migrate_enable();
>  }

Peter,

Are you ok if we take this?

I cannot think of a good alternative.

We can mark [__]migrate_disable/enable as notrace, nokprobe,
but attaching to them is only problematic for bpf.
Hence we keep them in our own deny list on the verifier side
which causes above issues with partial inlining.

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

* Re: [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
  2025-10-30  1:13 ` Alexei Starovoitov
@ 2025-10-30 10:53   ` Peter Zijlstra
  2025-10-30 15:18     ` Yonghong Song
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2025-10-30 10:53 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Yonghong Song, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Kernel Team, Martin KaFai Lau, Menglong Dong,
	Ihor Solodrai

On Wed, Oct 29, 2025 at 06:13:21PM -0700, Alexei Starovoitov wrote:
> On Wed, Oct 29, 2025 at 11:37 AM Yonghong Song <yonghong.song@linux.dev> wrote:
> >
> > With latest bpf/bpf-next tree and latest pahole master, I got the following
> > build failure:
> >
> >   $ make LLVM=1 -j
> >     ...
> >     LD      vmlinux.o
> >     GEN     .vmlinux.objs
> >     ...
> >     BTF     .tmp_vmlinux1.btf.o
> >     ...
> >     AS      .tmp_vmlinux2.kallsyms.o
> >     LD      vmlinux.unstripped
> >     BTFIDS  vmlinux.unstripped
> >   WARN: resolve_btfids: unresolved symbol migrate_enable
> >   WARN: resolve_btfids: unresolved symbol migrate_disable
> >   make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
> >   make[2]: *** Deleting file 'vmlinux.unstripped'
> >   make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
> >   make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2
> >
> > In pahole patch [1], if two functions having identical names but different
> > addresses, then this function name is considered ambiguous and later on
> > this function will not be added to vmlinux/module BTF.
> >
> > Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") changed
> > original global funcitons migrate_{enable,disable} to
> >   - in kernel/sched/core.c, migrate_{enable,disable} are global funcitons.
> >   - in other places, migrate_{enable,disable} may survive as static functions
> >     since they are marked as 'inline' in include/linux/sched.h and the
> >     'inline' attribute does not garantee inlining.
> >
> > If I build with clang compiler (make LLVM=1 -j) (llvm21 and llvm22), I found
> > there are four symbols for migrate_{enable,disable} respectively, three
> > static functions and one global function. With the above pahole patch [1],
> > migrate_{enable,disable} are not in vmlinux BTF and this will cause
> > later resolve_btfids failure.
> >
> > Making migrate_{enable,disable} always inline in include/linux/sched.h
> > can fix the problem.
> >
> >   [1] https://lore.kernel.org/dwarves/79a329ef-9bb3-454e-9135-731f2fd51951@oracle.com/
> >
> > Fixes: 378b7708194f ("sched: Make migrate_{en,dis}able() inline")
> > Cc: Menglong Dong <menglong8.dong@gmail.com>
> > Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
> > Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> > ---
> >  include/linux/sched.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/sched.h b/include/linux/sched.h
> > index cbb7340c5866..b469878de25c 100644
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -2407,12 +2407,12 @@ static inline void __migrate_enable(void) { }
> >   * be defined in kernel/sched/core.c.
> >   */
> >  #ifndef INSTANTIATE_EXPORTED_MIGRATE_DISABLE
> > -static inline void migrate_disable(void)
> > +static __always_inline void migrate_disable(void)
> >  {
> >         __migrate_disable();
> >  }
> >
> > -static inline void migrate_enable(void)
> > +static __always_inline void migrate_enable(void)
> >  {
> >         __migrate_enable();
> >  }
> 
> Peter,
> 
> Are you ok if we take this?

Yes, but WTH would clang not inline this trivial function to begin with?

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

* Re: [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
  2025-10-30 10:53   ` Peter Zijlstra
@ 2025-10-30 15:18     ` Yonghong Song
  0 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2025-10-30 15:18 UTC (permalink / raw)
  To: Peter Zijlstra, Alexei Starovoitov
  Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Kernel Team, Martin KaFai Lau, Menglong Dong, Ihor Solodrai



On 10/30/25 3:53 AM, Peter Zijlstra wrote:
> On Wed, Oct 29, 2025 at 06:13:21PM -0700, Alexei Starovoitov wrote:
>> On Wed, Oct 29, 2025 at 11:37 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>>> With latest bpf/bpf-next tree and latest pahole master, I got the following
>>> build failure:
>>>
>>>    $ make LLVM=1 -j
>>>      ...
>>>      LD      vmlinux.o
>>>      GEN     .vmlinux.objs
>>>      ...
>>>      BTF     .tmp_vmlinux1.btf.o
>>>      ...
>>>      AS      .tmp_vmlinux2.kallsyms.o
>>>      LD      vmlinux.unstripped
>>>      BTFIDS  vmlinux.unstripped
>>>    WARN: resolve_btfids: unresolved symbol migrate_enable
>>>    WARN: resolve_btfids: unresolved symbol migrate_disable
>>>    make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
>>>    make[2]: *** Deleting file 'vmlinux.unstripped'
>>>    make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
>>>    make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2
>>>
>>> In pahole patch [1], if two functions having identical names but different
>>> addresses, then this function name is considered ambiguous and later on
>>> this function will not be added to vmlinux/module BTF.
>>>
>>> Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") changed
>>> original global funcitons migrate_{enable,disable} to
>>>    - in kernel/sched/core.c, migrate_{enable,disable} are global funcitons.
>>>    - in other places, migrate_{enable,disable} may survive as static functions
>>>      since they are marked as 'inline' in include/linux/sched.h and the
>>>      'inline' attribute does not garantee inlining.
>>>
>>> If I build with clang compiler (make LLVM=1 -j) (llvm21 and llvm22), I found
>>> there are four symbols for migrate_{enable,disable} respectively, three
>>> static functions and one global function. With the above pahole patch [1],
>>> migrate_{enable,disable} are not in vmlinux BTF and this will cause
>>> later resolve_btfids failure.
>>>
>>> Making migrate_{enable,disable} always inline in include/linux/sched.h
>>> can fix the problem.
>>>
>>>    [1] https://lore.kernel.org/dwarves/79a329ef-9bb3-454e-9135-731f2fd51951@oracle.com/
>>>
>>> Fixes: 378b7708194f ("sched: Make migrate_{en,dis}able() inline")
>>> Cc: Menglong Dong <menglong8.dong@gmail.com>
>>> Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
>>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>>> ---
>>>   include/linux/sched.h | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>>> index cbb7340c5866..b469878de25c 100644
>>> --- a/include/linux/sched.h
>>> +++ b/include/linux/sched.h
>>> @@ -2407,12 +2407,12 @@ static inline void __migrate_enable(void) { }
>>>    * be defined in kernel/sched/core.c.
>>>    */
>>>   #ifndef INSTANTIATE_EXPORTED_MIGRATE_DISABLE
>>> -static inline void migrate_disable(void)
>>> +static __always_inline void migrate_disable(void)
>>>   {
>>>          __migrate_disable();
>>>   }
>>>
>>> -static inline void migrate_enable(void)
>>> +static __always_inline void migrate_enable(void)
>>>   {
>>>          __migrate_enable();
>>>   }
>> Peter,
>>
>> Are you ok if we take this?
> Yes, but WTH would clang not inline this trivial function to begin with?

I checked asm codes with migrate_disable(). In the above cases, 
__migrate_disable() is inlined and the function body of 
migrate_disable() then becomes reasonably big. The caller of 
migrate_disable() are ring_buffer_resize()*/*range_tree_set()/... which 
are pretty big too.


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

* Re: [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file
  2025-10-29 18:36 [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file Yonghong Song
  2025-10-30  1:00 ` Menglong Dong
  2025-10-30  1:13 ` Alexei Starovoitov
@ 2025-10-31 18:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-31 18:20 UTC (permalink / raw)
  To: Yonghong Song
  Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau, menglong8.dong,
	ihor.solodrai

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Wed, 29 Oct 2025 11:36:46 -0700 you wrote:
> With latest bpf/bpf-next tree and latest pahole master, I got the following
> build failure:
> 
>   $ make LLVM=1 -j
>     ...
>     LD      vmlinux.o
>     GEN     .vmlinux.objs
>     ...
>     BTF     .tmp_vmlinux1.btf.o
>     ...
>     AS      .tmp_vmlinux2.kallsyms.o
>     LD      vmlinux.unstripped
>     BTFIDS  vmlinux.unstripped
>   WARN: resolve_btfids: unresolved symbol migrate_enable
>   WARN: resolve_btfids: unresolved symbol migrate_disable
>   make[2]: *** [/home/yhs/work/bpf-next/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
>   make[2]: *** Deleting file 'vmlinux.unstripped'
>   make[1]: *** [/home/yhs/work/bpf-next/Makefile:1242: vmlinux] Error 2
>   make: *** [/home/yhs/work/bpf-next/Makefile:248: __sub-make] Error 2
> 
> [...]

Here is the summary with links:
  - [bpf] bpf: Make migrate_{disable,enable} always inline if in header file
    https://git.kernel.org/bpf/bpf/c/14a7f2392f42

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 18:36 [PATCH bpf] bpf: Make migrate_{disable,enable} always inline if in header file Yonghong Song
2025-10-30  1:00 ` Menglong Dong
2025-10-30  1:13 ` Alexei Starovoitov
2025-10-30 10:53   ` Peter Zijlstra
2025-10-30 15:18     ` Yonghong Song
2025-10-31 18:20 ` patchwork-bot+netdevbpf

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