[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZMN4mjsF1QEsvW7D@corigine.com>
Date: Fri, 28 Jul 2023 10:13:14 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Qi Zheng <zhengqi.arch@...edance.com>
Cc: akpm@...ux-foundation.org, david@...morbit.com, tkhai@...ru,
vbabka@...e.cz, roman.gushchin@...ux.dev, djwong@...nel.org,
brauner@...nel.org, paulmck@...nel.org, tytso@....edu,
steven.price@....com, cel@...nel.org, senozhatsky@...omium.org,
yujie.liu@...el.com, gregkh@...uxfoundation.org,
muchun.song@...ux.dev, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, x86@...nel.org, kvm@...r.kernel.org,
xen-devel@...ts.xenproject.org, linux-erofs@...ts.ozlabs.org,
linux-f2fs-devel@...ts.sourceforge.net, cluster-devel@...hat.com,
linux-nfs@...r.kernel.org, linux-mtd@...ts.infradead.org,
rcu@...r.kernel.org, netdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
dm-devel@...hat.com, linux-raid@...r.kernel.org,
linux-bcache@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
linux-xfs@...r.kernel.org, linux-btrfs@...r.kernel.org,
Muchun Song <songmuchun@...edance.com>
Subject: Re: [PATCH v3 04/49] mm: shrinker: remove redundant shrinker_rwsem
in debugfs operations
On Thu, Jul 27, 2023 at 04:04:17PM +0800, Qi Zheng wrote:
> The debugfs_remove_recursive() will wait for debugfs_file_put() to return,
> so the shrinker will not be freed when doing debugfs operations (such as
> shrinker_debugfs_count_show() and shrinker_debugfs_scan_write()), so there
> is no need to hold shrinker_rwsem during debugfs operations.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@...edance.com>
> Reviewed-by: Muchun Song <songmuchun@...edance.com>
> ---
> mm/shrinker_debug.c | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c
> index 3ab53fad8876..f1becfd45853 100644
> --- a/mm/shrinker_debug.c
> +++ b/mm/shrinker_debug.c
> @@ -55,11 +55,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v)
> if (!count_per_node)
> return -ENOMEM;
>
> - ret = down_read_killable(&shrinker_rwsem);
> - if (ret) {
> - kfree(count_per_node);
> - return ret;
> - }
> rcu_read_lock();
Hi Qi Zheng,
As can be seen in the next hunk, this function returns 'ret'.
However, with this change 'ret' is uninitialised unless
signal_pending() returns non-zero in the while loop below.
This is flagged in a clan-16 W=1 build.
mm/shrinker_debug.c:87:11: warning: variable 'ret' is used uninitialized whenever 'do' loop exits because its condition is false [-Wsometimes-uninitialized]
} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/shrinker_debug.c:92:9: note: uninitialized use occurs here
return ret;
^~~
mm/shrinker_debug.c:87:11: note: remove the condition if it is always true
} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1
mm/shrinker_debug.c:77:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!memcg_aware) {
^~~~~~~~~~~~
mm/shrinker_debug.c:92:9: note: uninitialized use occurs here
return ret;
^~~
mm/shrinker_debug.c:77:3: note: remove the 'if' if its condition is always false
if (!memcg_aware) {
^~~~~~~~~~~~~~~~~~~
mm/shrinker_debug.c:52:9: note: initialize the variable 'ret' to silence this warning
int ret, nid;
^
= 0
>
> memcg_aware = shrinker->flags & SHRINKER_MEMCG_AWARE;
> @@ -92,7 +87,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v)
> } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
>
> rcu_read_unlock();
> - up_read(&shrinker_rwsem);
>
> kfree(count_per_node);
> return ret;
...
Powered by blists - more mailing lists