Re: [rcu:willy-maple 189/202] mm/mmap.c:2830:18: warning: variable 'ma_lock' set but not used

From: Liam Howlett
Date: Wed Feb 03 2021 - 10:51:13 EST


* kernel test robot <lkp@xxxxxxxxx> [210202 22:08]:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git willy-maple
> head: 7e346d2845b4bd77663394f39fa70456e0084c86
> commit: e40a951e09ed0e66dbd646f938df19c876915b9d [189/202] mm: Remove vma linked list.
> config: alpha-defconfig (attached as .config)
> compiler: alpha-linux-gcc (GCC) 9.3.0
> 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
> # https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=e40a951e09ed0e66dbd646f938df19c876915b9d
> git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
> git fetch --no-tags rcu willy-maple
> git checkout e40a951e09ed0e66dbd646f938df19c876915b9d
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>

Hello!

Yes, this can be safely dropped. I will fix this in my next patch
revision.

Thank you,
Liam


> All warnings (new ones prefixed by >>):
>
> mm/mmap.c:2366:5: warning: no previous prototype for 'do_mas_align_munmap' [-Wmissing-prototypes]
> 2366 | int do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
> | ^~~~~~~~~~~~~~~~~~~
> mm/mmap.c: In function '__do_sys_remap_file_pages':
> >> mm/mmap.c:2830:18: warning: variable 'ma_lock' set but not used [-Wunused-but-set-variable]
> 2830 | struct ma_state ma_lock;
> | ^~~~~~~
>
>
> vim +/ma_lock +2830 mm/mmap.c
>
> 2824
> 2825 struct mm_struct *mm = current->mm;
> 2826 struct vm_area_struct *vma;
> 2827 unsigned long populate = 0;
> 2828 unsigned long ret = -EINVAL;
> 2829 struct file *file;
> > 2830 struct ma_state ma_lock;
> 2831 MA_STATE(mas, &mm->mm_mt, start, start);
> 2832
> 2833 pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/vm/remap_file_pages.rst.\n",
> 2834 current->comm, current->pid);
> 2835
> 2836 if (prot)
> 2837 return ret;
> 2838
> 2839 start = start & PAGE_MASK;
> 2840 size = size & PAGE_MASK;
> 2841 if (start + size <= start)
> 2842 return ret;
> 2843
> 2844 /* Does pgoff wrap? */
> 2845 if (pgoff + (size >> PAGE_SHIFT) < pgoff)
> 2846 return ret;
> 2847
> 2848 if (mmap_write_lock_killable(mm))
> 2849 return -EINTR;
> 2850
> 2851 mas_set(&mas, start);
> 2852 vma = mas_walk(&mas);
> 2853 ma_lock = mas;
> 2854
> 2855 if (!vma || !(vma->vm_flags & VM_SHARED))
> 2856 goto out;
> 2857
> 2858 if (!vma->vm_file)
> 2859 goto out;
> 2860
> 2861 if (start + size > vma->vm_end) {
> 2862 struct vm_area_struct *prev, *next;
> 2863
> 2864 prev = vma;
> 2865 mas_for_each(&mas, next, start + size) {
> 2866 /* hole between vmas ? */
> 2867 if (next->vm_start != prev->vm_end)
> 2868 goto out;
> 2869
> 2870 if (next->vm_file != vma->vm_file)
> 2871 goto out;
> 2872
> 2873 if (next->vm_flags != vma->vm_flags)
> 2874 goto out;
> 2875
> 2876 if (start + size <= next->vm_end)
> 2877 break;
> 2878
> 2879 prev = next;
> 2880 }
> 2881
> 2882 if (!next)
> 2883 goto out;
> 2884 }
> 2885
> 2886 prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
> 2887 prot |= vma->vm_flags & VM_WRITE ? PROT_WRITE : 0;
> 2888 prot |= vma->vm_flags & VM_EXEC ? PROT_EXEC : 0;
> 2889
> 2890 flags &= MAP_NONBLOCK;
> 2891 flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
> 2892
> 2893 file = get_file(vma->vm_file);
> 2894 ret = do_mmap(vma->vm_file, start, size,
> 2895 prot, flags, pgoff, &populate, NULL);
> 2896 fput(file);
> 2897 out:
> 2898 mmap_write_unlock(mm);
> 2899 if (populate)
> 2900 mm_populate(ret, populate);
> 2901 if (!IS_ERR_VALUE(ret))
> 2902 ret = 0;
> 2903 return ret;
> 2904 }
> 2905
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx