mm/swapops,rmap: remove should-never-be-compiled codes.
Subsystems (4)
PATCH v2 1/1 mm/swapops,rmap: remove should-never-be-compiled codes.
mm/swapops,rmap: remove should-never-be-compiled codes, included folio_add_return_large_mapcount(), folio_sub_return_large_mapcount(), set_pmd_migration_entry() and remove_migration_pmd().
--- include/linux/rmap.h | 17 ++----- include/linux/swapops.h | 12 ----- mm/migrate_device.c | 5 ++- mm/rmap.c | 98 ++++++++++++++++++++--------------------- 4 files changed, 54 insertions(+), 78 deletions(-)
include/linux/rmap.h +4 -13
@@ -354,33 +354,24 @@ static inline void folio_add_large_mapcount(struct folio *folio, atomic_add(diff, &folio->_large_mapcount); } -static inline int folio_add_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -} -static inline void folio_sub_large_mapcount (struct folio *folio,int diff,struct vm_area_struct *vma) {atomic_sub (diff, &folio->_large_mapcount); } -static inline int folio_sub_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -}#endif /* CONFIG_MM_ID */ #define folio_inc_large_mapcount (folio, vma) \ folio_add_large_mapcount(folio, 1, vma) -#define folio_inc_return_large_mapcount (folio, vma) \ - folio_add_return_large_mapcount(folio, 1, vma)#define folio_dec_large_mapcount (folio, vma) \ folio_sub_large_mapcount(folio, 1, vma) +#ifdef CONFIG_NO_PAGE_MAPCOUNT +#define folio_inc_return_large_mapcount (folio, vma) \ + folio_add_return_large_mapcount(folio, 1, vma)#define folio_dec_return_large_mapcount (folio, vma) \ folio_sub_return_large_mapcount(folio, 1, vma) +#endif /* RMAP flags, currently only relevant for some anon rmap operations. */ typedef int __bitwise rmap_t ;
include/linux/swapops.h +0 -12
@@ -339,18 +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) { }static inline pmd_t swp_entry_to_pmd (swp_entry_t entry)
mm/migrate_device.c +3 -2
@@ -195,8 +195,8 @@ 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 ))) {
@@ -228,6 +228,7 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start, } fallback: +#endif spin_unlock (ptl);if (!folio_test_large (folio)) goto done;
mm/rmap.c +47 -51
155 lines not on this page · raw message
Signature · 1 line
2.43.0
Andrew Morton
maintainerQuoted 3 lines · On Tue, 30 Dec 2025 21:01:10 +0800 Wale Zhang <[email protected]> wrote:
mm/swapops,rmap: remove should-never-be-compiled codes, included
folio_add_return_large_mapcount(),folio_sub_return_large_mapcount(),set_pmd_migration_entry()andremove_migration_pmd().
Please provide a reason for making this change.
Quoted 24 lines
...
mm/rmap.c +1
-12@@ -1264,22 +1262,21 @@ static __always_inline void __folio_add_rmap(struct folio *folio, nr = first;folio_add_large_mapcount (folio, orig_nr_pages, vma); +#endif break ;case PGTABLE_LEVEL_PMD :case PGTABLE_LEVEL_PUD : first =atomic_inc_and_test (&folio->_entire_mapcount); -if (IS_ENABLED (CONFIG_NO_PAGE_MAPCOUNT )) { -if (level ==PGTABLE_LEVEL_PMD && first) - nr_pmdmapped =folio_large_nr_pages (folio); - nr =folio_inc_return_large_mapcount (folio, vma); -if (nr ==1 ) -/* Was completely unmapped. */ - nr =folio_large_nr_pages (folio); -else - nr =0 ; -break ; - } -
mm/rmap.c static __always_inline void __folio_add_rmap(struct folio *folio, · line 1279
Quoted 10 lines
mm/rmap.c +10
-0+#ifdef CONFIG_NO_PAGE_MAPCOUNT +if (level ==PGTABLE_LEVEL_PMD && first) + nr_pmdmapped =folio_large_nr_pages (folio); + nr =folio_inc_return_large_mapcount (folio, vma); +if (nr ==1 ) +/* Was completely unmapped. */ + nr =folio_large_nr_pages (folio); +else + nr =0 ; +#else
Changes like this made the code unpleasant to read and harder to work on. What do we get in return for this?
David Hildenbrand (Red Hat)
maintainerQuoted 4 lines
mm/rmap.c +2
-1-break ; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last =atomic_add_negative (-1 , &folio->_entire_mapcount);
mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1706
Quoted 10 lines
mm/rmap.c +10
-0+if (level ==PGTABLE_LEVEL_PMD && last) + nr_pmdmapped =folio_large_nr_pages (folio); + nr =folio_dec_return_large_mapcount (folio, vma); +if (!nr) { +/* Now completely unmapped. */ + nr =folio_large_nr_pages (folio); + }else { + partially_mapped = last && + nr <folio_large_nr_pages (folio); + nr =0 ;
The whole code was written to avoid ifdefs.
Sorry, no.
Signature · 3 lines
Cheers David
Quoted 16 lines · David Hildenbrand (Red Hat)
Quoted 5 lines
mm/rmap.c +2
-1-break ; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last =atomic_add_negative (-1 , &folio->_entire_mapcount);mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1706
Quoted 10 lines
mm/rmap.c +10
-0+if (level ==PGTABLE_LEVEL_PMD && last) + nr_pmdmapped =folio_large_nr_pages (folio); + nr =folio_dec_return_large_mapcount (folio, vma); +if (!nr) { +/* Now completely unmapped. */ + nr =folio_large_nr_pages (folio); + }else { + partially_mapped = last && + nr <folio_large_nr_pages (folio); + nr =0 ;
Quoted 1 line
The whole code was written to avoid ifdefs.
The #ifdefs are only for -O0 builds, which are never a mainline requirement. However, dropping functions that contain nothing but a BUILD_BUG() seems reasonable?
If those functions were actually required, the compiler would fail anyway. In that case, there doesn’t seem to be much value in keeping wrapper functions whose sole purpose is to contain a single BUILD_BUG().
Thanks
Barry
Andrew Morton
maintainerQuoted 18 lines · On Wed, 31 Dec 2025 10:28:25 +1300 Barry Song <[email protected]> wrote:
Quoted 16 lines · David Hildenbrand (Red Hat)
Quoted 15 lines
mm/rmap.c +12
-1-break ; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last =atomic_add_negative (-1 , &folio->_entire_mapcount); +if (level ==PGTABLE_LEVEL_PMD && last) + nr_pmdmapped =folio_large_nr_pages (folio); + nr =folio_dec_return_large_mapcount (folio, vma); +if (!nr) { +/* Now completely unmapped. */ + nr =folio_large_nr_pages (folio); + }else { + partially_mapped = last && + nr <folio_large_nr_pages (folio); + nr =0 ;
Quoted 5 lines
Quoted 1 line
The whole code was written to avoid ifdefs.
The #ifdefs are only for -O0 builds, which are never a mainline requirement. However, dropping functions that contain nothing but a
BUILD_BUG()seems reasonable?
Let's not make -O0 an objective, please. We often make assumptions about dead code elimination in order to keep kernel code more pleasing to read and to maintain.
Quoted 4 lines
If those functions were actually required, the compiler would fail anyway. In that case, there doesn’t seem to be much value in keeping wrapper functions whose sole purpose is to contain a single
BUILD_BUG().
I agree with that part of the patch - if the thing only does a BUILD_BUG() then let's simply remove it. If somehow the compiler tries to reference the now-not-present function then we'll get an error message anyway.
David Hildenbrand (Red Hat)
maintainerQuoted 35 lines · Andrew Morton
Quoted 18 lines · On Wed, 31 Dec 2025 10:28:25 +1300 Barry Song <[email protected]> wrote:
Quoted 16 lines · David Hildenbrand (Red Hat)
Quoted 15 lines
(quoted diff) +12
-1- break; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last = atomic_add_negative(-1, &folio->_entire_mapcount); + if (level == PGTABLE_LEVEL_PMD && last) + nr_pmdmapped = folio_large_nr_pages(folio); + nr = folio_dec_return_large_mapcount(folio, vma); + if (!nr) { + /* Now completely unmapped. */ + nr = folio_large_nr_pages(folio); + } else { + partially_mapped = last && + nr < folio_large_nr_pages(folio); + nr = 0;Quoted 5 lines
Quoted 1 line
The whole code was written to avoid ifdefs.
The #ifdefs are only for -O0 builds, which are never a mainline requirement. However, dropping functions that contain nothing but a
BUILD_BUG()seems reasonable?Let's not make -O0 an objective, please. We often make assumptions about dead code elimination in order to keep kernel code more pleasing to read and to maintain.
Quoted 4 lines
If those functions were actually required, the compiler would fail anyway. In that case, there doesn’t seem to be much value in keeping wrapper functions whose sole purpose is to contain a single
BUILD_BUG().
Quoted 5 lines
I agree with that part of the patch - if the thing only does a
BUILD_BUG()then let's simply remove it. If somehow the compiler tries to reference the now-not-present function then we'll get an error message anyway.
The change
+#ifdef CONFIG_NO_PAGE_MAPCOUNT +#define folio_inc_return_large_mapcount(folio, vma) \ + folio_add_return_large_mapcount(folio, 1, vma) #define folio_dec_return_large_mapcount(folio, vma) \ folio_sub_return_large_mapcount(folio, 1, vma) +#endif
In the patch is wrong. It must be CONFIG_MM_ID.
So if the following makes compilers happy, fine with me:
include/linux/rmap.h +5 -16
@@ -336,6 +336,11 @@ static __always_inline int folio_sub_return_large_mapcount(struct folio *folio, return new_mapcount_val + 1; }#define folio_sub_large_mapcount folio_sub_return_large_mapcount + +#define folio_inc_return_large_mapcount (folio, vma) \ + folio_add_return_large_mapcount(folio, 1, vma) +#define folio_dec_return_large_mapcount (folio, vma) \ + folio_sub_return_large_mapcount(folio, 1, vma)#else /* !CONFIG_MM_ID */ /* * See __folio_rmap_sanity_checks(), we might map large folios even without
@@ -354,33 +359,17 @@ static inline void folio_add_large_mapcount(struct folio *folio, atomic_add(diff, &folio->_large_mapcount); } -static inline int folio_add_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -} -static inline void folio_sub_large_mapcount (struct folio *folio,int diff,struct vm_area_struct *vma) {atomic_sub (diff, &folio->_large_mapcount); } - -static inline int folio_sub_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -}#endif /* CONFIG_MM_ID */ #define folio_inc_large_mapcount (folio, vma) \ folio_add_large_mapcount(folio, 1, vma) -#define folio_inc_return_large_mapcount (folio, vma) \ - folio_add_return_large_mapcount(folio, 1, vma)#define folio_dec_large_mapcount (folio, vma) \ folio_sub_large_mapcount(folio, 1, vma) -#define folio_dec_return_large_mapcount (folio, vma) \ - folio_sub_return_large_mapcount(folio, 1, vma)/* RMAP flags, currently only relevant for some anon rmap operations. */ typedef int __bitwise rmap_t ;
Use a config with !CONFIG_TRANSPARENT_HUGEPAGE:
$ LANG=C make mm/rmap.o
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
DESCEND bpf/resolve_btfids
INSTALL libsubcmd_headers
CC mm/rmap.o
mm/rmap.c: In function '__folio_add_rmap':
mm/rmap.c:1249:30: error: implicit declaration of function 'folio_add_return_large_mapcount'; did you mean 'folio_add_large_mapcount'? [-Wimplicit-function-declaration]
1249 | nr = folio_add_return_large_mapcount(folio, orig_nr_pages, vma);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| folio_add_large_mapcount
mm/rmap.c:1274:30: error: implicit declaration of function 'folio_inc_return_large_mapcount'; did you mean 'folio_inc_large_mapcount'? [-Wimplicit-function-declaration]
1274 | nr = folio_inc_return_large_mapcount(folio, vma);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| folio_inc_large_mapcount
mm/rmap.c: In function '__folio_remove_rmap':
mm/rmap.c:1673:30: error: implicit declaration of function 'folio_sub_return_large_mapcount'; did you mean 'folio_sub_large_mapcount'? [-Wimplicit-function-declaration]
1673 | nr = folio_sub_return_large_mapcount(folio, nr_pages, vma);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| folio_sub_large_mapcount
mm/rmap.c:1702:30: error: implicit declaration of function 'folio_dec_return_large_mapcount'; did you mean 'folio_dec_large_mapcount'? [-Wimplicit-function-declaration]
1702 | nr = folio_dec_return_large_mapcount(folio, vma);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| folio_dec_large_mapcount
make[3]: *** [scripts/Makefile.build:287: mm/rmap.o] Error 1
make[2]: *** [scripts/Makefile.build:556: mm] Error 2
make[1]: *** [/home/dhildenb/git/linux/Makefile:2054: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2Signature · 3 lines
Cheers David
Quoted 45 lines · David Hildenbrand (Red Hat)
Quoted 35 lines · Andrew Morton
Quoted 18 lines · On Wed, 31 Dec 2025 10:28:25 +1300 Barry Song <[email protected]> wrote:
Quoted 16 lines · David Hildenbrand (Red Hat)
Quoted 15 lines
(quoted diff) +12
-1- break; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last = atomic_add_negative(-1, &folio->_entire_mapcount); + if (level == PGTABLE_LEVEL_PMD && last) + nr_pmdmapped = folio_large_nr_pages(folio); + nr = folio_dec_return_large_mapcount(folio, vma); + if (!nr) { + /* Now completely unmapped. */ + nr = folio_large_nr_pages(folio); + } else { + partially_mapped = last && + nr < folio_large_nr_pages(folio); + nr = 0;Quoted 5 lines
Quoted 1 line
The whole code was written to avoid ifdefs.
The #ifdefs are only for -O0 builds, which are never a mainline requirement. However, dropping functions that contain nothing but a
BUILD_BUG()seems reasonable?Let's not make -O0 an objective, please. We often make assumptions about dead code elimination in order to keep kernel code more pleasing to read and to maintain.
Quoted 4 lines
If those functions were actually required, the compiler would fail anyway. In that case, there doesn’t seem to be much value in keeping wrapper functions whose sole purpose is to contain a single
BUILD_BUG().Quoted 5 lines
I agree with that part of the patch - if the thing only does a
BUILD_BUG()then let's simply remove it. If somehow the compiler tries to reference the now-not-present function then we'll get an error message anyway.The change
Quoted 8 lines
+#ifdef CONFIG_NO_PAGE_MAPCOUNT +#define folio_inc_return_large_mapcount(folio, vma) \ + folio_add_return_large_mapcount(folio, 1, vma) #define folio_dec_return_large_mapcount(folio, vma) \ folio_sub_return_large_mapcount(folio, 1, vma) +#endifIn the patch is wrong. It must be
CONFIG_MM_ID.
Hello David,
folio_inc_return_large_mapcount and folio_dec_return_large_mapcount are only used when CONFIG_NO_PAGE_MAPCOUNT is defined.
Quoted 3 lines
So if the following makes compilers happy, fine with me:
Apart from the solution as below, I can't think of any other ways. Do you have any good ideas?
+#ifdef CONFIG_NO_PAGE_MAPCOUNT
- if (IS_ENABLED(CONFIG_NO_PAGE_MAPCOUNT)) {
Quoted 87 lines
include/linux/rmap.h +5
-16@@ -336,6 +336,11 @@ static __always_inline int folio_sub_return_large_mapcount(struct folio *folio, return new_mapcount_val + 1; }#define folio_sub_large_mapcount folio_sub_return_large_mapcount + +#define folio_inc_return_large_mapcount (folio, vma) \ + folio_add_return_large_mapcount(folio, 1, vma) +#define folio_dec_return_large_mapcount (folio, vma) \ + folio_sub_return_large_mapcount(folio, 1, vma)#else /* !CONFIG_MM_ID */ /* * See __folio_rmap_sanity_checks(), we might map large folios even without @@ -354,33 +359,17 @@ static inline void folio_add_large_mapcount(struct folio *folio, atomic_add(diff, &folio->_large_mapcount); } -static inline int folio_add_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -} -static inline void folio_sub_large_mapcount (struct folio *folio,int diff,struct vm_area_struct *vma) {atomic_sub (diff, &folio->_large_mapcount); } - -static inline int folio_sub_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -}#endif /* CONFIG_MM_ID */ #define folio_inc_large_mapcount (folio, vma) \ folio_add_large_mapcount(folio, 1, vma) -#define folio_inc_return_large_mapcount (folio, vma) \ - folio_add_return_large_mapcount(folio, 1, vma)#define folio_dec_large_mapcount (folio, vma) \ folio_sub_large_mapcount(folio, 1, vma) -#define folio_dec_return_large_mapcount (folio, vma) \ - folio_sub_return_large_mapcount(folio, 1, vma)/* RMAP flags, currently only relevant for some anon rmap operations. */ typedef int __bitwise rmap_t ;Use a config with !CONFIG_TRANSPARENT_HUGEPAGE:
$ LANG=C make mm/rmap.o CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers DESCEND bpf/resolve_btfids INSTALL libsubcmd_headers CC mm/rmap.o mm/rmap.c: In function '__folio_add_rmap': mm/rmap.c:1249:30: error: implicit declaration of function 'folio_add_return_large_mapcount'; did you mean 'folio_add_large_mapcount'? [-Wimplicit-function-declaration] 1249 | nr = folio_add_return_large_mapcount(folio, orig_nr_pages, vma); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | folio_add_large_mapcount mm/rmap.c:1274:30: error: implicit declaration of function 'folio_inc_return_large_mapcount'; did you mean 'folio_inc_large_mapcount'? [-Wimplicit-function-declaration] 1274 | nr = folio_inc_return_large_mapcount(folio, vma); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | folio_inc_large_mapcount mm/rmap.c: In function '__folio_remove_rmap': mm/rmap.c:1673:30: error: implicit declaration of function 'folio_sub_return_large_mapcount'; did you mean 'folio_sub_large_mapcount'? [-Wimplicit-function-declaration] 1673 | nr = folio_sub_return_large_mapcount(folio, nr_pages, vma); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | folio_sub_large_mapcount mm/rmap.c:1702:30: error: implicit declaration of function 'folio_dec_return_large_mapcount'; did you mean 'folio_dec_large_mapcount'? [-Wimplicit-function-declaration] 1702 | nr = folio_dec_return_large_mapcount(folio, vma); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | folio_dec_large_mapcount make[3]: *** [scripts/Makefile.build:287: mm/rmap.o] Error 1 make[2]: *** [scripts/Makefile.build:556: mm] Error 2 make[1]: *** [/home/dhildenb/git/linux/Makefile:2054: .] Error 2 make: *** [Makefile:248: __sub-make] Error 2
Quoted 4 lines
--
CheersDavid
Thanks
Wale
David Hildenbrand (Red Hat)
maintainerQuoted 5 lines
Hello David,
folio_inc_return_large_mapcountandfolio_dec_return_large_mapcountare only used whenCONFIG_NO_PAGE_MAPCOUNTis defined.
It's conceptually wrong to leak CONFIG_NO_PAGE_MAPCOUNT in something that is CONFIG_MM_ID material at this point.
Quoted 7 lines
Quoted 4 lines
So if the following makes compilers happy, fine with me:
Apart from the solution as below, I can't think of any other ways. Do you have any good ideas?
Leave the code alone.
What we *could* do is
include/linux/rmap.h +4 -10
@@ -354,11 +354,8 @@ static inline void folio_add_large_mapcount(struct folio *folio,atomic_add (diff, &folio->_large_mapcount); } -static inline int folio_add_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -} +int folio_add_return_large_mapcount (struct folio *folio, +int diff,struct vm_area_struct *vma);static inline void folio_sub_large_mapcount (struct folio *folio,int diff,struct vm_area_struct *vma)
@@ -366,11 +363,8 @@ static inline void folio_sub_large_mapcount(struct folio *folio, atomic_sub(diff, &folio->_large_mapcount); } -static inline int folio_sub_return_large_mapcount (struct folio *folio, -int diff,struct vm_area_struct *vma) -{ -BUILD_BUG (); -} +int folio_sub_return_large_mapcount (struct folio *folio, +int diff,struct vm_area_struct *vma);#endif /* CONFIG_MM_ID */ #define folio_inc_large_mapcount (folio, vma) \
But then, I have patches here in the works that actually fill these functions with life.
So leave the code alone; I'm sure that is something with more added value to be done in the kernel :)
Signature · 3 lines
Cheers David
Quoted 23 lines · Andrew Morton
Quoted 20 lines · On Wed, 31 Dec 2025 10:28:25 +1300 Barry Song <[email protected]> wrote:
Quoted 17 lines · David Hildenbrand (Red Hat)
Quoted 5 lines
mm/rmap.c +2
-1-break ; +#ifdef CONFIG_NO_PAGE_MAPCOUNT + last =atomic_add_negative (-1 , &folio->_entire_mapcount);mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1706
Quoted 10 lines
mm/rmap.c +10
-0+if (level ==PGTABLE_LEVEL_PMD && last) + nr_pmdmapped =folio_large_nr_pages (folio); + nr =folio_dec_return_large_mapcount (folio, vma); +if (!nr) { +/* Now completely unmapped. */ + nr =folio_large_nr_pages (folio); + }else { + partially_mapped = last && + nr <folio_large_nr_pages (folio); + nr =0 ;The whole code was written to avoid ifdefs.
Quoted 7 lines
Quoted 3 lines
The #ifdefs are only for -O0 builds, which are never a mainline requirement. However, dropping functions that contain nothing but a
BUILD_BUG()seems reasonable?Let's not make -O0 an objective, please. We often make assumptions about dead code elimination in order to keep kernel code more pleasing to read and to maintain.
Let me think if there is any other way to achieve it.
Quoted 10 lines
Quoted 4 lines
If those functions were actually required, the compiler would fail anyway. In that case, there doesn’t seem to be much value in keeping wrapper functions whose sole purpose is to contain a single
BUILD_BUG().I agree with that part of the patch - if the thing only does a
BUILD_BUG()then let's simply remove it. If somehow the compiler tries to reference the now-not-present function then we'll get an error message anyway.
Thanks
Wale