mm,swapops: Fix compile error on set_pmd_migration_entry.
Subsystems (3)
PATCH 1/1 mm,swapops: Fix compile error on set_pmd_migration_entry.
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }
| ^
cc1: some warnings being treated as errors
--- include/linux/swapops.h | 1 + 1 file changed, 1 insertion(+)
include/linux/swapops.h +1 -0
@@ -343,6 +343,7 @@ static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, struct page *page) {BUILD_BUG (); +return 0 ; } static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
Signature · 1 line
2.43.0
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>
Sorry. NAK.
This looks odd. We already have a BUILD_BUG(), so no fix is needed.
we should already have:././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error: BUILD_BUG failed
631 | _compiletime_assert(condition, msg,__compiletime_assert_, __COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’
612 | prefix ## suffix();
\
| ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Quoted 17 lines
--- include/linux/swapops.h | 1 + 1 file changed, 1 insertion(+)include/linux/swapops.h +1
-1@@ -343,6 +343,7 @@ static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, struct page *page) {BUILD_BUG (); +return 0 ; } static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, --
Quoted 2 lines
2.43.0
Thanks
Barry
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’
Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from /home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from /home/wale/repo/linux/master/include/linux/mm_inline.h:10, from /home/wale/repo/linux/master/mm/internal.h:13, from /home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }
| ^
cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....
There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 16 lines
Quoted 16 lines
--- include/linux/swapops.h | 1 + 1 file changed, 1 insertion(+)include/linux/swapops.h +1
-0@@ -343,6 +343,7 @@ static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, struct page *page) {BUILD_BUG (); +return 0 ; }
Quoted 7 lines
Quoted 4 lines
include/linux/swapops.h +0
-1static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, --2.43.0
Thanks
Barry
--
Thanks
Wale
Quoted 53 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....
Quoted 4 lines
There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
This is not my question. The BUILD_BUG here means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?
Thanks
Barry
Quoted 60 lines · Barry Song
Quoted 53 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....Quoted 4 lines
There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 4 lines
This is not my question. The
BUILD_BUGhere means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?
Hello Barry,
I'm very sorry for misunderstanding your meaning.
For -O0, __OPTIMIZE__ isn't defined, so line 615 is hit.
595 #ifdef __OPTIMIZE__
602 # define __compiletime_assert(condition, msg, prefix, suffix) \
612 prefix ## suffix();
614 #else
615 # define __compiletime_assert(condition, msg, prefix, suffix) ((void)(condition))
616 #endif
Finally, set_pmd_migration_entry is defined as follow:
static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
struct page *page)
{
- BUILD_BUG();
+ ((void)(0));
}
Quoted 2 lines
Thanks
Barry
--
Thanks
Wale
Quoted 62 lines · wale zhang
Quoted 60 lines · Barry Song
Quoted 57 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 8 lines
Quoted 4 lines
This is not my question. The
BUILD_BUGhere means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?Hello Barry,
I'm very sorry for misunderstanding your meaning.
No. You still don’t understand my point. The BUILD_BUG means this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.
This set_pmd_migration_entry() has no chance of ever being built.
let me give you an example:
#if 0
aaa;
#endif
main()
{
}
Imagine this set_pmd_migration_entry() as aaa.
Quoted 17 lines
For -O0,
__OPTIMIZE__isn't defined, so line 615 is hit.595 #ifdef
__OPTIMIZE__
602 # define__compiletime_assert(condition, msg, prefix, suffix)\
612 prefix ##suffix();
614 #else
615 # define__compiletime_assert(condition, msg, prefix, suffix)((void)(condition))
616 #endifFinally,
set_pmd_migration_entryis defined as follow:
static inline int set_pmd_migration_entry(structpage_vma_mapped_walk*pvmw,
struct page *page)
{(quoted diff) +1
-1- BUILD_BUG(); + ((void)(0));
Quoted 2 lines
}
Thanks
Barry
Quoted 71 lines · Barry Song
Quoted 69 lines · wale zhang
Quoted 60 lines · Barry Song
Quoted 53 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....Quoted 4 lines
There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 4 lines
This is not my question. The
BUILD_BUGhere means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?Hello Barry,
Quoted 8 lines
Quoted 1 line
I'm very sorry for misunderstanding your meaning.
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.
Hello Barry,
set_pmd_migration_entry() is defined in include/linux/swapops.h. For not defining CONFIG_ARCH_ENABLE_THP_MIGRATION, line 342~346 will be built as long as *.c file includes swapops.h.
There are many .c files including the header file directly or indirectly, such as fadvise.c, shm.c ...
include/linux/swapops.h
324 #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
325 extern int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
326 struct page *page);
341 #else /* CONFIG_ARCH_ENABLE_THP_MIGRATION */
342 static inline int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
343 struct page *page)
344 {
345 BUILD_BUG();
346 }
Quoted 33 lines
let me give you an example:
#if 0
aaa;
#endif
main()
{}
Imagine this
set_pmd_migration_entry()as aaa.Quoted 17 lines
For -O0,
__OPTIMIZE__isn't defined, so line 615 is hit.595 #ifdef
__OPTIMIZE__
602 # define__compiletime_assert(condition, msg, prefix, suffix)\
612 prefix ##suffix();
614 #else
615 # define__compiletime_assert(condition, msg, prefix, suffix)((void)(condition))
616 #endifFinally,
set_pmd_migration_entryis defined as follow:
static inline int set_pmd_migration_entry(structpage_vma_mapped_walk*pvmw,
struct page *page)
{(quoted diff) +1
-1- BUILD_BUG(); + ((void)(0));Quoted 2 lines
}
Quoted 2 lines
Thanks
Barry
--
Thanks
Wale
Quoted 114 lines · Barry Song
Quoted 62 lines · wale zhang
Quoted 60 lines · Barry Song
Quoted 57 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 8 lines
Quoted 4 lines
This is not my question. The
BUILD_BUGhere means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?Hello Barry,
I'm very sorry for misunderstanding your meaning.
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.let me give you an example:
#if 0
aaa;
#endif
main()
{}
Imagine this
set_pmd_migration_entry()as aaa.Quoted 17 lines
For -O0,
__OPTIMIZE__isn't defined, so line 615 is hit.595 #ifdef
__OPTIMIZE__
602 # define__compiletime_assert(condition, msg, prefix, suffix)\
612 prefix ##suffix();
614 #else
615 # define__compiletime_assert(condition, msg, prefix, suffix)((void)(condition))
616 #endifFinally,
set_pmd_migration_entryis defined as follow:
static inline int set_pmd_migration_entry(structpage_vma_mapped_walk*pvmw,
struct page *page)
{(quoted diff) +1
-1- BUILD_BUG(); + ((void)(0));Quoted 2 lines
}
Thanks
Barry
Quoted 82 lines · wale zhang
Quoted 71 lines · Barry Song
Quoted 69 lines · wale zhang
Quoted 60 lines · Barry Song
Quoted 53 lines · wale zhang
Quoted 24 lines · Barry Song
Quoted 8 lines · Wale Zhang
../include/linux/swapops.h: In function ‘set_pmd_migration_entry’:../include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
Signed-off-by Wale Zhang <[email protected]>Sorry. NAK.
This looks odd. We already have a
BUILD_BUG(), so no fix is needed.we should already have:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_907’ declared with attribute error:BUILD_BUGfailed
631 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
| ^././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’Quoted 6 lines
612 | prefix ## suffix(); \ | ^~~~~~Do you actually see this being built? If so, please help identify why it gets built.
Hello Barry,
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear. In file included from
/home/wale/repo/linux/master/include/linux/leafops.h:11,
from/home/wale/repo/linux/master/include/linux/userfaultfd_k.h:19,
from/home/wale/repo/linux/master/include/linux/mm_inline.h:10, from/home/wale/repo/linux/master/mm/internal.h:13, from/home/wale/repo/linux/master/mm/fadvise.c:24:/home/wale/repo/linux/master/include/linux/swapops.h: In function ‘set_pmd_migration_entry’:/home/wale/repo/linux/master/include/linux/swapops.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | }| ^cc1: some warnings being treated as errors
make[4]: *** [/home/wale/repo/linux/master/scripts/Makefile.build:287:mm/fadvise.o] Error 1
make[4]: *** Waiting for unfinished jobs....Quoted 4 lines
There is an example on my github(https://github.com/wale-ftd/linux/commits/linux-6.12/) that used -O0 to compile the 6.12 kernel. If you're interested, you can check them out.
Quoted 4 lines
This is not my question. The
BUILD_BUGhere means this code should never be built. If it is built, then that indicates a bug. So my question is: under what kernel configuration would this code actually get built?Hello Barry,
Quoted 8 lines
Quoted 1 line
I'm very sorry for misunderstanding your meaning.
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.
Quoted 7 lines
Hello Barry,
set_pmd_migration_entry()is defined ininclude/linux/swapops.h. For not definingCONFIG_ARCH_ENABLE_THP_MIGRATION, line 342~346 will be built as long as *.c file includesswapops.h.
There are many .c files including the header file directly or indirectly, such asfadvise.c,shm.c...
As far as I understand, set_pmd_migration_entry is never called unless CONFIG_ARCH_ENABLE_THP_MIGRATION is enabled. If that is correct, no fix is required.
Andrew Morton
maintainerQuoted 9 lines · On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <[email protected]> wrote:
Quoted 6 lines
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.Hello Barry,
Please share the .config which was used to trigger this build error.
(It is strange to have this should-never-be-compiled code. Why not just delete it and let the compiler/linker report the error.)
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <[email protected]> wrote:
Quoted 6 lines
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.
Quoted 7 lines
Quoted 2 lines
Hello Barry,
Please share the .config which was used to trigger this build error.
(It is strange to have this should-never-be-compiled code. Why not just delete it and let the compiler/linker report the error.)
Right. We should entirely drop it in mainline. If Wale does want an O0 build, then the only call to set_pmd_migration_entry() that is not under
#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
is migrate_vma_collect_huge_pmd() in mm/migrate_device.c.
Then what we really need is as follows:
include/linux/swapops.h +0 -11
@@ -339,17 +339,6 @@ static inline pmd_t swp_entry_to_pmd(swp_entry_t entry) }#else /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ -static inline int set_pmd_migration_entry (struct page_vma_mapped_walk *pvmw, -struct page *page) -{ -BUILD_BUG (); -} - -static inline void remove_migration_pmd (struct page_vma_mapped_walk *pvmw, -struct page *new) -{ -BUILD_BUG (); -}static inline void pmd_migration_entry_wait (struct mm_struct *m,pmd_t *p) { }
mm/migrate_device.c +4 -2
@@ -195,8 +195,9 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,return migrate_vma_collect_skip (start, end, walk); } -if (thp_migration_supported () && - (migrate->flags &MIGRATE_VMA_SELECT_COMPOUND ) && + +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION +if ((migrate->flags &MIGRATE_VMA_SELECT_COMPOUND ) && (IS_ALIGNED (start,HPAGE_PMD_SIZE ) &&IS_ALIGNED (end,HPAGE_PMD_SIZE ))) {
@@ -226,6 +227,7 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,spin_unlock (ptl); return 0; } +#endif fallback:spin_unlock (ptl);
Thanks
Barry
Quoted 77 lines · Barry Song
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <[email protected]> wrote:
Quoted 6 lines
No. You still don’t understand my point. The
BUILD_BUGmeans this code will never have a chance to be compiled under any possible kernel configuration. That makes it dead code. If there is any kernel .config in which it can be built, then we should fix it.This
set_pmd_migration_entry()has no chance of ever being built.Quoted 7 lines
Quoted 2 lines
Hello Barry,
Please share the .config which was used to trigger this build error.
(It is strange to have this should-never-be-compiled code. Why not just delete it and let the compiler/linker report the error.)
Right. We should entirely drop it in mainline. If Wale does want an O0 build, then the only call to
set_pmd_migration_entry()that is not under#ifdef
CONFIG_ARCH_ENABLE_THP_MIGRATIONis
migrate_vma_collect_huge_pmd()inmm/migrate_device.c.Then what we really need is as follows:
include/linux/swapops.h +0
-11@@ -339,17 +339,6 @@ static inline pmd_t swp_entry_to_pmd(swp_entry_t entry) }#else /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ -static inline int set_pmd_migration_entry (struct page_vma_mapped_walk *pvmw, -struct page *page) -{ -BUILD_BUG (); -} - -static inline void remove_migration_pmd (struct page_vma_mapped_walk *pvmw, -struct page *new) -{ -BUILD_BUG (); -}static inline void pmd_migration_entry_wait (struct mm_struct *m,pmd_t *p) { }mm/migrate_device.c +4
-2@@ -195,8 +195,9 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,return migrate_vma_collect_skip (start, end, walk); } -if (thp_migration_supported () && - (migrate->flags &MIGRATE_VMA_SELECT_COMPOUND ) && + +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION +if ((migrate->flags &MIGRATE_VMA_SELECT_COMPOUND ) && (IS_ALIGNED (start,HPAGE_PMD_SIZE ) &&IS_ALIGNED (end,HPAGE_PMD_SIZE ))) {@@ -226,6 +227,7 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,spin_unlock (ptl); return 0; } +#endif fallback:spin_unlock (ptl);
Quoted 3 lines
Thanks
Barry
OK. I will prepare the next patch to delete this unnecessary codes. Thank you for your guidance.
--
Thanks
Wale
Quoted 1 line · wale zhang
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear.
I don't think we support compilation with -O0. Why did you think this would work, and why did you think this was a good idea?
Quoted 6 lines · Matthew Wilcox
Quoted 1 line · wale zhang
I compile the 6.19-rc2 for arm64 with -O0, this kind of error log will appear.
I don't think we support compilation with -O0. Why did you think this would work, and why did you think this was a good idea?
Hello Matthew,
Compilation with -O0 is mainly for beginners to learn and debug. I don't want to encounter the same problems every time I pull the latest code. Perhaps other people will also encounter the same problem.
And I see that include/linux/pgtable.h has the same usage.
320 static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
321 unsigned long address, pmd_t *pmdp,
322 pmd_t entry, int dirty)
323 {
324 BUILD_BUG();
325 return 0;
326 }
Thanks
Wale