bpf: Make migrate_{disable,enable} always inline if in header file
Yonghong Song
reviewerPATCH 1/1 bpf: Make migrate_{disable,enable} always inline if in header file
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 2In 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/[email protected]/
--- include/linux/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched.h +2 -2
@@ -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 (); }
Signature · 1 line
2.47.3
Quoted 60 lines · Yonghong Song
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 2In 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
- inkernel/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' ininclude/linux/sched.hand 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_btfidsfailure.Making migrate_{enable,disable} always inline in
include/linux/sched.hcan fix the problem.[1] https://lore.kernel.org/dwarves/[email protected]/
Fixes 378b7708194f ("sched: Make migrate_{en,dis}able() inline")Cc Menglong Dong <[email protected]>Cc Ihor Solodrai <[email protected]>Signed-off-by Yonghong Song <[email protected]>--- include/linux/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/sched.h +0
-1@@ -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 )
include/linux/sched.h static inline void __migrate_enable(void) { } · line 2418
Quoted 10 lines
include/linux/sched.h +2
-1+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.
Peter Zijlstra
maintainerQuoted 74 lines · Alexei Starovoitov
Quoted 60 lines · Yonghong Song
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 2In 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
- inkernel/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' ininclude/linux/sched.hand 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_btfidsfailure.Making migrate_{enable,disable} always inline in
include/linux/sched.hcan fix the problem.[1] https://lore.kernel.org/dwarves/[email protected]/
Fixes 378b7708194f ("sched: Make migrate_{en,dis}able() inline")Cc Menglong Dong <[email protected]>Cc Ihor Solodrai <[email protected]>Signed-off-by Yonghong Song <[email protected]>--- include/linux/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/sched.h +0
-1@@ -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 )include/linux/sched.h static inline void __migrate_enable(void) { } · line 2418
Quoted 10 lines
include/linux/sched.h +2
-1+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,
Quoted 1 line
Are you ok if we take this?
Yes, but WTH would clang not inline this trivial function to begin with?
Yonghong Song
reviewerQuoted 73 lines · Peter Zijlstra
Quoted 72 lines · Alexei Starovoitov
Quoted 59 lines · Yonghong Song
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 2In 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
- inkernel/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' ininclude/linux/sched.hand 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_btfidsfailure.Making migrate_{enable,disable} always inline in
include/linux/sched.hcan fix the problem.[1] https://lore.kernel.org/dwarves/[email protected]/Fixes 378b7708194f ("sched: Make migrate_{en,dis}able() inline")Cc Menglong Dong <[email protected]>Cc Ihor Solodrai <[email protected]>Signed-off-by Yonghong Song <[email protected]>--- include/linux/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/sched.h +0
-1@@ -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 )include/linux/sched.h static inline void __migrate_enable(void) { } · line 2418
Quoted 10 lines
include/linux/sched.h +2
-1+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,
Quoted 2 lines
Quoted 1 line
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.
Quoted 55 lines · Yonghong Song
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 2In 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
- inkernel/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' ininclude/linux/sched.hand 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_btfidsfailure.Making migrate_{enable,disable} always inline in
include/linux/sched.hcan fix the problem.[1] https://lore.kernel.org/dwarves/[email protected]/
Fixes 378b7708194f ("sched: Make migrate_{en,dis}able() inline")Cc Menglong Dong <[email protected]>Cc Ihor Solodrai <[email protected]>Signed-off-by Yonghong Song <[email protected]>--- include/linux/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/sched.h +0
-0
include/linux/sched.h static inline void __migrate_enable(void) { } · line 2413
Quoted 8 lines
include/linux/sched.h +1
-1@@ -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 :)
Quoted 7 lines
include/linux/sched.h +1
-1-static inline void migrate_enable (void ) +static __always_inline void migrate_enable(void) {__migrate_enable (); }
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 20 lines · 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
Quoted 1 line
[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html