Skip to contentSkip to conversation

mm/shrinker.c:100:1-7: preceding lock on line 83 (fwd)

PATCH In review Julia Lawall 2 participants 2 messages Sep 29, 2023 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 8008/8345 mm/shrinker.c:100:1-7: preceding lock on line 83 (fwd)

Should shrinker_mutex be released on the error path?

julia

---------- Forwarded message ----------
Date: Fri, 29 Sep 2023 21:31:25 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 8008/8345] mm/shrinker.c:100:1-7: preceding lock on

    line 83

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

Hi Qi,

FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   df964ce9ef9fea10cf131bf6bad8658fde7956f6
commit: 3b0ec351e30dfbe71675deb22da8a9fe1894c87f [8008/8345] mm: shrinker: convert shrinker_rwsem to mutex

:::::: branch date: 9 hours ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-103-20230927 (https://download.01.org/0day-ci/archive/20230929/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230929/[email protected]/reproduce)

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 >>)

Quoted 1 line
Quoted 1 line

mm/shrinker.c:100:1-7: preceding lock on line 83

vim +100 mm/shrinker.c

2babd0d6e9cfca Qi Zheng 2023-09-11   76
2babd0d6e9cfca Qi Zheng 2023-09-11   77  int alloc_shrinker_info(struct mem_cgroup *memcg)
2babd0d6e9cfca Qi Zheng 2023-09-11   78  {
2babd0d6e9cfca Qi Zheng 2023-09-11   79  	struct shrinker_info *info;
b6884b5f15cf5a Qi Zheng 2023-09-11   80  	int nid, ret = 0;
b6884b5f15cf5a Qi Zheng 2023-09-11   81  	int array_size = 0;
2babd0d6e9cfca Qi Zheng 2023-09-11   82
3b0ec351e30dfb Qi Zheng 2023-09-11  @83  	mutex_lock(&shrinker_mutex);
b6884b5f15cf5a Qi Zheng 2023-09-11   84  	array_size = shrinker_unit_size(shrinker_nr_max);
2babd0d6e9cfca Qi Zheng 2023-09-11   85  	for_each_node(nid) {
b6884b5f15cf5a Qi Zheng 2023-09-11   86  		info = kvzalloc_node(sizeof(*info) + array_size, GFP_KERNEL, nid);
b6884b5f15cf5a Qi Zheng 2023-09-11   87  		if (!info)
b6884b5f15cf5a Qi Zheng 2023-09-11   88  			goto err;
2babd0d6e9cfca Qi Zheng 2023-09-11   89  		info->map_nr_max = shrinker_nr_max;
b6884b5f15cf5a Qi Zheng 2023-09-11   90  		if (shrinker_unit_alloc(info, NULL, nid))
b6884b5f15cf5a Qi Zheng 2023-09-11   91  			goto err;
2babd0d6e9cfca Qi Zheng 2023-09-11   92  		rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_info, info);
2babd0d6e9cfca Qi Zheng 2023-09-11   93  	}
3b0ec351e30dfb Qi Zheng 2023-09-11   94  	mutex_unlock(&shrinker_mutex);
2babd0d6e9cfca Qi Zheng 2023-09-11   95
2babd0d6e9cfca Qi Zheng 2023-09-11   96  	return ret;
b6884b5f15cf5a Qi Zheng 2023-09-11   97
b6884b5f15cf5a Qi Zheng 2023-09-11   98  err:
b6884b5f15cf5a Qi Zheng 2023-09-11   99  	free_shrinker_info(memcg);

b6884b5f15cf5a Qi Zheng 2023-09-11 @100 return -ENOMEM;
2babd0d6e9cfca Qi Zheng 2023-09-11 101 }
2babd0d6e9cfca Qi Zheng 2023-09-11 102

:::::: The code at line 100 was first introduced by commit
:::::: b6884b5f15cf5acf6886ec0704d799035477ad7e mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred}

:::::: TO: Qi Zheng <[email protected]> :::::: CC: Andrew Morton <[email protected]>

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

