Re: [PATCH v1] hugetlb: support FOLL_FORCE|FOLL_WRITE

kernel test robot
2024-12-05T01:24:08Z

Hi Guillaume,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.13-rc1 next-20241204]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Guillaume-Morin/hugetlb-support-FOLL_FORCE-FOLL_WRITE/20241205-022843
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/Z1Ce6j5WiBE3kaGf%40bender.morinfr.org
patch subject: [PATCH v1] hugetlb: support FOLL_FORCE|FOLL_WRITE
config: x86_64-buildonly-randconfig-002-20241205 (https://download.01.org/0day-ci/archive/20241205/202412050954.m9cwNOJC-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241205/202412050954.m9cwNOJC-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412050954.m9cwNOJC-lkp@intel.com/

All warnings (new ones prefixed by >>):

In file included from mm/gup.c:7:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from mm/gup.c:20:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
>> mm/gup.c:681:33: warning: variable 'page' is uninitialized when used here [-Wuninitialized]
681 | !can_follow_write_pud(pud, page, vma, flags))
| ^~~~
mm/gup.c:673:19: note: initialize the variable 'page' to silence this warning
673 | struct page *page;
| ^
| = NULL
7 warnings generated.

vim +/page +681 mm/gup.c

667
668 static struct page *follow_huge_pud(struct vm_area_struct *vma,
669 unsigned long addr, pud_t *pudp,
670 int flags, struct follow_page_context *ctx)
671 {
672 struct mm_struct *mm = vma->vm_mm;
673 struct page *page;
674 pud_t pud = *pudp;
675 unsigned long pfn = pud_pfn(pud);
676 int ret;
677
678 assert_spin_locked(pud_lockptr(mm, pudp));
679
680 if ((flags & FOLL_WRITE) &&
> 681 !can_follow_write_pud(pud, page, vma, flags))
682 return NULL;
683
684 if (!pud_present(pud))
685 return NULL;
686
687 pfn += (addr & ~PUD_MASK) >> PAGE_SHIFT;
688
689 if (IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) &&
690 pud_devmap(pud)) {
691 /*
692 * device mapped pages can only be returned if the caller
693 * will manage the page reference count.
694 *
695 * At least one of FOLL_GET | FOLL_PIN must be set, so
696 * assert that here:
697 */
698 if (!(flags & (FOLL_GET | FOLL_PIN)))
699 return ERR_PTR(-EEXIST);
700
701 if (flags & FOLL_TOUCH)
702 touch_pud(vma, addr, pudp, flags & FOLL_WRITE);
703
704 ctx->pgmap = get_dev_pagemap(pfn, ctx->pgmap);
705 if (!ctx->pgmap)
706 return ERR_PTR(-EFAULT);
707 }
708
709 page = pfn_to_page(pfn);
710
711 if (!pud_devmap(pud) && !pud_write(pud) &&
712 gup_must_unshare(vma, flags, page))
713 return ERR_PTR(-EMLINK);
714
715 ret = try_grab_folio(page_folio(page), 1, flags);
716 if (ret)
717 page = ERR_PTR(ret);
718 else
719 ctx->page_mask = HPAGE_PUD_NR - 1;
720
721 return page;
722 }
723

--
0-DAY CI Kernel Test Service