* [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry.
@ 2025-12-25 9:40 Wale Zhang
2025-12-25 10:22 ` Barry Song
0 siblings, 1 reply; 13+ messages in thread
From: Wale Zhang @ 2025-12-25 9:40 UTC (permalink / raw)
To: akpm; +Cc: lorenzo.stoakes, baohua, chrisl, linux-mm, 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 <wale.zhang.ftd@gmail.com>
---
include/linux/swapops.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 8cfc966eae48..84eb36d97212 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -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,
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-25 9:40 [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry Wale Zhang @ 2025-12-25 10:22 ` Barry Song 2025-12-26 11:45 ` wale zhang 0 siblings, 1 reply; 13+ messages in thread From: Barry Song @ 2025-12-25 10:22 UTC (permalink / raw) To: Wale Zhang; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > ../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 <wale.zhang.ftd@gmail.com> 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. > --- > include/linux/swapops.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/swapops.h b/include/linux/swapops.h > index 8cfc966eae48..84eb36d97212 100644 > --- a/include/linux/swapops.h > +++ b/include/linux/swapops.h > @@ -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, > -- > 2.43.0 > Thanks Barry ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-25 10:22 ` Barry Song @ 2025-12-26 11:45 ` wale zhang 2025-12-26 18:43 ` Barry Song 2025-12-30 5:00 ` Matthew Wilcox 0 siblings, 2 replies; 13+ messages in thread From: wale zhang @ 2025-12-26 11:45 UTC (permalink / raw) To: Barry Song; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > ../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 <wale.zhang.ftd@gmail.com> > > 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. 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. > > > --- > > include/linux/swapops.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/include/linux/swapops.h b/include/linux/swapops.h > > index 8cfc966eae48..84eb36d97212 100644 > > --- a/include/linux/swapops.h > > +++ b/include/linux/swapops.h > > @@ -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, > > -- > > 2.43.0 > > > > Thanks > Barry -- Thanks Wale ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-26 11:45 ` wale zhang @ 2025-12-26 18:43 ` Barry Song 2025-12-27 7:51 ` wale zhang 2025-12-30 5:00 ` Matthew Wilcox 1 sibling, 1 reply; 13+ messages in thread From: Barry Song @ 2025-12-26 18:43 UTC (permalink / raw) To: wale zhang; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > 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. > > 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. 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-26 18:43 ` Barry Song @ 2025-12-27 7:51 ` wale zhang 2025-12-27 8:16 ` Barry Song 0 siblings, 1 reply; 13+ messages in thread From: wale zhang @ 2025-12-27 7:51 UTC (permalink / raw) To: Barry Song; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Sat, Dec 27, 2025 at 2:43 AM Barry Song <21cnbao@gmail.com> wrote: > > On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > > > 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. > > > > 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. > > 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? 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)); } > Thanks > Barry -- Thanks Wale ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-27 7:51 ` wale zhang @ 2025-12-27 8:16 ` Barry Song 2025-12-27 9:58 ` wale zhang 0 siblings, 1 reply; 13+ messages in thread From: Barry Song @ 2025-12-27 8:16 UTC (permalink / raw) To: wale zhang; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Sat, Dec 27, 2025 at 8:51 PM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > On Sat, Dec 27, 2025 at 2:43 AM Barry Song <21cnbao@gmail.com> wrote: > > > > On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > > > > > 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. > > > > > > 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. > > > > 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? > > 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. > > 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)); > } > Thanks Barry ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-27 8:16 ` Barry Song @ 2025-12-27 9:58 ` wale zhang 2025-12-27 11:25 ` Barry Song 2025-12-28 21:37 ` Andrew Morton 0 siblings, 2 replies; 13+ messages in thread From: wale zhang @ 2025-12-27 9:58 UTC (permalink / raw) To: Barry Song; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Sat, Dec 27, 2025 at 4:16 PM Barry Song <21cnbao@gmail.com> wrote: > > On Sat, Dec 27, 2025 at 8:51 PM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > On Sat, Dec 27, 2025 at 2:43 AM Barry Song <21cnbao@gmail.com> wrote: > > > > > > On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > > > > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > > > > > > > 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. > > > > > > > > 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. > > > > > > 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? > > > > 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. 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 } > > let me give you an example: > #if 0 > aaa; > #endif > > main() > { > > } > > Imagine this set_pmd_migration_entry() as aaa. > > > > > 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)); > > } > > > > Thanks > Barry -- Thanks Wale On Sat, Dec 27, 2025 at 4:16 PM Barry Song <21cnbao@gmail.com> wrote: > > On Sat, Dec 27, 2025 at 8:51 PM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > On Sat, Dec 27, 2025 at 2:43 AM Barry Song <21cnbao@gmail.com> wrote: > > > > > > On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > > > > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > > > > > > > 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. > > > > > > > > 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. > > > > > > 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? > > > > 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. > > > > > 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)); > > } > > > > Thanks > Barry ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-27 9:58 ` wale zhang @ 2025-12-27 11:25 ` Barry Song 2025-12-28 21:37 ` Andrew Morton 1 sibling, 0 replies; 13+ messages in thread From: Barry Song @ 2025-12-27 11:25 UTC (permalink / raw) To: wale zhang; +Cc: akpm, lorenzo.stoakes, chrisl, linux-mm On Sat, Dec 27, 2025 at 5:58 PM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > On Sat, Dec 27, 2025 at 4:16 PM Barry Song <21cnbao@gmail.com> wrote: > > > > On Sat, Dec 27, 2025 at 8:51 PM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > On Sat, Dec 27, 2025 at 2:43 AM Barry Song <21cnbao@gmail.com> wrote: > > > > > > > > On Sat, Dec 27, 2025 at 12:46 AM wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > > > On Thu, Dec 25, 2025 at 6:22 PM Barry Song <21cnbao@gmail.com> wrote: > > > > > > > > > > > > On Thu, Dec 25, 2025 at 10:41 PM Wale Zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > > > > > > > > > ../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 <wale.zhang.ftd@gmail.com> > > > > > > > > > > > > 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. > > > > > > > > > > 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. > > > > > > > > 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? > > > > > > 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. > > 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 ... 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. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-27 9:58 ` wale zhang 2025-12-27 11:25 ` Barry Song @ 2025-12-28 21:37 ` Andrew Morton 2025-12-28 22:07 ` Barry Song 1 sibling, 1 reply; 13+ messages in thread From: Andrew Morton @ 2025-12-28 21:37 UTC (permalink / raw) To: wale zhang; +Cc: Barry Song, lorenzo.stoakes, chrisl, linux-mm On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <wale.zhang.ftd@gmail.com> wrote: > > 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. > > 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.) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-28 21:37 ` Andrew Morton @ 2025-12-28 22:07 ` Barry Song 2025-12-29 11:37 ` wale zhang 0 siblings, 1 reply; 13+ messages in thread From: Barry Song @ 2025-12-28 22:07 UTC (permalink / raw) To: akpm; +Cc: 21cnbao, chrisl, linux-mm, lorenzo.stoakes, wale.zhang.ftd On Mon, Dec 29, 2025 at 10:37 AM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > 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. > > > > 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: diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 8cfc966eae48..fdd4375d5d90 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -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) { } diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 23379663b1e1..74d23c91626a 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-28 22:07 ` Barry Song @ 2025-12-29 11:37 ` wale zhang 0 siblings, 0 replies; 13+ messages in thread From: wale zhang @ 2025-12-29 11:37 UTC (permalink / raw) To: Barry Song; +Cc: akpm, chrisl, linux-mm, lorenzo.stoakes On Mon, Dec 29, 2025 at 6:07 AM Barry Song <21cnbao@gmail.com> wrote: > > On Mon, Dec 29, 2025 at 10:37 AM Andrew Morton <akpm@linux-foundation.org> wrote: > > > > On Sat, 27 Dec 2025 17:58:40 +0800 wale zhang <wale.zhang.ftd@gmail.com> wrote: > > > > > > 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. > > > > > > 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: > > diff --git a/include/linux/swapops.h b/include/linux/swapops.h > index 8cfc966eae48..fdd4375d5d90 100644 > --- a/include/linux/swapops.h > +++ b/include/linux/swapops.h > @@ -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) { } > > diff --git a/mm/migrate_device.c b/mm/migrate_device.c > index 23379663b1e1..74d23c91626a 100644 > --- a/mm/migrate_device.c > +++ b/mm/migrate_device.c > @@ -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 > OK. I will prepare the next patch to delete this unnecessary codes. Thank you for your guidance. -- Thanks Wale ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-26 11:45 ` wale zhang 2025-12-26 18:43 ` Barry Song @ 2025-12-30 5:00 ` Matthew Wilcox 2025-12-30 8:05 ` wale zhang 1 sibling, 1 reply; 13+ messages in thread From: Matthew Wilcox @ 2025-12-30 5:00 UTC (permalink / raw) To: wale zhang; +Cc: Barry Song, akpm, lorenzo.stoakes, chrisl, linux-mm On Fri, Dec 26, 2025 at 07:45:48PM +0800, wale zhang wrote: > 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? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry. 2025-12-30 5:00 ` Matthew Wilcox @ 2025-12-30 8:05 ` wale zhang 0 siblings, 0 replies; 13+ messages in thread From: wale zhang @ 2025-12-30 8:05 UTC (permalink / raw) To: Matthew Wilcox; +Cc: Barry Song, akpm, lorenzo.stoakes, chrisl, linux-mm On Tue, Dec 30, 2025 at 1:00 PM Matthew Wilcox <willy@infradead.org> wrote: > > On Fri, Dec 26, 2025 at 07:45:48PM +0800, wale zhang wrote: > > 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-12-30 8:05 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-12-25 9:40 [PATCH 1/1] mm,swapops: Fix compile error on set_pmd_migration_entry Wale Zhang 2025-12-25 10:22 ` Barry Song 2025-12-26 11:45 ` wale zhang 2025-12-26 18:43 ` Barry Song 2025-12-27 7:51 ` wale zhang 2025-12-27 8:16 ` Barry Song 2025-12-27 9:58 ` wale zhang 2025-12-27 11:25 ` Barry Song 2025-12-28 21:37 ` Andrew Morton 2025-12-28 22:07 ` Barry Song 2025-12-29 11:37 ` wale zhang 2025-12-30 5:00 ` Matthew Wilcox 2025-12-30 8:05 ` wale zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox