Re: [PATCH v2 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas

From: Baoquan He
Date: Sat Dec 17 2022 - 04:47:14 EST


On 12/17/22 at 02:41pm, kernel test robot wrote:
> Hi Baoquan,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-vmalloc-c-allow-vread-to-read-out-vm_map_ram-areas/20221217-095615
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20221217015435.73889-4-bhe%40redhat.com
> patch subject: [PATCH v2 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas
> config: loongarch-randconfig-r006-20221216
> compiler: loongarch64-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/368cd65be8fedd1642e53393dc3f28ff8726122d
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Baoquan-He/mm-vmalloc-c-allow-vread-to-read-out-vm_map_ram-areas/20221217-095615
> git checkout 368cd65be8fedd1642e53393dc3f28ff8726122d
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> mm/vmalloc.c: In function 'vb_vread':
> >> mm/vmalloc.c:3563:49: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
> 3563 | n = (re - rs + 1) << PAGE_SHIFT - offset;

Thanks, below code change can fix the warning.

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index bdaceda1b878..ec5665e70114 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3544,7 +3544,7 @@ static void vb_vread(char *buf, char *addr, int count)
}
/*it could start reading from the middle of used region*/
offset = offset_in_page(addr);
- n = (re - rs + 1) << PAGE_SHIFT - offset;
+ n = ((re - rs + 1) << PAGE_SHIFT) - offset;
if (n > count)
n = count;
aligned_vread(buf, start+offset, n);