On Sun, Feb 06, 2022 at 10:05:35PM +0000, Matthew Wilcox wrote: > On Sun, Feb 06, 2022 at 11:33:40PM +0200, Mike Rapoport wrote: > > On Sun, Feb 06, 2022 at 08:46:45PM +0000, Matthew Wilcox wrote: > > > On Sun, Feb 06, 2022 at 08:13:11PM +0200, Mike Rapoport wrote: > > > > On Fri, Feb 04, 2022 at 07:58:18PM +0000, Matthew Wilcox (Oracle) wrote: > > > > > I need to use this function in common code, so define it for hexagon. > > > > > > > > > > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> > > > > > --- > > > > > arch/hexagon/include/asm/pgtable.h | 3 ++- > > > > > > > > Why hexagon out of all architectures? > > > > What about m68k, nios2, nds32 etc? > > > > > Presumably they don't support CONFIG_TRANSPARENT_HUGEPAGE. > > > This code isn't compiled when THP are disabled; at least I haven't > > > had a buildbot complaint for any other architectures. > > > > m68k defconfig fails: > > > > CC mm/page_vma_mapped.o > > mm/page_vma_mapped.c: In function 'page_vma_mapped_walk': > > mm/page_vma_mapped.c:219:20: error: implicit declaration of function 'pmd_pfn'; did you mean 'pmd_off'? [-Werror=implicit-function-declaration] > > 219 | if (!check_pmd(pmd_pfn(pmde), pvmw)) > > | ^~~~~~~ > > | pmd_off > > Ok, so this whole thing is protected by "if (pmd_trans_huge(pmd))" > which is defined to be 0 if !THP. But obviously, gcc is trying to parse > it. So I think we need something like: > > #ifndef CONFIG_TRANSPARENT_HUGEPAGE > static inline unsigned long pmd_pfn(pmd_t pmd) > { > BUG(); > return 0UL; > } > #endif > > but that can have its own problem if architectures define pmd_pfn() > when they don't have CONFIG_TRANSPARENT_HUGEPAGE. Which of course, they > can do. I think the safest would be to define pmd_pfn where it's missing. Then the whole pmd_pfn(), pmd_page() and pmd_page_vaddr() can be cleaned up on top, but this won't block folio work. I've baked a patch that defines pmd_pfn() based on pmd_page_vaddr() or pmd_page() definition. With pmd_pfn() defined we won't need special care for THP or !THP cases and PMD is always there even if it's called PGD sometimes.