Hi Julia,

Quoted 1 line · Julia Lawall

Should shrinker_mutex be released on the error path?

Yes, and this has been fixed by https://lore.kernel.org/lkml/[email protected]/.

Thanks,
Qi

Quoted 77 lines

julia

---------- Forwarded message ----------
Date: Fri, 29 Sep 2023 21:31:25 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 8008/8345] mm/shrinker.c:100:1-7: preceding lock on

     line 83

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

Hi Qi,

FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   df964ce9ef9fea10cf131bf6bad8658fde7956f6
commit: 3b0ec351e30dfbe71675deb22da8a9fe1894c87f [8008/8345] mm: shrinker: convert shrinker_rwsem to mutex

:::::: branch date: 9 hours ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-103-20230927 (https://download.01.org/0day-ci/archive/20230929/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230929/[email protected]/reproduce)

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 >>)

Quoted 1 line
Quoted 1 line

mm/shrinker.c:100:1-7: preceding lock on line 83

vim +100 mm/shrinker.c

2babd0d6e9cfca Qi Zheng 2023-09-11   76
2babd0d6e9cfca Qi Zheng 2023-09-11   77  int alloc_shrinker_info(struct mem_cgroup *memcg)
2babd0d6e9cfca Qi Zheng 2023-09-11   78  {
2babd0d6e9cfca Qi Zheng 2023-09-11   79  	struct shrinker_info *info;
b6884b5f15cf5a Qi Zheng 2023-09-11   80  	int nid, ret = 0;
b6884b5f15cf5a Qi Zheng 2023-09-11   81  	int array_size = 0;
2babd0d6e9cfca Qi Zheng 2023-09-11   82
3b0ec351e30dfb Qi Zheng 2023-09-11  @83  	mutex_lock(&shrinker_mutex);
b6884b5f15cf5a Qi Zheng 2023-09-11   84  	array_size = shrinker_unit_size(shrinker_nr_max);
2babd0d6e9cfca Qi Zheng 2023-09-11   85  	for_each_node(nid) {
b6884b5f15cf5a Qi Zheng 2023-09-11   86  		info = kvzalloc_node(sizeof(*info) + array_size, GFP_KERNEL, nid);
b6884b5f15cf5a Qi Zheng 2023-09-11   87  		if (!info)
b6884b5f15cf5a Qi Zheng 2023-09-11   88  			goto err;
2babd0d6e9cfca Qi Zheng 2023-09-11   89  		info->map_nr_max = shrinker_nr_max;
b6884b5f15cf5a Qi Zheng 2023-09-11   90  		if (shrinker_unit_alloc(info, NULL, nid))
b6884b5f15cf5a Qi Zheng 2023-09-11   91  			goto err;
2babd0d6e9cfca Qi Zheng 2023-09-11   92  		rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_info, info);
2babd0d6e9cfca Qi Zheng 2023-09-11   93  	}
3b0ec351e30dfb Qi Zheng 2023-09-11   94  	mutex_unlock(&shrinker_mutex);
2babd0d6e9cfca Qi Zheng 2023-09-11   95
2babd0d6e9cfca Qi Zheng 2023-09-11   96  	return ret;
b6884b5f15cf5a Qi Zheng 2023-09-11   97
b6884b5f15cf5a Qi Zheng 2023-09-11   98  err:
b6884b5f15cf5a Qi Zheng 2023-09-11   99  	free_shrinker_info(memcg);

b6884b5f15cf5a Qi Zheng 2023-09-11 @100 return -ENOMEM;
2babd0d6e9cfca Qi Zheng 2023-09-11 101 }
2babd0d6e9cfca Qi Zheng 2023-09-11 102

:::::: The code at line 100 was first introduced by commit
:::::: b6884b5f15cf5acf6886ec0704d799035477ad7e mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred}

:::::: TO: Qi Zheng <[email protected]> :::::: CC: Andrew Morton <[email protected]>