Skip to contentSkip to conversation

mm/list_lru.c:82:3-9: preceding lock on line 77

DISCUSSION kernel test robot 1 participant 1 message May 25, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Kairui Song <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Linux Memory Management List <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d0c22de9995b624f563bc5004d44ac2655712a56
commit: fb56fdf8b9a2f7397f8a83dce50189f3f0cf71af mm/list_lru: split the lock to per-cgroup scope
date:   6 months ago

:::::: branch date: 10 hours ago
:::::: commit date: 6 months ago
config: x86_64-randconfig-102-20250525 (https://download.01.org/0day-ci/archive/20250525/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

>> mm/list_lru.c:82:3-9: preceding lock on line 77
>> mm/list_lru.c:82:3-9: preceding lock on line 77

mm/list_lru.c:82:3-9: preceding lock on line 75 mm/list_lru.c:82:3-9: preceding lock on line 75

vim +82 mm/list_lru.c

28e98022b31efd Kairui Song 2024-11-05   62  
28e98022b31efd Kairui Song 2024-11-05   63  static inline struct list_lru_one *
fb56fdf8b9a2f7 Kairui Song 2024-11-05   64  lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg,
fb56fdf8b9a2f7 Kairui Song 2024-11-05   65  		       bool irq, bool skip_empty)
28e98022b31efd Kairui Song 2024-11-05   66  {
28e98022b31efd Kairui Song 2024-11-05   67  	struct list_lru_one *l;
fb56fdf8b9a2f7 Kairui Song 2024-11-05   68  	long nr_items;
fb56fdf8b9a2f7 Kairui Song 2024-11-05   69  
fb56fdf8b9a2f7 Kairui Song 2024-11-05   70  	rcu_read_lock();
28e98022b31efd Kairui Song 2024-11-05   71  again:
28e98022b31efd Kairui Song 2024-11-05   72  	l = list_lru_from_memcg_idx(lru, nid, memcg_kmem_id(memcg));
fb56fdf8b9a2f7 Kairui Song 2024-11-05   73  	if (likely(l)) {
fb56fdf8b9a2f7 Kairui Song 2024-11-05   74  		if (irq)
fb56fdf8b9a2f7 Kairui Song 2024-11-05   75  			spin_lock_irq(&l->lock);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   76  		else
fb56fdf8b9a2f7 Kairui Song 2024-11-05  @77  			spin_lock(&l->lock);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   78  		nr_items = READ_ONCE(l->nr_items);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   79  		if (likely(nr_items != LONG_MIN)) {
fb56fdf8b9a2f7 Kairui Song 2024-11-05   80  			WARN_ON(nr_items < 0);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   81  			rcu_read_unlock();
28e98022b31efd Kairui Song 2024-11-05  @82  			return l;
fb56fdf8b9a2f7 Kairui Song 2024-11-05   83  		}
fb56fdf8b9a2f7 Kairui Song 2024-11-05   84  		if (irq)
fb56fdf8b9a2f7 Kairui Song 2024-11-05   85  			spin_unlock_irq(&l->lock);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   86  		else
fb56fdf8b9a2f7 Kairui Song 2024-11-05   87  			spin_unlock(&l->lock);
fb56fdf8b9a2f7 Kairui Song 2024-11-05   88  	}
fb56fdf8b9a2f7 Kairui Song 2024-11-05   89  	/*
fb56fdf8b9a2f7 Kairui Song 2024-11-05   90  	 * Caller may simply bail out if raced with reparenting or
fb56fdf8b9a2f7 Kairui Song 2024-11-05   91  	 * may iterate through the list_lru and expect empty slots.
fb56fdf8b9a2f7 Kairui Song 2024-11-05   92  	 */
fb56fdf8b9a2f7 Kairui Song 2024-11-05   93  	if (skip_empty) {
fb56fdf8b9a2f7 Kairui Song 2024-11-05   94  		rcu_read_unlock();
fb56fdf8b9a2f7 Kairui Song 2024-11-05   95  		return NULL;
fb56fdf8b9a2f7 Kairui Song 2024-11-05   96  	}
28e98022b31efd Kairui Song 2024-11-05   97  	VM_WARN_ON(!css_is_dying(&memcg->css));
fb56fdf8b9a2f7 Kairui Song 2024-11-05   98  	memcg = parent_mem_cgroup(memcg);
28e98022b31efd Kairui Song 2024-11-05   99  	goto again;
28e98022b31efd Kairui Song 2024-11-05  100  }

fb56fdf8b9a2f7 Kairui Song 2024-11-05 101

:::::: The code at line 82 was first introduced by commit
:::::: 28e98022b31efdb8f1ba310d938cd9b97ededfe4 mm/list_lru: simplify reparenting and initial allocation

:::::: TO: Kairui Song <[email protected]> :::::: CC: Andrew Morton <[email protected]>

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