All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 8382/11648] mm/shmem.c:2478:9: sparse: sparse: context imbalance in 'shmem_mcopy_atomic_pte' - different lock contexts for basic block
@ 2021-04-09 17:47 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-04-09 17:47 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: Axel Rasmussen <axelrasmussen@google.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   e99d8a8495175df8cb8b739f8cf9b0fc9d0cd3b5
commit: a311f80f1475642eea71c635c368043783c22f4a [8382/11648] userfaultfd: support minor fault handling for shmem
:::::: branch date: 6 hours ago
:::::: commit date: 9 days ago
config: parisc-randconfig-s031-20210409 (attached as .config)
compiler: hppa64-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-279-g6d5d9b42-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a311f80f1475642eea71c635c368043783c22f4a
        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 a311f80f1475642eea71c635c368043783c22f4a
        # 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__' ARCH=parisc 

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/shmem.c:2478:9: sparse: sparse: context imbalance in 'shmem_mcopy_atomic_pte' - different lock contexts for basic block

vim +/shmem_mcopy_atomic_pte +2478 mm/shmem.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  2361  
a311f80f147564 Axel Rasmussen    2021-04-01  2362  int shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd,
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2363  			   struct vm_area_struct *dst_vma,
a311f80f147564 Axel Rasmussen    2021-04-01  2364  			   unsigned long dst_addr, unsigned long src_addr,
a311f80f147564 Axel Rasmussen    2021-04-01  2365  			   enum mcopy_atomic_mode mode, struct page **pagep)
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2366  {
a311f80f147564 Axel Rasmussen    2021-04-01  2367  	bool is_continue = (mode == MCOPY_ATOMIC_CONTINUE);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2368  	struct inode *inode = file_inode(dst_vma->vm_file);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2369  	struct shmem_inode_info *info = SHMEM_I(inode);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2370  	struct address_space *mapping = inode->i_mapping;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2371  	gfp_t gfp = mapping_gfp_mask(mapping);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2372  	pgoff_t pgoff = linear_page_index(dst_vma, dst_addr);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2373  	spinlock_t *ptl;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2374  	void *page_kaddr;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2375  	struct page *page;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2376  	pte_t _dst_pte, *dst_pte;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2377  	int ret;
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2378  	pgoff_t offset, max_off;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2379  
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2380  	ret = -ENOMEM;
0f0796945614b7 Mike Rapoport     2017-09-06  2381  	if (!shmem_inode_acct_block(inode, 1))
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2382  		goto out;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2383  
a311f80f147564 Axel Rasmussen    2021-04-01  2384  	if (is_continue) {
a311f80f147564 Axel Rasmussen    2021-04-01  2385  		ret = -EFAULT;
a311f80f147564 Axel Rasmussen    2021-04-01  2386  		page = find_lock_page(mapping, pgoff);
a311f80f147564 Axel Rasmussen    2021-04-01  2387  		if (!page)
a311f80f147564 Axel Rasmussen    2021-04-01  2388  			goto out_unacct_blocks;
a311f80f147564 Axel Rasmussen    2021-04-01  2389  	} else if (!*pagep) {
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2390  		page = shmem_alloc_page(gfp, info, pgoff);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2391  		if (!page)
0f0796945614b7 Mike Rapoport     2017-09-06  2392  			goto out_unacct_blocks;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2393  
a311f80f147564 Axel Rasmussen    2021-04-01  2394  		if (mode == MCOPY_ATOMIC_NORMAL) {	/* mcopy_atomic */
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2395  			page_kaddr = kmap_atomic(page);
8d10396342063c Mike Rapoport     2017-09-06  2396  			ret = copy_from_user(page_kaddr,
8d10396342063c Mike Rapoport     2017-09-06  2397  					     (const void __user *)src_addr,
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2398  					     PAGE_SIZE);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2399  			kunmap_atomic(page_kaddr);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2400  
c1e8d7c6a7a682 Michel Lespinasse 2020-06-08  2401  			/* fallback to copy_from_user outside mmap_lock */
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2402  			if (unlikely(ret)) {
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2403  				*pagep = page;
0f0796945614b7 Mike Rapoport     2017-09-06  2404  				shmem_inode_unacct_blocks(inode, 1);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2405  				/* don't free the page */
9e368259ad9883 Andrea Arcangeli  2018-11-30  2406  				return -ENOENT;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2407  			}
a311f80f147564 Axel Rasmussen    2021-04-01  2408  		} else {		/* zeropage */
8d10396342063c Mike Rapoport     2017-09-06  2409  			clear_highpage(page);
8d10396342063c Mike Rapoport     2017-09-06  2410  		}
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2411  	} else {
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2412  		page = *pagep;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2413  		*pagep = NULL;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2414  	}
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2415  
a311f80f147564 Axel Rasmussen    2021-04-01  2416  	if (!is_continue) {
a311f80f147564 Axel Rasmussen    2021-04-01  2417  		VM_BUG_ON(PageSwapBacked(page));
a311f80f147564 Axel Rasmussen    2021-04-01  2418  		VM_BUG_ON(PageLocked(page));
9cc90c664a65f9 Andrea Arcangeli  2017-02-22  2419  		__SetPageLocked(page);
9cc90c664a65f9 Andrea Arcangeli  2017-02-22  2420  		__SetPageSwapBacked(page);
a425d3584e7e69 Andrea Arcangeli  2017-02-22  2421  		__SetPageUptodate(page);
a311f80f147564 Axel Rasmussen    2021-04-01  2422  	}
9cc90c664a65f9 Andrea Arcangeli  2017-02-22  2423  
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2424  	ret = -EFAULT;
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2425  	offset = linear_page_index(dst_vma, dst_addr);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2426  	max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2427  	if (unlikely(offset >= max_off))
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2428  		goto out_release;
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2429  
a311f80f147564 Axel Rasmussen    2021-04-01  2430  	/* If page wasn't already in the page cache, add it. */
a311f80f147564 Axel Rasmussen    2021-04-01  2431  	if (!is_continue) {
552446a4166189 Matthew Wilcox    2017-12-01  2432  		ret = shmem_add_to_page_cache(page, mapping, pgoff, NULL,
3fea5a499d57de Johannes Weiner   2020-06-03  2433  					      gfp & GFP_RECLAIM_MASK, dst_mm);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2434  		if (ret)
3fea5a499d57de Johannes Weiner   2020-06-03  2435  			goto out_release;
a311f80f147564 Axel Rasmussen    2021-04-01  2436  	}
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2437  
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2438  	_dst_pte = mk_pte(page, dst_vma->vm_page_prot);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2439  	if (dst_vma->vm_flags & VM_WRITE)
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2440  		_dst_pte = pte_mkwrite(pte_mkdirty(_dst_pte));
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2441  	else {
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2442  		/*
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2443  		 * We don't set the pte dirty if the vma has no
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2444  		 * VM_WRITE permission, so mark the page dirty or it
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2445  		 * could be freed from under us. We could do it
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2446  		 * unconditionally before unlock_page(), but doing it
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2447  		 * only if VM_WRITE is not set is faster.
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2448  		 */
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2449  		set_page_dirty(page);
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2450  	}
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2451  
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2452  	dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2453  
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2454  	ret = -EFAULT;
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2455  	max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2456  	if (unlikely(offset >= max_off))
3fea5a499d57de Johannes Weiner   2020-06-03  2457  		goto out_release_unlock;
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2458  
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2459  	ret = -EEXIST;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2460  	if (!pte_none(*dst_pte))
3fea5a499d57de Johannes Weiner   2020-06-03  2461  		goto out_release_unlock;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2462  
a311f80f147564 Axel Rasmussen    2021-04-01  2463  	if (!is_continue) {
6058eaec816f29 Johannes Weiner   2020-06-03  2464  		lru_cache_add(page);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2465  
94b7cc01da5a3c Yang Shi          2020-04-20  2466  		spin_lock_irq(&info->lock);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2467  		info->alloced++;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2468  		inode->i_blocks += BLOCKS_PER_PAGE;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2469  		shmem_recalc_inode(inode);
94b7cc01da5a3c Yang Shi          2020-04-20  2470  		spin_unlock_irq(&info->lock);
a311f80f147564 Axel Rasmussen    2021-04-01  2471  	}
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2472  
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2473  	inc_mm_counter(dst_mm, mm_counter_file(page));
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2474  	page_add_file_rmap(page, false);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2475  	set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2476  
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2477  	/* No need to invalidate - it was non-present before */
4c27fe4c4c84f3 Mike Rapoport     2017-02-22 @2478  	update_mmu_cache(dst_vma, dst_addr, dst_pte);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2479  	pte_unmap_unlock(dst_pte, ptl);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2480  	unlock_page(page);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2481  	ret = 0;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2482  out:
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2483  	return ret;
3fea5a499d57de Johannes Weiner   2020-06-03  2484  out_release_unlock:
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2485  	pte_unmap_unlock(dst_pte, ptl);
dcf7fe9d89763a Andrea Arcangeli  2018-11-30  2486  	ClearPageDirty(page);
e2a50c1f64145a Andrea Arcangeli  2018-11-30  2487  	delete_from_page_cache(page);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2488  out_release:
9cc90c664a65f9 Andrea Arcangeli  2017-02-22  2489  	unlock_page(page);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2490  	put_page(page);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2491  out_unacct_blocks:
0f0796945614b7 Mike Rapoport     2017-09-06  2492  	shmem_inode_unacct_blocks(inode, 1);
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2493  	goto out;
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2494  }
4c27fe4c4c84f3 Mike Rapoport     2017-02-22  2495  

:::::: The code at line 2478 was first introduced by commit
:::::: 4c27fe4c4c84f3afd504ecff2420cc1ad420d38e userfaultfd: shmem: add shmem_mcopy_atomic_pte for userfaultfd support

:::::: TO: Mike Rapoport <rppt@linux.vnet.ibm.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

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

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-09 17:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 17:47 [linux-next:master 8382/11648] mm/shmem.c:2478:9: sparse: sparse: context imbalance in 'shmem_mcopy_atomic_pte' - different lock contexts for basic block kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.