Skip to contentSkip to conversation

mm/gup.c:536:29: error: implicit declaration of function 'pud_pfn'; did you mean 'pmd_pfn'?

PATCH kernel test robot 2 participants 2 messages Mar 23, 2024 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
head:   af520f81c51001f7ccdf0579fc73df282b26292d
commit: 529f3b89b7333564792458ca7be06f5bff258d23 [115/141] mm/gup: handle huge pud for follow_pud_mask()
config: sh-defconfig (https://download.01.org/0day-ci/archive/20240323/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240323/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

mm/gup.c: In function 'follow_huge_pud':

>> mm/gup.c:536:29: error: implicit declaration of function 'pud_pfn'; did you mean 'pmd_pfn'? [-Werror=implicit-function-declaration]
     536 |         unsigned long pfn = pud_pfn(pud);
         |                             ^~~~~~~
         |                             pmd_pfn

cc1: some warnings being treated as errors

vim +536 mm/gup.c

527
528 #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
529 static struct page *follow_huge_pud(struct vm_area_struct *vma,
530 unsigned long addr, pud_t *pudp,
531 int flags, struct follow_page_context *ctx)
532 {
533 struct mm_struct *mm = vma->vm_mm;
534 struct page *page;
535 pud_t pud = *pudp;

 > 536		unsigned long pfn = pud_pfn(pud);

537 int ret;
538
539 assert_spin_locked(pud_lockptr(mm, pudp));
540
541 if ((flags & FOLL_WRITE) && !pud_write(pud))
542 return NULL;
543
544 if (!pud_present(pud))
545 return NULL;
546
547 pfn += (addr & ~PUD_MASK) >> PAGE_SHIFT;
548
549 if (IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) &&
550 pud_devmap(pud)) {
551 /*
552 * device mapped pages can only be returned if the caller
553 * will manage the page reference count.
554 *
555 * At least one of FOLL_GET | FOLL_PIN must be set, so
556 * assert that here:
557 */
558 if (!(flags & (FOLL_GET | FOLL_PIN)))
559 return ERR_PTR(-EEXIST);
560
561 if (flags & FOLL_TOUCH)
562 touch_pud(vma, addr, pudp, flags & FOLL_WRITE);
563
564 ctx->pgmap = get_dev_pagemap(pfn, ctx->pgmap);
565 if (!ctx->pgmap)
566 return ERR_PTR(-EFAULT);
567 }
568
569 page = pfn_to_page(pfn);
570
571 if (!pud_devmap(pud) && !pud_write(pud) &&
572 gup_must_unshare(vma, flags, page))
573 return ERR_PTR(-EMLINK);
574
575 ret = try_grab_page(page, flags);
576 if (ret)
577 page = ERR_PTR(ret);
578 else
579 ctx->page_mask = HPAGE_PUD_NR - 1;
580
581 return page;
582 }
583 #else /* CONFIG_PGTABLE_HAS_HUGE_LEAVES */
584 static struct page *follow_huge_pud(struct vm_area_struct *vma,
585 unsigned long addr, pud_t *pudp,
586 int flags, struct follow_page_context *ctx)
587 {
588 return NULL;
589 }
590 #endif /* CONFIG_PGTABLE_HAS_HUGE_LEAVES */
591

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 12 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
head:   af520f81c51001f7ccdf0579fc73df282b26292d
commit: 529f3b89b7333564792458ca7be06f5bff258d23 [115/141] mm/gup: handle huge pud for follow_pud_mask()
config: sh-defconfig (https://download.01.org/0day-ci/archive/20240323/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240323/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 8 lines

All errors (new ones prefixed by >>):

mm/gup.c: In function 'follow_huge_pud':

Quoted 1 line
Quoted 1 line

mm/gup.c:536:29: error: implicit declaration of function 'pud_pfn'; did you mean 'pmd_pfn'? [-Werror=implicit-function-declaration]

     536 |         unsigned long pfn = pud_pfn(pud);
         |                             ^~~~~~~
         |                             pmd_pfn

cc1: some warnings being treated as errors

This is a HUGETLB_PAGE && !THP setup, where on SH there's no huge mappings at all, actually it seems to only use a similar cont ptes concept.. which I didn't notice before.

We should have tackled similar issue with pmd_pfn() in 2022, where 7106c51ee9a1 ("arch: Add pmd_pfn() where it is missing") defined pmd_pfn for all archs.

Instead of doing that (archs using pud_pfn is still not much; defining it all across sounds like an overkill), and instead of providing a fixup patch, I think it'll make more sense I provide a standalone patch to provide pud_pfn() globally with a fallback. Ideally such patch can be put before this problematic commit if we care about per-commit compilations.

I'll post a formal patch soon.

Signature · 1 line
Peter Xu