From: Qi Zheng <qi.zheng@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: akpm@linux-foundation.org, david@kernel.org, kasong@tencent.com,
shakeel.butt@linux.dev, axelrasmussen@google.com,
yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org,
harry@kernel.org, muchun.song@linux.dev,
peiyang_he@smail.nju.edu.cn, mhocko@kernel.org,
roman.gushchin@linux.dev, ljs@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Qi Zheng <zhengqi.arch@bytedance.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] mm: mglru: fix stale batch updates after memcg reparenting
Date: Tue, 23 Jun 2026 09:57:47 +0800 [thread overview]
Message-ID: <19710ee5-8e1c-4b13-812b-4b03ca34260d@linux.dev> (raw)
In-Reply-To: <CAGsJ_4z34ZRu_RKkaZ7EgTWMOxptUjZ90WJyNoJrXGNjzutxnA@mail.gmail.com>
Hi Barry,
On 6/23/26 6:52 AM, Barry Song wrote:
> On Mon, Jun 22, 2026 at 3:38 PM Qi Zheng <qi.zheng@linux.dev> wrote:
>>
>> From: Qi Zheng <zhengqi.arch@bytedance.com>
>>
>> The mglru page table walker batches per-generation size deltas in
>> walk->nr_pages while walking page tables without holding the lruvec lock.
>> The reset_batch_size() later folds those deltas into walk->lruvec under
>> the lruvec lock.
>>
>> The page table walker can run concurrently with the memcg reparenting path
>> as follows:
>>
>> CPU0 CPU1
>> ==== ====
>>
>> walk_mm
>> --> walk_page_range
>> --> update_batch_size
>> --> walk->nr_pages += delta
>>
>> mem_cgroup_css_offline
>> --> memcg_reparent_objcgs
>> --> lock lruvec
>> lru_gen_reparent_memcg
>> --> reparent child folios to parent
>> unlock lruvec
>>
>> lock lruvec
>> reset_batch_size
>> --> child lrugen->nr_pages += delta
>>
>> This can trigger the following warning:
>>
>> WARNING: mm/vmscan.c:5867 at lru_gen_exit_memcg+0x26f/0x300
>> RIP: 0010:lru_gen_exit_memcg+0x26f/0x300 mm/vmscan.c:5867
>
> I can't find 5867; instead, I can find 5828:
>
> VM_WARN_ON_ONCE(memchr_inv(lruvec->lrugen.nr_pages, 0,
> sizeof(lruvec->lrugen.nr_pages)));
>
> Is this the warning?
Yes, I just copy-pasted the warning log from Peiyang's report.
Maybe the description should be changed to:
This will trigger the following warning in lru_gen_exit_memcg():
VM_WARN_ON_ONCE(memchr_inv(lruvec->lrugen.nr_pages, 0,
sizeof(lruvec->lrugen.nr_pages)));
>
>> Call Trace:
>> <TASK>
>> mem_cgroup_free mm/memcontrol.c:3972 [inline]
>> mem_cgroup_css_free+0x76/0xb0 mm/memcontrol.c:4241
>> css_free_rwork_fn+0x125/0x1260 kernel/cgroup/cgroup.c:5575
>> process_one_work+0xa0d/0x1c30 kernel/workqueue.c:3314
>> process_scheduled_works kernel/workqueue.c:3397 [inline]
>> worker_thread+0x645/0xe80 kernel/workqueue.c:3478
>> kthread+0x367/0x480 kernel/kthread.c:436
>> ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158
>> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
>> </TASK>
>>
>> To fix it, add lrugen->reparented to remember the new owner of a
>> reparented lruvec, and make reset_batch_size() charge pending deltas to
>> that owner.
>>
>> Reported-by: Peiyang He <peiyang_he@smail.nju.edu.cn>
>> Closes: https://lore.kernel.org/all/5A9E929D82717101+12fcf643-efb8-4b9a-a53a-1e28cc894f0b@smail.nju.edu.cn
>> Fixes: f304652609ea ("mm: vmscan: prepare for reparenting MGLRU folios")
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>
> Looks reasonable to me.
> Reviewed-by: Barry Song <baohua@kernel.org>
Thanks!
next prev parent reply other threads:[~2026-06-23 1:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 13:50 [BUG] mm: mglru: stale aging batch triggers lru_gen_exit_memcg warning Peiyang He
2026-06-22 3:12 ` Qi Zheng
2026-06-22 7:37 ` [PATCH] mm: mglru: fix stale batch updates after memcg reparenting Qi Zheng
2026-06-22 8:24 ` Peiyang He
2026-06-22 8:31 ` Qi Zheng
2026-06-22 22:52 ` Barry Song
2026-06-23 1:57 ` Qi Zheng [this message]
2026-06-23 2:15 ` Barry Song
2026-06-23 2:20 ` 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=19710ee5-8e1c-4b13-812b-4b03ca34260d@linux.dev \
--to=qi.zheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=peiyang_he@smail.nju.edu.cn \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=stable@vger.kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--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