Re: [PATCH] mm: huge_memory: a new debugfs interface for splitting THP tests.
From: kernel test robot
Date: Mon Mar 08 2021 - 14:24:09 EST
Hi Zi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on kselftest/next]
[also build test ERROR on linux/master linus/master v5.12-rc2 next-20210305]
[cannot apply to hnaz-linux-mm/master]
[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]
url: https://github.com/0day-ci/linux/commits/Zi-Yan/mm-huge_memory-a-new-debugfs-interface-for-splitting-THP-tests/20210308-232339
base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
config: x86_64-randconfig-a015-20210308 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 3a11a41795bec548e91621caaa4cc00fc31b2212)
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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/961321af55684845ebc1e13e4c4e7c0da14a476a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Zi-Yan/mm-huge_memory-a-new-debugfs-interface-for-splitting-THP-tests/20210308-232339
git checkout 961321af55684845ebc1e13e4c4e7c0da14a476a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All errors (new ones prefixed by >>):
>> mm/huge_memory.c:3026:40: error: implicit declaration of function 'vma_migratable' [-Werror,-Wimplicit-function-declaration]
if (!vma || addr < vma->vm_start || !vma_migratable(vma))
^
1 error generated.
vim +/vma_migratable +3026 mm/huge_memory.c
2930
2931 #ifdef CONFIG_DEBUG_FS
2932 static int split_huge_pages_set(void *data, u64 val)
2933 {
2934 struct zone *zone;
2935 struct page *page;
2936 unsigned long pfn, max_zone_pfn;
2937 unsigned long total = 0, split = 0;
2938
2939 if (val != 1)
2940 return -EINVAL;
2941
2942 for_each_populated_zone(zone) {
2943 max_zone_pfn = zone_end_pfn(zone);
2944 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
2945 if (!pfn_valid(pfn))
2946 continue;
2947
2948 page = pfn_to_page(pfn);
2949 if (!get_page_unless_zero(page))
2950 continue;
2951
2952 if (zone != page_zone(page))
2953 goto next;
2954
2955 if (!PageHead(page) || PageHuge(page) || !PageLRU(page))
2956 goto next;
2957
2958 total++;
2959 lock_page(page);
2960 if (!split_huge_page(page))
2961 split++;
2962 unlock_page(page);
2963 next:
2964 put_page(page);
2965 }
2966 }
2967
2968 pr_info("%lu of %lu THP split\n", split, total);
2969
2970 return 0;
2971 }
2972 DEFINE_DEBUGFS_ATTRIBUTE(split_huge_pages_fops, NULL, split_huge_pages_set,
2973 "%llu\n");
2974
2975 static ssize_t split_huge_pages_in_range_pid_write(struct file *file,
2976 const char __user *buf, size_t count, loff_t *ppops)
2977 {
2978 static DEFINE_MUTEX(mutex);
2979 ssize_t ret;
2980 char input_buf[80]; /* hold pid, start_vaddr, end_vaddr */
2981 int pid;
2982 unsigned long vaddr_start, vaddr_end, addr;
2983 nodemask_t task_nodes;
2984 struct mm_struct *mm;
2985 unsigned long total = 0, split = 0;
2986
2987 ret = mutex_lock_interruptible(&mutex);
2988 if (ret)
2989 return ret;
2990
2991 ret = -EFAULT;
2992
2993 memset(input_buf, 0, 80);
2994 if (copy_from_user(input_buf, buf, min_t(size_t, count, 80)))
2995 goto out;
2996
2997 input_buf[79] = '\0';
2998 ret = sscanf(input_buf, "%d,0x%lx,0x%lx", &pid, &vaddr_start, &vaddr_end);
2999 if (ret != 3) {
3000 ret = -EINVAL;
3001 goto out;
3002 }
3003 vaddr_start &= PAGE_MASK;
3004 vaddr_end &= PAGE_MASK;
3005
3006 ret = strlen(input_buf);
3007 pr_debug("split huge pages in pid: %d, vaddr: [%lx - %lx]\n",
3008 pid, vaddr_start, vaddr_end);
3009
3010 mm = find_mm_struct(pid, &task_nodes);
3011 if (IS_ERR(mm)) {
3012 ret = -EINVAL;
3013 goto out;
3014 }
3015
3016 mmap_read_lock(mm);
3017 /*
3018 * always increase addr by PAGE_SIZE, since we could have a PTE page
3019 * table filled with PTE-mapped THPs, each of which is distinct.
3020 */
3021 for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) {
3022 struct vm_area_struct *vma = find_vma(mm, addr);
3023 unsigned int follflags;
3024 struct page *page;
3025
> 3026 if (!vma || addr < vma->vm_start || !vma_migratable(vma))
3027 break;
3028
3029 /* FOLL_DUMP to ignore special (like zero) pages */
3030 follflags = FOLL_GET | FOLL_DUMP;
3031 page = follow_page(vma, addr, follflags);
3032
3033 if (IS_ERR(page))
3034 break;
3035 if (!page)
3036 break;
3037
3038 if (!is_transparent_hugepage(page))
3039 continue;
3040
3041 total++;
3042 if (!can_split_huge_page(compound_head(page), NULL))
3043 continue;
3044
3045 if (!trylock_page(page))
3046 continue;
3047
3048 if (!split_huge_page(page))
3049 split++;
3050
3051 unlock_page(page);
3052 put_page(page);
3053 }
3054 mmap_read_unlock(mm);
3055 mmput(mm);
3056
3057 pr_debug("%lu of %lu THP split\n", split, total);
3058 out:
3059 mutex_unlock(&mutex);
3060 return ret;
3061
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip