From: Qi Zheng <qi.zheng@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
shakeel.butt@linux.dev, muchun.song@linux.dev, yosry@kernel.org,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH v2] mm: memcontrol: fix rcu unbalance in get_non_dying_memcg_end()
Date: Wed, 29 Apr 2026 10:48:34 +0800 [thread overview]
Message-ID: <ea4b2fcc-25e4-42ae-9d3e-5fe7d86ed7fa@linux.dev> (raw)
In-Reply-To: <20260428151253.bdfb08401ebb74c438df0e52@linux-foundation.org>
On 4/29/26 6:12 AM, Andrew Morton wrote:
> On Tue, 28 Apr 2026 18:31:08 +0800 Qi Zheng <qi.zheng@linux.dev> wrote:
>
>> Currently, get_non_dying_memcg_start() and get_non_dying_memcg_end() both
>> evaluate cgroup_subsys_on_dfl(memory_cgrp_subsys) independently to
>> determine whether to acquire or release the RCU read lock.
>
> Sashiko review
> (https://sashiko.dev/#/patchset/20260428103108.45719-1-qi.zheng@linux.dev)
> is correct.
>
> mm/memcontrol.c: In function 'mod_memcg_state':
> mm/memcontrol.c:881:9: error: 'rcu_locked' is used uninitialized [-Werror=uninitialized]
> 881 | get_non_dying_memcg_end(rcu_locked);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/memcontrol.c:874:14: note: 'rcu_locked' was declared here
> 874 | bool rcu_locked;
> | ^~~~~~~~~~
> In function 'mod_memcg_lruvec_state',
> inlined from 'mod_lruvec_state' at mm/memcontrol.c:973:3:
> mm/memcontrol.c:952:9: error: 'rcu_locked' is used uninitialized [-Werror=uninitialized]
> 952 | get_non_dying_memcg_end(rcu_locked);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/memcontrol.c:944:14: note: 'rcu_locked' was declared here
> 944 | bool rcu_locked;
> | ^~~~~~~~~~
> In function 'mod_memcg_state',
> inlined from 'mem_cgroup_sk_uncharge' at mm/memcontrol.c:5392:2:
> mm/memcontrol.c:881:9: error: 'rcu_locked' is used uninitialized [-Werror=uninitialized]
> 881 | get_non_dying_memcg_end(rcu_locked);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/memcontrol.c:874:14: note: 'rcu_locked' was declared here
> 874 | bool rcu_locked;
> | ^~~~~~~~~~
In v1, I explicitly set rcu_locked in get_non_dying_memcg_start() to
avoid the uninitialized warning. However, I noticed that even if I drop
it, the warning doesn't actually trigger -- probably due to some GCC
optimiztions.
Anyway, let's explicitly initialize rcu_locked in both
mod_memcg_state() and mod_memcg_lruvec_state(). Will do it in v3.
Thanks!
prev parent reply other threads:[~2026-04-29 2:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 10:31 [PATCH v2] mm: memcontrol: fix rcu unbalance in get_non_dying_memcg_end() Qi Zheng
2026-04-28 11:19 ` Muchun Song
2026-04-28 22:12 ` Andrew Morton
2026-04-29 2:48 ` Qi Zheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea4b2fcc-25e4-42ae-9d3e-5fe7d86ed7fa@linux.dev \
--to=qi.zheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=yosry@kernel.org \
--cc=zhengqi.arch@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox