Re: [PATCH v2] mm: mglru: fix stale batch updates after memcg reparenting
From: Qi Zheng
Date: Thu Jun 25 2026 - 02:12:06 EST
On 6/25/26 12:16 PM, Harry Yoo wrote:
[...]
So lock_batch_lruvec() can be implemented like this:
#ifdef CONFIG_MEMCG
static struct lruvec *lock_batch_lruvec(struct lruvec *lruvec)
{
struct pglist_data *pgdat = lruvec_pgdat(lruvec);
struct mem_cgroup *memcg = lruvec_memcg(lruvec);
rcu_read_lock();
/*
* The memcg can be NULL when the memory controller is disabled.
* Otherwise, the caller keeps the memcg owning @lruvec alive.
*/
if (!memcg || !css_is_dying(&memcg->css))
goto lock;
do {
memcg = parent_mem_cgroup(memcg);
} while (memcg && css_is_dying(&memcg->css));
lruvec = mem_cgroup_lruvec(memcg, pgdat);
lock:
spin_lock_irq(&lruvec->lru_lock);
return lruvec;
}
#else
static struct lruvec *lock_batch_lruvec(struct lruvec *lruvec)
{
lruvec_lock_irq(lruvec);
return lruvec;
}
#endif
Does this make sense?
Yes, looks good to me!
OK, this sync method makes more sense as it doesn't require adding a
new lrugen->reparente. I'll go with this method and update v3.
Hi Barry and Baolin, what do you think? Since the sync method has been
changed, I will temporarily drop your previous Reviewed-by tags in v3. ;)
Thanks,
Qi