All of lore.kernel.org
 help / color / mirror / Atom feed
* [akpm-mm:mm-new 443/459] fs/proc/task_mmu.c:1425 show_smaps_rollup() warn: 'vma' is an error pointer or valid
@ 2026-09-12 15:24 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-09-12 15:24 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: David Hildenbrand <david@kernel.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
CC: mm-commits@vger.kernel.org
TO: Suren Baghdasaryan <surenb@google.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
CC: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-new
head:   383fc05d4650b021f3c17e36a145106dcc61a294
commit: 69a7a3a45cf34c8bcc7552221d1ee62b001ec2a1 [443/459] proc/task_mmu: read proc/pid/smaps_rollup under per-vma lock
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: riscv-randconfig-r073-20260912 (https://download.01.org/0day-ci/archive/20260912/202609121707.Hya5cxAX-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 707c032dae3bee24eae29c6f4c459a6d6dc6556d)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202609121707.Hya5cxAX-lkp@intel.com/

New smatch warnings:
fs/proc/task_mmu.c:1425 show_smaps_rollup() warn: 'vma' is an error pointer or valid

Old smatch warnings:
arch/riscv/include/asm/atomic.h:218 arch_atomic_fetch_add_unless() warn: inconsistent indenting

vim +/vma +1425 fs/proc/task_mmu.c

258f669e7e88c1 Vlastimil Babka         2018-08-21  1391  
258f669e7e88c1 Vlastimil Babka         2018-08-21  1392  static int show_smaps_rollup(struct seq_file *m, void *v)
258f669e7e88c1 Vlastimil Babka         2018-08-21  1393  {
258f669e7e88c1 Vlastimil Babka         2018-08-21  1394  	struct proc_maps_private *priv = m->private;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1395  	struct proc_maps_locking_ctx *lock_ctx = &priv->lock_ctx;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1396  	struct mm_struct *mm = lock_ctx->mm;
860a2e7fa4a186 Alexey Dobriyan         2023-09-29  1397  	struct mem_size_stats mss = {};
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1398  	unsigned long last_vma_end = 0;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1399  	unsigned long vma_start = 0;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1400  	struct vm_area_struct *vma;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1401  	loff_t pos = 0;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1402  	int ret = 0;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1403  
258f669e7e88c1 Vlastimil Babka         2018-08-21  1404  	priv->task = get_proc_task(priv->inode);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1405  	if (!priv->task)
258f669e7e88c1 Vlastimil Babka         2018-08-21  1406  		return -ESRCH;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1407  
258f669e7e88c1 Vlastimil Babka         2018-08-21  1408  	if (!mm || !mmget_not_zero(mm)) {
258f669e7e88c1 Vlastimil Babka         2018-08-21  1409  		ret = -ESRCH;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1410  		goto out_put_task;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1411  	}
258f669e7e88c1 Vlastimil Babka         2018-08-21  1412  
258f669e7e88c1 Vlastimil Babka         2018-08-21  1413  	hold_task_mempolicy(priv);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1414  	rcu_read_lock();
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1415  	reset_lock_ctx(lock_ctx);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1416  
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1417  	vma_iter_init(&priv->iter, mm, 0);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1418  	vma = proc_get_vma(m, &pos);
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1419) 	if (unlikely(!vma))
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1420) 		goto empty_set;
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1421) 
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1422  	if (!IS_ERR(vma))
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1423) 		vma_start = vma->vm_start;
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1424  
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11 @1425  	while (vma) {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1426  		if (IS_ERR(vma)) {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1427  			ret = PTR_ERR(vma);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1428  			goto out_unlock;
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1429  		}
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1430  
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1431  		if (vma->vm_start < last_vma_end) {
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1432  			/*
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1433  			 * After retaking the lock, already reported VMA grew
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1434  			 * or got merged with the next one and we found it
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1435  			 * again. Gather stats for the remaining portion by
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1436  			 * starting at last_vma_end.
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1437  			 */
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1438  			smap_gather_stats_range(priv, vma, &mss, last_vma_end);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1439  		} else {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1440  			/* Found next unreported VMA, start from its beginning */
143ffc016ffd18 Suren Baghdasaryan      2026-09-11  1441  			smap_gather_stats(priv, vma, &mss);
6d065f507d8230 Yuanyuan Zhong          2024-05-23  1442  		}
6d065f507d8230 Yuanyuan Zhong          2024-05-23  1443  		last_vma_end = vma->vm_end;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1444  
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1445  		/*
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1446  		 * If the VMA lock is not taken, we hold the often contended
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1447  		 * mmap lock. This can happen if we had to fall back to the
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1448  		 * mmap lock.
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1449  		 *
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1450  		 * To relieve pressure, check if it is indeed contended, then
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1451  		 * temporarily release it.
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1452  		 */
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1453  		if (lock_ctx->mmap_locked &&
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1454  		    mmap_lock_is_contended(lock_ctx->mm)) {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1455  			unlock_ctx_mm(lock_ctx);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1456  			/*
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1457  			 * Even though we previously fell back to mmap lock,
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1458  			 * we try taking VMA lock for the next VMA, since it
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1459  			 * might not be under modification. In the worst case
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1460  			 * we will fall back to mmap lock again.
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1461  			 */
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1462  			rcu_read_lock();
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1463  			reset_lock_ctx(lock_ctx);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1464  			/* Resume from the last position. */
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1465  			pos = last_vma_end;
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1466  			vma_iter_init(&priv->iter, mm, pos);
6d065f507d8230 Yuanyuan Zhong          2024-05-23  1467  		}
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1468  		vma = proc_get_vma(m, &pos);
ff9f47f6f00cfe Chinwen Chang           2020-10-13  1469  	}
258f669e7e88c1 Vlastimil Babka         2018-08-21  1470  
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1471) empty_set:
c4c84f06285e48 Matthew Wilcox (Oracle  2022-09-06  1472) 	show_vma_header_prefix(m, vma_start, last_vma_end, 0, 0, 0, 0);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1473  	seq_pad(m, ' ');
258f669e7e88c1 Vlastimil Babka         2018-08-21  1474  	seq_puts(m, "[rollup]\n");
258f669e7e88c1 Vlastimil Babka         2018-08-21  1475  
ee2ad71b0756e9 Luigi Semenzato         2019-07-11  1476  	__show_smap(m, &mss, true);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1477  
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1478  out_unlock:
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1479  	if (lock_ctx->mmap_locked) {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1480  		unlock_ctx_mm(lock_ctx);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1481  	} else {
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1482  		unlock_ctx_vma(lock_ctx);
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1483  		rcu_read_unlock();
69a7a3a45cf34c Suren Baghdasaryan      2026-09-11  1484  	}
258f669e7e88c1 Vlastimil Babka         2018-08-21  1485  	release_task_mempolicy(priv);
a26a9781554857 Konstantin Khlebnikov   2019-07-11  1486  	mmput(mm);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1487  out_put_task:
258f669e7e88c1 Vlastimil Babka         2018-08-21  1488  	put_task_struct(priv->task);
258f669e7e88c1 Vlastimil Babka         2018-08-21  1489  	priv->task = NULL;
258f669e7e88c1 Vlastimil Babka         2018-08-21  1490  
493b0e9d945fa9 Daniel Colascione       2017-09-06  1491  	return ret;
e070ad49f31155 Mauricio Lin            2005-09-03  1492  }
d1be35cb6f9697 Andrei Vagin            2018-04-10  1493  #undef SEQ_PUT_DEC
e070ad49f31155 Mauricio Lin            2005-09-03  1494  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

only message in thread, other threads:[~2026-09-12 15:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-12 15:24 [akpm-mm:mm-new 443/459] fs/proc/task_mmu.c:1425 show_smaps_rollup() warn: 'vma' is an error pointer or valid 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.