Message ID | 166810136860.3462948.16794726061248137027.stgit@warthog.procyon.org.uk (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: Make some folio and page function arguments const and use bool | expand |
On Thu, Nov 10, 2022 at 05:29:28PM +0000, David Howells wrote: > Mark the folio* argument to some of the folio accessor functions as a const > pointer and similarly make some page* arguments to some page functions > const. I think the build bots are going to whinge. #ifdef CONFIG_DEBUG_VM_PGFLAGS #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) #define VM_BUG_ON_PAGE(cond, page) \ do { \ if (unlikely(cond)) { \ dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")"); void dump_page(struct page *page, const char *reason); I've looked at making dump_page() take a const struct page * in the past, but it's a lot of work. Do you really need this or is this a Friday afternoon project?
Hi David, I love your patch! Perhaps something to improve: [auto build test WARNING on akpm-mm/mm-everything] url: https://github.com/intel-lab-lkp/linux/commits/David-Howells/mm-Make-some-folio-and-page-function-arguments-const-and-use-bool/20221111-012958 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/166810136860.3462948.16794726061248137027.stgit%40warthog.procyon.org.uk patch subject: [PATCH] mm: Make some folio and page function arguments const and use bool config: m68k-allyesconfig compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/3fb73cfd420034dbced68189dcfd7fb204a9018d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review David-Howells/mm-Make-some-folio-and-page-function-arguments-const-and-use-bool/20221111-012958 git checkout 3fb73cfd420034dbced68189dcfd7fb204a9018d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from include/linux/percpu.h:5, from include/linux/hrtimer.h:19, from include/linux/sched.h:20, from arch/m68k/kernel/asm-offsets.c:15: include/linux/page-flags.h: In function 'const_folio_flags': >> include/linux/page-flags.h:316:43: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:316:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:317:70: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:317:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ In file included from include/linux/thread_info.h:27, from include/asm-generic/preempt.h:5, from ./arch/m68k/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from arch/m68k/include/asm/irqflags.h:6, from include/linux/irqflags.h:16, from arch/m68k/include/asm/atomic.h:6, from include/linux/atomic.h:7, from include/linux/rcupdate.h:25, from include/linux/rculist.h:11, from include/linux/pid.h:5, from include/linux/sched.h:14: include/linux/page-flags.h: In function 'PageLocked': include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:365:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 365 | VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:257:34: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 257 | #define compound_head(page) ((typeof(page))_compound_head(page)) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:357:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 357 | VM_BUG_ON_PGFLAGS(PagePoisoned(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:17: note: in expansion of macro 'PF_POISONED_CHECK' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:35: note: in expansion of macro 'compound_head' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:51:23: note: in definition of macro 'bitop' -- In file included from include/linux/percpu.h:5, from include/linux/percpu_counter.h:14, from include/linux/mm_types.h:21, from include/linux/buildid.h:5, from include/linux/module.h:14, from arch/m68k/kernel/ints.c:9: include/linux/page-flags.h: In function 'const_folio_flags': >> include/linux/page-flags.h:316:43: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:316:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:317:70: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:317:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ In file included from include/linux/thread_info.h:27, from include/asm-generic/preempt.h:5, from ./arch/m68k/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from arch/m68k/include/asm/irqflags.h:6, from include/linux/irqflags.h:16, from arch/m68k/include/asm/atomic.h:6, from include/linux/atomic.h:7, from include/linux/mm_types_task.h:13, from include/linux/mm_types.h:5: include/linux/page-flags.h: In function 'PageLocked': include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:365:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 365 | VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:257:34: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 257 | #define compound_head(page) ((typeof(page))_compound_head(page)) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:357:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 357 | VM_BUG_ON_PGFLAGS(PagePoisoned(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:17: note: in expansion of macro 'PF_POISONED_CHECK' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:35: note: in expansion of macro 'compound_head' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:51:23: note: in definition of macro 'bitop' 51 | (uintptr_t)(addr) != (uintptr_t)NULL && \ | ^~~~ -- In file included from include/linux/percpu.h:5, from include/linux/hrtimer.h:19, from include/linux/sched.h:20, from arch/m68k/kernel/vectors.c:20: include/linux/page-flags.h: In function 'const_folio_flags': >> include/linux/page-flags.h:316:43: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:316:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 316 | VM_BUG_ON_PGFLAGS(PageTail(page), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:317:70: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~ include/linux/mmdebug.h:21:35: note: in definition of macro 'VM_BUG_ON_PAGE' 21 | dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ | ^~~~ include/linux/page-flags.h:317:9: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 317 | VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); | ^~~~~~~~~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ In file included from include/linux/thread_info.h:27, from include/asm-generic/preempt.h:5, from ./arch/m68k/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from arch/m68k/include/asm/irqflags.h:6, from include/linux/irqflags.h:16, from arch/m68k/include/asm/atomic.h:6, from include/linux/atomic.h:7, from include/linux/rcupdate.h:25, from include/linux/rculist.h:11, from include/linux/pid.h:5, from include/linux/sched.h:14: include/linux/page-flags.h: In function 'PageLocked': include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:365:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 365 | VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:257:34: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 257 | #define compound_head(page) ((typeof(page))_compound_head(page)) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/bitops.h:50:44: note: in definition of macro 'bitop' 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ | ^~~~ include/linux/page-flags.h:389:10: note: in expansion of macro 'test_bit' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~~~ include/linux/mmdebug.h:110:39: note: in expansion of macro 'VM_BUG_ON_PAGE' 110 | #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:357:17: note: in expansion of macro 'VM_BUG_ON_PGFLAGS' 357 | VM_BUG_ON_PGFLAGS(PagePoisoned(page), page); \ | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:17: note: in expansion of macro 'PF_POISONED_CHECK' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:35: note: in expansion of macro 'compound_head' 366 | PF_POISONED_CHECK(compound_head(page)); }) | ^~~~~~~~~~~~~ include/linux/page-flags.h:389:32: note: in expansion of macro 'PF_NO_TAIL' 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~~~ include/linux/page-flags.h:439:9: note: in expansion of macro 'TESTPAGEFLAG' 439 | TESTPAGEFLAG(uname, lname, policy) \ | ^~~~~~~~~~~~ include/linux/page-flags.h:479:1: note: in expansion of macro '__PAGEFLAG' 479 | __PAGEFLAG(Locked, locked, PF_NO_TAIL) | ^~~~~~~~~~ include/linux/mmdebug.h:12:29: note: expected 'struct page *' but argument is of type 'const struct page *' 12 | void dump_page(struct page *page, const char *reason); | ~~~~~~~~~~~~~^~~~ include/linux/page-flags.h:389:39: warning: passing argument 1 of 'dump_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 389 | { return test_bit(PG_##lname, &policy(page, 0)->flags); } | ^~~~ include/linux/bitops.h:51:23: note: in definition of macro 'bitop' .. vim +316 include/linux/page-flags.h 311 312 static const unsigned long *const_folio_flags(const struct folio *folio, unsigned n) 313 { 314 const struct page *page = &folio->page; 315 > 316 VM_BUG_ON_PGFLAGS(PageTail(page), page); 317 VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); 318 return &page[n].flags; 319 } 320
Hi David, I love your patch! Yet something to improve: [auto build test ERROR on akpm-mm/mm-everything] url: https://github.com/intel-lab-lkp/linux/commits/David-Howells/mm-Make-some-folio-and-page-function-arguments-const-and-use-bool/20221111-012958 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/166810136860.3462948.16794726061248137027.stgit%40warthog.procyon.org.uk patch subject: [PATCH] mm: Make some folio and page function arguments const and use bool config: x86_64-randconfig-a016 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/3fb73cfd420034dbced68189dcfd7fb204a9018d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review David-Howells/mm-Make-some-folio-and-page-function-arguments-const-and-use-bool/20221111-012958 git checkout 3fb73cfd420034dbced68189dcfd7fb204a9018d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 prepare If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:316:36: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] VM_BUG_ON_PGFLAGS(PageTail(page), page); ^~~~ include/linux/mmdebug.h:110:60: note: expanded from macro 'VM_BUG_ON_PGFLAGS' #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) ^~~~ include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:317:63: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); ^~~~ include/linux/mmdebug.h:110:60: note: expanded from macro 'VM_BUG_ON_PGFLAGS' #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) ^~~~ include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:479:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:439:2: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:365:48: note: expanded from macro 'PF_NO_TAIL' VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:50:37: note: expanded from macro 'bitop' __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:479:28: error: passing 'typeof (page)' (aka 'const struct page *') to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ include/linux/page-flags.h:439:29: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/page-flags.h:389:32: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:21: note: expanded from macro 'PF_NO_TAIL' PF_POISONED_CHECK(compound_head(page)); }) ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ~~~~~~~~~~~~~~~~~~~~~^~~~~ include/linux/bitops.h:50:37: note: expanded from macro 'bitop' __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:479:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:439:2: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:365:48: note: expanded from macro 'PF_NO_TAIL' VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:51:16: note: expanded from macro 'bitop' (uintptr_t)(addr) != (uintptr_t)NULL && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:479:28: error: passing 'typeof (page)' (aka 'const struct page *') to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ include/linux/page-flags.h:439:29: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/page-flags.h:389:32: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:21: note: expanded from macro 'PF_NO_TAIL' PF_POISONED_CHECK(compound_head(page)); }) ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ~~~~~~~~~~~~~~~~~~~~~^~~~~ include/linux/bitops.h:51:16: note: expanded from macro 'bitop' (uintptr_t)(addr) != (uintptr_t)NULL && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:479:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:439:2: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:365:48: note: expanded from macro 'PF_NO_TAIL' VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:52:50: note: expanded from macro 'bitop' __builtin_constant_p(*(const unsigned long *)(addr))) ? \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:479:28: error: passing 'typeof (page)' (aka 'const struct page *') to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ include/linux/page-flags.h:439:29: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/page-flags.h:389:32: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:21: note: expanded from macro 'PF_NO_TAIL' PF_POISONED_CHECK(compound_head(page)); }) ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ~~~~~~~~~~~~~~~~~~~~~^~~~~ include/linux/bitops.h:52:50: note: expanded from macro 'bitop' __builtin_constant_p(*(const unsigned long *)(addr))) ? \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:479:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:439:2: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:365:48: note: expanded from macro 'PF_NO_TAIL' VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:53:17: note: expanded from macro 'bitop' const##op(nr, addr) : op(nr, addr)) ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:479:28: error: passing 'typeof (page)' (aka 'const struct page *') to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ include/linux/page-flags.h:439:29: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/page-flags.h:389:32: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:21: note: expanded from macro 'PF_NO_TAIL' PF_POISONED_CHECK(compound_head(page)); }) ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ~~~~~~~~~~~~~~~~~~~~~^~~~~ include/linux/bitops.h:53:17: note: expanded from macro 'bitop' const##op(nr, addr) : op(nr, addr)) ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:479:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:439:2: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:365:48: note: expanded from macro 'PF_NO_TAIL' VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:53:32: note: expanded from macro 'bitop' const##op(nr, addr) : op(nr, addr)) ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: >> include/linux/page-flags.h:479:28: error: passing 'typeof (page)' (aka 'const struct page *') to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] __PAGEFLAG(Locked, locked, PF_NO_TAIL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ include/linux/page-flags.h:439:29: note: expanded from macro '__PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/page-flags.h:389:32: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:366:21: note: expanded from macro 'PF_NO_TAIL' PF_POISONED_CHECK(compound_head(page)); }) ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ~~~~~~~~~~~~~~~~~~~~~^~~~~ include/linux/bitops.h:53:32: note: expanded from macro 'bitop' const##op(nr, addr) : op(nr, addr)) ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:480:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:434:2: note: expanded from macro 'PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:362:37: note: expanded from macro 'PF_ONLY_HEAD' VM_BUG_ON_PGFLAGS(PageTail(page), page); \ ^~~~ note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:50:37: note: expanded from macro 'bitop' __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:480:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:434:2: note: expanded from macro 'PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:363:21: note: expanded from macro 'PF_ONLY_HEAD' PF_POISONED_CHECK(page); }) ^~~~ note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/mmdebug.h:21:14: note: expanded from macro 'VM_BUG_ON_PAGE' dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ ^~~~ include/linux/bitops.h:61:50: note: expanded from macro 'test_bit' #define test_bit(nr, addr) bitop(_test_bit, nr, addr) ^~~~ include/linux/bitops.h:50:37: note: expanded from macro 'bitop' __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ ^~~~ include/linux/mmdebug.h:12:29: note: passing argument to parameter 'page' here void dump_page(struct page *page, const char *reason); ^ In file included from arch/x86/kernel/asm-offsets.c:9: In file included from include/linux/crypto.h:20: In file included from include/linux/slab.h:15: In file included from include/linux/gfp.h:7: In file included from include/linux/mmzone.h:22: include/linux/page-flags.h:480:1: error: passing 'const struct page *' to parameter of type 'struct page *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:434:2: note: expanded from macro 'PAGEFLAG' TESTPAGEFLAG(uname, lname, policy) \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/page-flags.h:389:39: note: expanded from macro 'TESTPAGEFLAG' { return test_bit(PG_##lname, &policy(page, 0)->flags); } ^~~~ include/linux/page-flags.h:362:37: note: expanded from macro 'PF_ONLY_HEAD' VM_BUG_ON_PGFLAGS(PageTail(page), page); \ vim +316 include/linux/page-flags.h 311 312 static const unsigned long *const_folio_flags(const struct folio *folio, unsigned n) 313 { 314 const struct page *page = &folio->page; 315 > 316 VM_BUG_ON_PGFLAGS(PageTail(page), page); 317 VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); 318 return &page[n].flags; 319 } 320 321 static unsigned long *folio_flags(struct folio *folio, unsigned n) 322 { 323 struct page *page = &folio->page; 324 325 VM_BUG_ON_PGFLAGS(PageTail(page), page); 326 VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); 327 return &page[n].flags; 328 } 329 330 /* 331 * Page flags policies wrt compound pages 332 * 333 * PF_POISONED_CHECK 334 * check if this struct page poisoned/uninitialized 335 * 336 * PF_ANY: 337 * the page flag is relevant for small, head and tail pages. 338 * 339 * PF_HEAD: 340 * for compound page all operations related to the page flag applied to 341 * head page. 342 * 343 * PF_ONLY_HEAD: 344 * for compound page, callers only ever operate on the head page. 345 * 346 * PF_NO_TAIL: 347 * modifications of the page flag must be done on small or head pages, 348 * checks can be done on tail pages too. 349 * 350 * PF_NO_COMPOUND: 351 * the page flag is not relevant for compound pages. 352 * 353 * PF_SECOND: 354 * the page flag is stored in the first tail page. 355 */ 356 #define PF_POISONED_CHECK(page) ({ \ 357 VM_BUG_ON_PGFLAGS(PagePoisoned(page), page); \ 358 page; }) 359 #define PF_ANY(page, enforce) PF_POISONED_CHECK(page) 360 #define PF_HEAD(page, enforce) PF_POISONED_CHECK(compound_head(page)) 361 #define PF_ONLY_HEAD(page, enforce) ({ \ 362 VM_BUG_ON_PGFLAGS(PageTail(page), page); \ 363 PF_POISONED_CHECK(page); }) 364 #define PF_NO_TAIL(page, enforce) ({ \ 365 VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ 366 PF_POISONED_CHECK(compound_head(page)); }) 367 #define PF_NO_COMPOUND(page, enforce) ({ \ 368 VM_BUG_ON_PGFLAGS(enforce && PageCompound(page), page); \ 369 PF_POISONED_CHECK(page); }) 370 #define PF_SECOND(page, enforce) ({ \ 371 VM_BUG_ON_PGFLAGS(!PageHead(page), page); \ 372 PF_POISONED_CHECK(&page[1]); }) 373 374 /* Which page is the flag stored in */ 375 #define FOLIO_PF_ANY 0 376 #define FOLIO_PF_HEAD 0 377 #define FOLIO_PF_ONLY_HEAD 0 378 #define FOLIO_PF_NO_TAIL 0 379 #define FOLIO_PF_NO_COMPOUND 0 380 #define FOLIO_PF_SECOND 1 381 382 /* 383 * Macros to create function definitions for page flags 384 */ 385 #define TESTPAGEFLAG(uname, lname, policy) \ 386 static __always_inline bool folio_test_##lname(const struct folio *folio) \ 387 { return test_bit(PG_##lname, const_folio_flags(folio, FOLIO_##policy)); } \ 388 static __always_inline bool Page##uname(const struct page *page) \ 389 { return test_bit(PG_##lname, &policy(page, 0)->flags); } 390 391 #define SETPAGEFLAG(uname, lname, policy) \ 392 static __always_inline \ 393 void folio_set_##lname(struct folio *folio) \ 394 { set_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 395 static __always_inline void SetPage##uname(struct page *page) \ 396 { set_bit(PG_##lname, &policy(page, 1)->flags); } 397 398 #define CLEARPAGEFLAG(uname, lname, policy) \ 399 static __always_inline \ 400 void folio_clear_##lname(struct folio *folio) \ 401 { clear_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 402 static __always_inline void ClearPage##uname(struct page *page) \ 403 { clear_bit(PG_##lname, &policy(page, 1)->flags); } 404 405 #define __SETPAGEFLAG(uname, lname, policy) \ 406 static __always_inline \ 407 void __folio_set_##lname(struct folio *folio) \ 408 { __set_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 409 static __always_inline void __SetPage##uname(struct page *page) \ 410 { __set_bit(PG_##lname, &policy(page, 1)->flags); } 411 412 #define __CLEARPAGEFLAG(uname, lname, policy) \ 413 static __always_inline \ 414 void __folio_clear_##lname(struct folio *folio) \ 415 { __clear_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 416 static __always_inline void __ClearPage##uname(struct page *page) \ 417 { __clear_bit(PG_##lname, &policy(page, 1)->flags); } 418 419 #define TESTSETFLAG(uname, lname, policy) \ 420 static __always_inline \ 421 bool folio_test_set_##lname(struct folio *folio) \ 422 { return test_and_set_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 423 static __always_inline bool TestSetPage##uname(struct page *page) \ 424 { return test_and_set_bit(PG_##lname, &policy(page, 1)->flags); } 425 426 #define TESTCLEARFLAG(uname, lname, policy) \ 427 static __always_inline \ 428 bool folio_test_clear_##lname(struct folio *folio) \ 429 { return test_and_clear_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ 430 static __always_inline bool TestClearPage##uname(struct page *page) \ 431 { return test_and_clear_bit(PG_##lname, &policy(page, 1)->flags); } 432 433 #define PAGEFLAG(uname, lname, policy) \ 434 TESTPAGEFLAG(uname, lname, policy) \ 435 SETPAGEFLAG(uname, lname, policy) \ 436 CLEARPAGEFLAG(uname, lname, policy) 437 438 #define __PAGEFLAG(uname, lname, policy) \ 439 TESTPAGEFLAG(uname, lname, policy) \ 440 __SETPAGEFLAG(uname, lname, policy) \ 441 __CLEARPAGEFLAG(uname, lname, policy) 442 443 #define TESTSCFLAG(uname, lname, policy) \ 444 TESTSETFLAG(uname, lname, policy) \ 445 TESTCLEARFLAG(uname, lname, policy) 446 447 #define TESTPAGEFLAG_FALSE(uname, lname) \ 448 static inline bool folio_test_##lname(const struct folio *folio) { return false; } \ 449 static inline bool Page##uname(const struct page *page) { return false; } 450 451 #define SETPAGEFLAG_NOOP(uname, lname) \ 452 static inline void folio_set_##lname(struct folio *folio) { } \ 453 static inline void SetPage##uname(struct page *page) { } 454 455 #define CLEARPAGEFLAG_NOOP(uname, lname) \ 456 static inline void folio_clear_##lname(struct folio *folio) { } \ 457 static inline void ClearPage##uname(struct page *page) { } 458 459 #define __CLEARPAGEFLAG_NOOP(uname, lname) \ 460 static inline void __folio_clear_##lname(struct folio *folio) { } \ 461 static inline void __ClearPage##uname(struct page *page) { } 462 463 #define TESTSETFLAG_FALSE(uname, lname) \ 464 static inline bool folio_test_set_##lname(struct folio *folio) \ 465 { return false; } \ 466 static inline bool TestSetPage##uname(struct page *page) { return false; } 467 468 #define TESTCLEARFLAG_FALSE(uname, lname) \ 469 static inline bool folio_test_clear_##lname(struct folio *folio) \ 470 { return false; } \ 471 static inline bool TestClearPage##uname(struct page *page) { return false; } 472 473 #define PAGEFLAG_FALSE(uname, lname) TESTPAGEFLAG_FALSE(uname, lname) \ 474 SETPAGEFLAG_NOOP(uname, lname) CLEARPAGEFLAG_NOOP(uname, lname) 475 476 #define TESTSCFLAG_FALSE(uname, lname) \ 477 TESTSETFLAG_FALSE(uname, lname) TESTCLEARFLAG_FALSE(uname, lname) 478 > 479 __PAGEFLAG(Locked, locked, PF_NO_TAIL) 480 PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) 481 PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) 482 PAGEFLAG(Referenced, referenced, PF_HEAD) 483 TESTCLEARFLAG(Referenced, referenced, PF_HEAD) 484 __SETPAGEFLAG(Referenced, referenced, PF_HEAD) 485 PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD) 486 __CLEARPAGEFLAG(Dirty, dirty, PF_HEAD) 487 PAGEFLAG(LRU, lru, PF_HEAD) __CLEARPAGEFLAG(LRU, lru, PF_HEAD) 488 TESTCLEARFLAG(LRU, lru, PF_HEAD) 489 PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD) 490 TESTCLEARFLAG(Active, active, PF_HEAD) 491 PAGEFLAG(Workingset, workingset, PF_HEAD) 492 TESTCLEARFLAG(Workingset, workingset, PF_HEAD) 493 __PAGEFLAG(Slab, slab, PF_NO_TAIL) 494 __PAGEFLAG(SlobFree, slob_free, PF_NO_TAIL) 495 PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems */ 496
diff --git a/include/linux/mm.h b/include/linux/mm.h index 7a7a287818ad..a069f6f70aed 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -711,7 +711,7 @@ int vma_is_stack_for_current(struct vm_area_struct *vma); struct mmu_gather; struct inode; -static inline unsigned int compound_order(struct page *page) +static inline unsigned int compound_order(const struct page *page) { if (!PageHead(page)) return 0; @@ -727,7 +727,7 @@ static inline unsigned int compound_order(struct page *page) * * Return: The order of the folio. */ -static inline unsigned int folio_order(struct folio *folio) +static inline unsigned int folio_order(const struct folio *folio) { if (!folio_test_large(folio)) return 0; @@ -945,7 +945,7 @@ static inline void set_compound_order(struct page *page, unsigned int order) } /* Returns the number of pages in this potentially compound page. */ -static inline unsigned long compound_nr(struct page *page) +static inline unsigned long compound_nr(const struct page *page) { if (!PageHead(page)) return 1; @@ -1519,7 +1519,7 @@ static inline unsigned long page_to_section(const struct page *page) * * Return: The Page Frame Number of the first page in the folio. */ -static inline unsigned long folio_pfn(struct folio *folio) +static inline unsigned long folio_pfn(const struct folio *folio) { return page_to_pfn(&folio->page); } @@ -1600,7 +1600,7 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma, /* MIGRATE_CMA and ZONE_MOVABLE do not allow pin pages */ #ifdef CONFIG_MIGRATION -static inline bool is_longterm_pinnable_page(struct page *page) +static inline bool is_longterm_pinnable_page(const struct page *page) { #ifdef CONFIG_CMA int mt = get_pageblock_migratetype(page); @@ -1620,13 +1620,13 @@ static inline bool is_longterm_pinnable_page(struct page *page) return !is_zone_movable_page(page); } #else -static inline bool is_longterm_pinnable_page(struct page *page) +static inline bool is_longterm_pinnable_page(const struct page *page) { return true; } #endif -static inline bool folio_is_longterm_pinnable(struct folio *folio) +static inline bool folio_is_longterm_pinnable(const struct folio *folio) { return is_longterm_pinnable_page(&folio->page); } @@ -1659,7 +1659,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, * * Return: A positive power of two. */ -static inline long folio_nr_pages(struct folio *folio) +static inline long folio_nr_pages(const struct folio *folio) { if (!folio_test_large(folio)) return 1; @@ -1701,7 +1701,7 @@ static inline struct folio *folio_next(struct folio *folio) * it from being split. It is not necessary for the folio to be locked. * Return: The base-2 logarithm of the size of this folio. */ -static inline unsigned int folio_shift(struct folio *folio) +static inline unsigned int folio_shift(const struct folio *folio) { return PAGE_SHIFT + folio_order(folio); } @@ -1714,7 +1714,7 @@ static inline unsigned int folio_shift(struct folio *folio) * it from being split. It is not necessary for the folio to be locked. * Return: The number of bytes in this folio. */ -static inline size_t folio_size(struct folio *folio) +static inline size_t folio_size(const struct folio *folio) { return PAGE_SIZE << folio_order(folio); } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0b0ae5084e60..ee6604fcc1d1 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -243,7 +243,7 @@ static inline const struct page *page_fixed_fake_head(const struct page *page) } #endif -static __always_inline int page_is_fake_head(struct page *page) +static __always_inline bool page_is_fake_head(const struct page *page) { return page_fixed_fake_head(page) != page; } @@ -287,19 +287,19 @@ static inline unsigned long _compound_head(const struct page *page) */ #define folio_page(folio, n) nth_page(&(folio)->page, n) -static __always_inline int PageTail(struct page *page) +static __always_inline bool PageTail(const struct page *page) { return READ_ONCE(page->compound_head) & 1 || page_is_fake_head(page); } -static __always_inline int PageCompound(struct page *page) +static __always_inline bool PageCompound(const struct page *page) { return test_bit(PG_head, &page->flags) || READ_ONCE(page->compound_head) & 1; } #define PAGE_POISON_PATTERN -1l -static inline int PagePoisoned(const struct page *page) +static inline bool PagePoisoned(const struct page *page) { return READ_ONCE(page->flags) == PAGE_POISON_PATTERN; } @@ -312,6 +312,15 @@ static inline void page_init_poison(struct page *page, size_t size) } #endif +static const unsigned long *const_folio_flags(const struct folio *folio, unsigned n) +{ + const struct page *page = &folio->page; + + VM_BUG_ON_PGFLAGS(PageTail(page), page); + VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); + return &page[n].flags; +} + static unsigned long *folio_flags(struct folio *folio, unsigned n) { struct page *page = &folio->page; @@ -377,9 +386,9 @@ static unsigned long *folio_flags(struct folio *folio, unsigned n) * Macros to create function definitions for page flags */ #define TESTPAGEFLAG(uname, lname, policy) \ -static __always_inline bool folio_test_##lname(struct folio *folio) \ -{ return test_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ -static __always_inline int Page##uname(struct page *page) \ +static __always_inline bool folio_test_##lname(const struct folio *folio) \ +{ return test_bit(PG_##lname, const_folio_flags(folio, FOLIO_##policy)); } \ +static __always_inline bool Page##uname(const struct page *page) \ { return test_bit(PG_##lname, &policy(page, 0)->flags); } #define SETPAGEFLAG(uname, lname, policy) \ @@ -414,14 +423,14 @@ static __always_inline void __ClearPage##uname(struct page *page) \ static __always_inline \ bool folio_test_set_##lname(struct folio *folio) \ { return test_and_set_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ -static __always_inline int TestSetPage##uname(struct page *page) \ +static __always_inline bool TestSetPage##uname(struct page *page) \ { return test_and_set_bit(PG_##lname, &policy(page, 1)->flags); } #define TESTCLEARFLAG(uname, lname, policy) \ static __always_inline \ bool folio_test_clear_##lname(struct folio *folio) \ { return test_and_clear_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \ -static __always_inline int TestClearPage##uname(struct page *page) \ +static __always_inline bool TestClearPage##uname(struct page *page) \ { return test_and_clear_bit(PG_##lname, &policy(page, 1)->flags); } #define PAGEFLAG(uname, lname, policy) \ @@ -440,7 +449,7 @@ static __always_inline int TestClearPage##uname(struct page *page) \ #define TESTPAGEFLAG_FALSE(uname, lname) \ static inline bool folio_test_##lname(const struct folio *folio) { return false; } \ -static inline int Page##uname(const struct page *page) { return 0; } +static inline bool Page##uname(const struct page *page) { return false; } #define SETPAGEFLAG_NOOP(uname, lname) \ static inline void folio_set_##lname(struct folio *folio) { } \ @@ -456,13 +465,13 @@ static inline void __ClearPage##uname(struct page *page) { } #define TESTSETFLAG_FALSE(uname, lname) \ static inline bool folio_test_set_##lname(struct folio *folio) \ -{ return 0; } \ -static inline int TestSetPage##uname(struct page *page) { return 0; } +{ return false; } \ +static inline bool TestSetPage##uname(struct page *page) { return false; } #define TESTCLEARFLAG_FALSE(uname, lname) \ static inline bool folio_test_clear_##lname(struct folio *folio) \ -{ return 0; } \ -static inline int TestClearPage##uname(struct page *page) { return 0; } +{ return false; } \ +static inline bool TestClearPage##uname(struct page *page) { return false; } #define PAGEFLAG_FALSE(uname, lname) TESTPAGEFLAG_FALSE(uname, lname) \ SETPAGEFLAG_NOOP(uname, lname) CLEARPAGEFLAG_NOOP(uname, lname) @@ -538,13 +547,13 @@ PAGEFLAG_FALSE(HighMem, highmem) #endif #ifdef CONFIG_SWAP -static __always_inline bool folio_test_swapcache(struct folio *folio) +static __always_inline bool folio_test_swapcache(const struct folio *folio) { return folio_test_swapbacked(folio) && - test_bit(PG_swapcache, folio_flags(folio, 0)); + test_bit(PG_swapcache, const_folio_flags(folio, 0)); } -static __always_inline bool PageSwapCache(struct page *page) +static __always_inline bool PageSwapCache(const struct page *page) { return folio_test_swapcache(page_folio(page)); } @@ -643,22 +652,22 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) */ #define PAGE_MAPPING_DAX_COW 0x1 -static __always_inline bool folio_mapping_flags(struct folio *folio) +static __always_inline bool folio_mapping_flags(const struct folio *folio) { return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) != 0; } -static __always_inline int PageMappingFlags(struct page *page) +static __always_inline bool PageMappingFlags(const struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) != 0; } -static __always_inline bool folio_test_anon(struct folio *folio) +static __always_inline bool folio_test_anon(const struct folio *folio) { return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0; } -static __always_inline bool PageAnon(struct page *page) +static __always_inline bool PageAnon(const struct page *page) { return folio_test_anon(page_folio(page)); } @@ -669,7 +678,7 @@ static __always_inline bool __folio_test_movable(const struct folio *folio) PAGE_MAPPING_MOVABLE; } -static __always_inline int __PageMovable(struct page *page) +static __always_inline bool __PageMovable(const struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) == PAGE_MAPPING_MOVABLE; @@ -682,13 +691,13 @@ static __always_inline int __PageMovable(struct page *page) * is found in VM_MERGEABLE vmas. It's a PageAnon page, pointing not to any * anon_vma, but to that page's node of the stable tree. */ -static __always_inline bool folio_test_ksm(struct folio *folio) +static __always_inline bool folio_test_ksm(const struct folio *folio) { return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) == PAGE_MAPPING_KSM; } -static __always_inline bool PageKsm(struct page *page) +static __always_inline bool PageKsm(const struct page *page) { return folio_test_ksm(page_folio(page)); } @@ -708,9 +717,9 @@ u64 stable_page_flags(struct page *page); * some of the bytes in it may be; see the is_partially_uptodate() * address_space operation. */ -static inline bool folio_test_uptodate(struct folio *folio) +static inline bool folio_test_uptodate(const struct folio *folio) { - bool ret = test_bit(PG_uptodate, folio_flags(folio, 0)); + bool ret = test_bit(PG_uptodate, const_folio_flags(folio, 0)); /* * Must ensure that the data we read out of the folio is loaded * _after_ we've loaded folio->flags to check the uptodate bit. @@ -725,7 +734,7 @@ static inline bool folio_test_uptodate(struct folio *folio) return ret; } -static inline int PageUptodate(struct page *page) +static inline bool PageUptodate(const struct page *page) { return folio_test_uptodate(page_folio(page)); } @@ -777,12 +786,12 @@ static inline bool test_set_page_writeback(struct page *page) return set_page_writeback(page); } -static __always_inline bool folio_test_head(struct folio *folio) +static __always_inline bool folio_test_head(const struct folio *folio) { - return test_bit(PG_head, folio_flags(folio, FOLIO_PF_ANY)); + return test_bit(PG_head, const_folio_flags(folio, FOLIO_PF_ANY)); } -static __always_inline int PageHead(struct page *page) +static __always_inline bool PageHead(const struct page *page) { PF_POISONED_CHECK(page); return test_bit(PG_head, &page->flags) && !page_is_fake_head(page); @@ -798,7 +807,7 @@ CLEARPAGEFLAG(Head, head, PF_ANY) * * Return: True if the folio is larger than one page. */ -static inline bool folio_test_large(struct folio *folio) +static inline bool folio_test_large(const struct folio *folio) { return folio_test_head(folio); } @@ -824,9 +833,9 @@ static inline void ClearPageCompound(struct page *page) #define PG_head_mask ((1UL << PG_head)) #ifdef CONFIG_HUGETLB_PAGE -int PageHuge(struct page *page); -int PageHeadHuge(struct page *page); -static inline bool folio_test_hugetlb(struct folio *folio) +bool PageHuge(const struct page *page); +bool PageHeadHuge(const struct page *page); +static inline bool folio_test_hugetlb(const struct folio *folio) { return PageHeadHuge(&folio->page); } @@ -844,13 +853,13 @@ TESTPAGEFLAG_FALSE(HeadHuge, headhuge) * hugetlbfs pages, but not normal pages. PageTransHuge() can only be * called only in the core VM paths where hugetlbfs pages can't exist. */ -static inline int PageTransHuge(struct page *page) +static inline bool PageTransHuge(const struct page *page) { VM_BUG_ON_PAGE(PageTail(page), page); return PageHead(page); } -static inline bool folio_test_transhuge(struct folio *folio) +static inline bool folio_test_transhuge(const struct folio *folio) { return folio_test_head(folio); } @@ -860,7 +869,7 @@ static inline bool folio_test_transhuge(struct folio *folio) * and hugetlbfs pages, so it should only be called when it's known * that hugetlbfs pages aren't involved. */ -static inline int PageTransCompound(struct page *page) +static inline bool PageTransCompound(const struct page *page) { return PageCompound(page); } @@ -870,7 +879,7 @@ static inline int PageTransCompound(struct page *page) * and hugetlbfs pages, so it should only be called when it's known * that hugetlbfs pages aren't involved. */ -static inline int PageTransTail(struct page *page) +static inline bool PageTransTail(const struct page *page) { return PageTail(page); } @@ -918,7 +927,7 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) * best effort only and inherently racy: there is no way to synchronize with * failing hardware. */ -static inline bool is_page_hwpoison(struct page *page) +static inline bool is_page_hwpoison(const struct page *page) { if (PageHWPoison(page)) return true; @@ -945,13 +954,13 @@ static inline bool is_page_hwpoison(struct page *page) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) -static inline int page_has_type(struct page *page) +static inline bool page_has_type(const struct page *page) { return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; } #define PAGE_TYPE_OPS(uname, lname) \ -static __always_inline int Page##uname(struct page *page) \ +static __always_inline bool Page##uname(const struct page *page) \ { \ return PageType(page, PG_##lname); \ } \ @@ -1011,11 +1020,11 @@ PAGE_TYPE_OPS(Table, table) */ PAGE_TYPE_OPS(Guard, guard) -extern bool is_free_buddy_page(struct page *page); +extern bool is_free_buddy_page(const struct page *page); PAGEFLAG(Isolated, isolated, PF_ANY); -static __always_inline int PageAnonExclusive(struct page *page) +static __always_inline bool PageAnonExclusive(const struct page *page) { VM_BUG_ON_PGFLAGS(!PageAnon(page), page); VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page); @@ -1080,12 +1089,12 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page) * Determine if a page has private stuff, indicating that release routines * should be invoked upon it. */ -static inline int page_has_private(struct page *page) +static inline bool page_has_private(const struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } -static inline bool folio_has_private(struct folio *folio) +static inline bool folio_has_private(const struct folio *folio) { return page_has_private(&folio->page); } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 546df97c31e4..ac8bed42f276 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1886,10 +1886,10 @@ static bool prep_compound_gigantic_page_for_demote(struct page *page, * transparent huge pages. See the PageTransHuge() documentation for more * details. */ -int PageHuge(struct page *page) +bool PageHuge(const struct page *page) { if (!PageCompound(page)) - return 0; + return false; page = compound_head(page); return page[1].compound_dtor == HUGETLB_PAGE_DTOR; @@ -1900,10 +1900,10 @@ EXPORT_SYMBOL_GPL(PageHuge); * PageHeadHuge() only returns true for hugetlbfs head page, but not for * normal or transparent huge pages. */ -int PageHeadHuge(struct page *page_head) +bool PageHeadHuge(const struct page *page_head) { if (!PageHead(page_head)) - return 0; + return false; return page_head[1].compound_dtor == HUGETLB_PAGE_DTOR; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 218b28ee49ed..81ccca8364bb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -9586,13 +9586,13 @@ void __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) /* * This function returns a stable result only if called under zone lock. */ -bool is_free_buddy_page(struct page *page) +bool is_free_buddy_page(const struct page *page) { unsigned long pfn = page_to_pfn(page); unsigned int order; for (order = 0; order < MAX_ORDER; order++) { - struct page *page_head = page - (pfn & ((1 << order) - 1)); + const struct page *page_head = page - (pfn & ((1 << order) - 1)); if (PageBuddy(page_head) && buddy_order_unsafe(page_head) >= order)
Mark the folio* argument to some of the folio accessor functions as a const pointer and similarly make some page* arguments to some page functions const. Also switch the return values to bool rather than int where the test inside produces a bool. Signed-off-by: David Howells <dhowells@redhat.com> --- include/linux/mm.h | 20 ++++----- include/linux/page-flags.h | 99 ++++++++++++++++++++++++-------------------- mm/hugetlb.c | 8 ++-- mm/page_alloc.c | 4 +- 4 files changed, 70 insertions(+), 61 deletions(-)