Re: include/linux/pgtable.h:257:16: sparse: sparse: cast to non-scalar

From: Huang, Ying
Date: Tue Mar 08 2022 - 20:11:37 EST


kernel test robot <lkp@xxxxxxxxx> writes:

> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: ea4424be16887a37735d6550cfd0611528dbe5d9
> commit: b99a342d4f11a5455d999b12f5fee42ab6acaf8c NUMA balancing: reduce TLB flush via delaying mapping on hint page fault
> date: 10 months ago
> config: alpha-randconfig-s031-20220308 (https://download.01.org/0day-ci/archive/20220309/202203090359.xgOwYxvo-lkp@xxxxxxxxx/config)
> compiler: alpha-linux-gcc (GCC) 11.2.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b99a342d4f11a5455d999b12f5fee42ab6acaf8c
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout b99a342d4f11a5455d999b12f5fee42ab6acaf8c
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
>
> sparse warnings: (new ones prefixed by >>)
> mm/memory.c:949:17: sparse: sparse: context imbalance in 'copy_pte_range' - different lock contexts for basic block
> mm/memory.c:1629:16: sparse: sparse: context imbalance in '__get_locked_pte' - different lock contexts for basic block
> mm/memory.c:1678:9: sparse: sparse: context imbalance in 'insert_page' - different lock contexts for basic block
> mm/memory.c:2180:17: sparse: sparse: context imbalance in 'remap_pte_range' - different lock contexts for basic block
> mm/memory.c:2436:17: sparse: sparse: context imbalance in 'apply_to_pte_range' - unexpected unlock
> mm/memory.c:2692:17: sparse: sparse: context imbalance in 'wp_page_copy' - unexpected unlock
> mm/memory.c:3038:17: sparse: sparse: context imbalance in 'wp_pfn_shared' - unexpected unlock
> mm/memory.c:3101:19: sparse: sparse: context imbalance in 'do_wp_page' - different lock contexts for basic block
> mm/memory.c: note: in included file (through include/linux/mm.h, arch/alpha/include/asm/io.h, include/linux/io.h, include/linux/irq.h, ...):
>>> include/linux/pgtable.h:257:16: sparse: sparse: cast to non-scalar
>>> include/linux/pgtable.h:257:16: sparse: sparse: cast from non-scalar
> mm/memory.c:4660:5: sparse: sparse: context imbalance in 'follow_invalidate_pte' - different lock contexts for basic block
> mm/memory.c:4781:9: sparse: sparse: context imbalance in 'follow_pfn' - unexpected unlock
>
> vim +257 include/linux/pgtable.h
>
> e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 253
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 254 #ifndef __HAVE_ARCH_PTEP_GET
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 255 static inline pte_t ptep_get(pte_t *ptep)
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 256 {
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 @257 return READ_ONCE(*ptep);

The change isn't introduced by the reported commit apparently. So
there may be some mistake in the 0-Day bisection.

I am not familiar with alpha architecture. If the pte_t is always
defined as follows for alpha, the atomicity of the operation should be
OK?

typedef struct { unsigned long pte; } pte_t;

Best Regards,
Huang, Ying

> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 258 }
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 259 #endif
> 481e980a7c199c include/linux/pgtable.h Christophe Leroy 2020-06-15 260
>
> :::::: The code at line 257 was first introduced by commit
> :::::: 481e980a7c199c5a4634fd7ea308067dd4ba75fa mm: Allow arches to provide ptep_get()
>
> :::::: TO: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
> :::::: CC: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx