linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [linux-next:master 5116/5396] mm/memory.c:710:25: sparse: sparse: cast to non-scalar
@ 2021-05-26 13:56 kernel test robot
  2021-06-16  6:41 ` Alistair Popple
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-05-26 13:56 UTC (permalink / raw)
  To: Alistair Popple
  Cc: kbuild-all, Linux Memory Management List, Christoph Hellwig,
	Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 4315 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   f6b46ef27317b3441138b902689bd89e4f82c6f4
commit: ce50e82c1d69532fc05721ed7951480c8525e7fd [5116/5396] mm: device exclusive memory access
config: alpha-randconfig-s032-20210526 (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.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.3-341-g8af24329-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ce50e82c1d69532fc05721ed7951480c8525e7fd
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout ce50e82c1d69532fc05721ed7951480c8525e7fd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=alpha 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> mm/memory.c:710:25: sparse: sparse: cast to non-scalar
>> mm/memory.c:710:25: sparse: sparse: cast from non-scalar
   mm/memory.c:1024:17: sparse: sparse: context imbalance in 'copy_pte_range' - different lock contexts for basic block
   mm/memory.c:1721:16: sparse: sparse: context imbalance in '__get_locked_pte' - different lock contexts for basic block
   mm/memory.c:1770:9: sparse: sparse: context imbalance in 'insert_page' - different lock contexts for basic block
   mm/memory.c:2272:17: sparse: sparse: context imbalance in 'remap_pte_range' - different lock contexts for basic block
   mm/memory.c:2528:17: sparse: sparse: context imbalance in 'apply_to_pte_range' - unexpected unlock
   mm/memory.c:2816:17: sparse: sparse: context imbalance in 'wp_page_copy' - unexpected unlock
   mm/memory.c:3162:17: sparse: sparse: context imbalance in 'wp_pfn_shared' - unexpected unlock
   mm/memory.c:3225: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:4823:5: sparse: sparse: context imbalance in 'follow_invalidate_pte' - different lock contexts for basic block
   mm/memory.c:4944:9: sparse: sparse: context imbalance in 'follow_pfn' - unexpected unlock

vim +710 mm/memory.c

   702	
   703	static void restore_exclusive_pte(struct vm_area_struct *vma,
   704					  struct page *page, unsigned long address,
   705					  pte_t *ptep)
   706	{
   707		pte_t pte;
   708		swp_entry_t entry;
   709	
 > 710		pte = pte_mkold(mk_pte(page, READ_ONCE(vma->vm_page_prot)));
   711		if (pte_swp_soft_dirty(*ptep))
   712			pte = pte_mksoft_dirty(pte);
   713	
   714		entry = pte_to_swp_entry(*ptep);
   715		if (pte_swp_uffd_wp(*ptep))
   716			pte = pte_mkuffd_wp(pte);
   717		else if (is_writable_device_exclusive_entry(entry))
   718			pte = maybe_mkwrite(pte_mkdirty(pte), vma);
   719	
   720		set_pte_at(vma->vm_mm, address, ptep, pte);
   721	
   722		/*
   723		 * No need to take a page reference as one was already
   724		 * created when the swap entry was made.
   725		 */
   726		if (PageAnon(page))
   727			page_add_anon_rmap(page, vma, address, false);
   728		else
   729			/*
   730			 * Currently device exclusive access only supports anonymous
   731			 * memory so the entry shouldn't point to a filebacked page.
   732			 */
   733			WARN_ON_ONCE(!PageAnon(page));
   734	
   735		if (vma->vm_flags & VM_LOCKED)
   736			mlock_vma_page(page);
   737	
   738		/*
   739		 * No need to invalidate - it was non-present before. However
   740		 * secondary CPUs may have mappings that need invalidating.
   741		 */
   742		update_mmu_cache(vma, address, ptep);
   743	}
   744	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26003 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-next:master 5116/5396] mm/memory.c:710:25: sparse: sparse: cast to non-scalar
  2021-05-26 13:56 [linux-next:master 5116/5396] mm/memory.c:710:25: sparse: sparse: cast to non-scalar kernel test robot
@ 2021-06-16  6:41 ` Alistair Popple
  0 siblings, 0 replies; 2+ messages in thread
From: Alistair Popple @ 2021-06-16  6:41 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, Linux Memory Management List, Christoph Hellwig,
	Andrew Morton

On Wednesday, 26 May 2021 11:56:13 PM AEST kernel test robot wrote:

> sparse warnings: (new ones prefixed by >>)
> >> mm/memory.c:710:25: sparse: sparse: cast to non-scalar
> >> mm/memory.c:710:25: sparse: sparse: cast from non-scalar

These warnings seem strange to me - sparse is warning about the following:

    struct test test1 = { .x = 0 }, test2;
    test2 = (struct test) test1;

But I don't see what the issue is. Obviously you wouldn't normally write code
like this but this is the result of macro expansion. The reason this warning
occurs only for Alpha is READ_ONCE has a different implementation there. At
this stage I don't think there is a problem with this patch though - it is
either an issue with sparse or with the Alpha READ_ONCE implementation. I did
have a go at fixing the Alpha implementation but couldn't come up with a way
to make sparse happy.

It's also worth noting a x86 build encounters the same pair of warnings in
other analogous situations.

 - Alistair

>    mm/memory.c:1024:17: sparse: sparse: context imbalance in 'copy_pte_range' - different lock contexts for basic block
>    mm/memory.c:1721:16: sparse: sparse: context imbalance in '__get_locked_pte' - different lock contexts for basic block
>    mm/memory.c:1770:9: sparse: sparse: context imbalance in 'insert_page' - different lock contexts for basic block
>    mm/memory.c:2272:17: sparse: sparse: context imbalance in 'remap_pte_range' - different lock contexts for basic block
>    mm/memory.c:2528:17: sparse: sparse: context imbalance in 'apply_to_pte_range' - unexpected unlock
>    mm/memory.c:2816:17: sparse: sparse: context imbalance in 'wp_page_copy' - unexpected unlock
>    mm/memory.c:3162:17: sparse: sparse: context imbalance in 'wp_pfn_shared' - unexpected unlock
>    mm/memory.c:3225: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:4823:5: sparse: sparse: context imbalance in 'follow_invalidate_pte' - different lock contexts for basic block
>    mm/memory.c:4944:9: sparse: sparse: context imbalance in 'follow_pfn' - unexpected unlock
> 
> vim +710 mm/memory.c
> 
>    702
>    703  static void restore_exclusive_pte(struct vm_area_struct *vma,
>    704                                    struct page *page, unsigned long address,
>    705                                    pte_t *ptep)
>    706  {
>    707          pte_t pte;
>    708          swp_entry_t entry;
>    709
>  > 710          pte = pte_mkold(mk_pte(page, READ_ONCE(vma->vm_page_prot)));
>    711          if (pte_swp_soft_dirty(*ptep))
>    712                  pte = pte_mksoft_dirty(pte);
>    713
>    714          entry = pte_to_swp_entry(*ptep);
>    715          if (pte_swp_uffd_wp(*ptep))
>    716                  pte = pte_mkuffd_wp(pte);
>    717          else if (is_writable_device_exclusive_entry(entry))
>    718                  pte = maybe_mkwrite(pte_mkdirty(pte), vma);
>    719
>    720          set_pte_at(vma->vm_mm, address, ptep, pte);
>    721
>    722          /*
>    723           * No need to take a page reference as one was already
>    724           * created when the swap entry was made.
>    725           */
>    726          if (PageAnon(page))
>    727                  page_add_anon_rmap(page, vma, address, false);
>    728          else
>    729                  /*
>    730                   * Currently device exclusive access only supports anonymous
>    731                   * memory so the entry shouldn't point to a filebacked page.
>    732                   */
>    733                  WARN_ON_ONCE(!PageAnon(page));
>    734
>    735          if (vma->vm_flags & VM_LOCKED)
>    736                  mlock_vma_page(page);
>    737
>    738          /*
>    739           * No need to invalidate - it was non-present before. However
>    740           * secondary CPUs may have mappings that need invalidating.
>    741           */
>    742          update_mmu_cache(vma, address, ptep);
>    743  }
>    744
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-16  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 13:56 [linux-next:master 5116/5396] mm/memory.c:710:25: sparse: sparse: cast to non-scalar kernel test robot
2021-06-16  6:41 ` Alistair Popple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox