Re: [PATCH v1 1/2] mm/madvise: introduce MADV_TRY_COLLAPSE for attempted synchronous hugepage collapse

From: kernel test robot
Date: Wed Jan 17 2024 - 16:53:32 EST


Hi Lance,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/Lance-Yang/mm-madvise-add-MADV_TRY_COLLAPSE-to-process_madvise/20240117-130450
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240117050217.43610-1-ioworker0%40gmail.com
patch subject: [PATCH v1 1/2] mm/madvise: introduce MADV_TRY_COLLAPSE for attempted synchronous hugepage collapse
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20240118/202401180500.SKo0zynj-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240118/202401180500.SKo0zynj-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401180500.SKo0zynj-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

mm/khugepaged.c: In function 'madvise_collapse':
>> mm/khugepaged.c:2784:28: warning: this statement may fall through [-Wimplicit-fallthrough=]
2784 | if (cc->is_try) {
| ^
mm/khugepaged.c:2789:17: note: here
2789 | case SCAN_PMD_NULL:
| ^~~~


vim +2784 mm/khugepaged.c

2702
2703 int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
2704 unsigned long start, unsigned long end, bool is_try)
2705 {
2706 struct collapse_control *cc;
2707 struct mm_struct *mm = vma->vm_mm;
2708 unsigned long hstart, hend, addr;
2709 int thps = 0, last_fail = SCAN_FAIL;
2710 bool mmap_locked = true;
2711
2712 BUG_ON(vma->vm_start > start);
2713 BUG_ON(vma->vm_end < end);
2714
2715 *prev = vma;
2716
2717 if (!thp_vma_allowable_order(vma, vma->vm_flags, false, false, false,
2718 PMD_ORDER))
2719 return -EINVAL;
2720
2721 cc = kmalloc(sizeof(*cc), GFP_KERNEL);
2722 if (!cc)
2723 return -ENOMEM;
2724 cc->is_khugepaged = false;
2725 cc->is_try = is_try;
2726
2727 mmgrab(mm);
2728 lru_add_drain_all();
2729
2730 hstart = (start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
2731 hend = end & HPAGE_PMD_MASK;
2732
2733 for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) {
2734 int result = SCAN_FAIL;
2735
2736 if (!mmap_locked) {
2737 cond_resched();
2738 mmap_read_lock(mm);
2739 mmap_locked = true;
2740 result = hugepage_vma_revalidate(mm, addr, false, &vma,
2741 cc);
2742 if (result != SCAN_SUCCEED) {
2743 last_fail = result;
2744 goto out_nolock;
2745 }
2746
2747 hend = min(hend, vma->vm_end & HPAGE_PMD_MASK);
2748 }
2749 mmap_assert_locked(mm);
2750 memset(cc->node_load, 0, sizeof(cc->node_load));
2751 nodes_clear(cc->alloc_nmask);
2752 if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file) {
2753 struct file *file = get_file(vma->vm_file);
2754 pgoff_t pgoff = linear_page_index(vma, addr);
2755
2756 mmap_read_unlock(mm);
2757 mmap_locked = false;
2758 result = hpage_collapse_scan_file(mm, addr, file, pgoff,
2759 cc);
2760 fput(file);
2761 } else {
2762 result = hpage_collapse_scan_pmd(mm, vma, addr,
2763 &mmap_locked, cc);
2764 }
2765 if (!mmap_locked)
2766 *prev = NULL; /* Tell caller we dropped mmap_lock */
2767
2768 handle_result:
2769 switch (result) {
2770 case SCAN_SUCCEED:
2771 case SCAN_PMD_MAPPED:
2772 ++thps;
2773 break;
2774 case SCAN_PTE_MAPPED_HUGEPAGE:
2775 BUG_ON(mmap_locked);
2776 BUG_ON(*prev);
2777 mmap_read_lock(mm);
2778 result = collapse_pte_mapped_thp(mm, addr, true);
2779 mmap_read_unlock(mm);
2780 goto handle_result;
2781 /* MADV_TRY_COLLAPSE: fail quickly */
2782 case SCAN_ALLOC_HUGE_PAGE_FAIL:
2783 case SCAN_CGROUP_CHARGE_FAIL:
> 2784 if (cc->is_try) {

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki