From: Andrew Morton <akpm@linux-foundation.org>
To: Qi Zheng <qi.zheng@linux.dev>
Cc: shakeel.butt@linux.dev,
syzbot <syzbot+7d60b33a8a546263da7c@syzkaller.appspotmail.com>,
Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, ljs@kernel.org, surenb@google.com,
syzkaller-bugs@googlegroups.com, vbabka@kernel.org,
Muchun Song <songmuchun@bytedance.com>
Subject: Re: [syzbot] [mm?] WARNING: bad unlock balance in do_wp_page
Date: Mon, 27 Apr 2026 03:43:52 -0700 [thread overview]
Message-ID: <20260427034352.6ca48156d613319aac415290@linux-foundation.org> (raw)
In-Reply-To: <3591c663-a4a9-4c22-97cf-b58b2e7d8a41@linux.dev>
On Mon, 27 Apr 2026 15:24:10 +0800 Qi Zheng <qi.zheng@linux.dev> wrote:
>
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -805,10 +805,15 @@ static long memcg_state_val_in_pages(int idx, long
> val)
> * Used in mod_memcg_state() and mod_memcg_lruvec_state() to avoid
> race with
> * reparenting of non-hierarchical state_locals.
> */
> -static inline struct mem_cgroup *get_non_dying_memcg_start(struct
> mem_cgroup *memcg)
> +static inline struct mem_cgroup *get_non_dying_memcg_start(struct
> mem_cgroup *memcg,
> + bool *locked)
Sometimes this is called "locked", sometimes "rcu_locked". Let's be
consistent please.
> {
> - if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
> + if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
> + *locked = false;
> return memcg;
> + }
I was thinking we could use a single bit in the task_struct for this:
--- a/mm/memcontrol.c~a
+++ a/mm/memcontrol.c
@@ -810,6 +810,8 @@ static inline struct mem_cgroup *get_non
if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
return memcg;
+ current->foo = 1;
+
rcu_read_lock();
while (memcg_is_dying(memcg))
@@ -820,9 +822,11 @@ static inline struct mem_cgroup *get_non
static inline void get_non_dying_memcg_end(void)
{
- if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+ if (current->foo == 0)
return;
+ current->foo = 0;
+
rcu_read_unlock();
}
#else
_
That doesn't work if get_non_dying_memcg_start/get_non_dying_memcg_end
calls can nest? If they can nest then we'd need a counter in the
task_struct.
next prev parent reply other threads:[~2026-04-27 10:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-26 8:17 [syzbot] [mm?] WARNING: bad unlock balance in do_wp_page syzbot
2026-04-26 10:49 ` Andrew Morton
2026-04-26 15:57 ` Qi Zheng
2026-04-26 17:55 ` Andrew Morton
2026-04-27 7:24 ` Qi Zheng
2026-04-27 9:43 ` Qi Zheng
2026-04-27 10:44 ` Andrew Morton
2026-04-27 10:57 ` Qi Zheng
2026-04-27 10:43 ` Andrew Morton [this message]
2026-04-27 10:54 ` Qi Zheng
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=20260427034352.6ca48156d613319aac415290@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Liam.Howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=songmuchun@bytedance.com \
--cc=surenb@google.com \
--cc=syzbot+7d60b33a8a546263da7c@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vbabka@kernel.org \
/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