Re: [PATCH v2 1/2] mm/zswap: Fix global shrinker when memory cgroup is disabled

From: Johannes Weiner

Date: Wed Jul 22 2026 - 22:25:01 EST


On Fri, Jul 17, 2026 at 04:51:50PM +0800, Hao Jia wrote:
> From: Hao Jia <jiahao1@xxxxxxxxxxx>
>
> Zswap writeback on hitting the pool limit is broken when memory cgroup
> is disabled, because mem_cgroup_iter() always returns NULL. Therefore,
> the global shrinker shrink_worker() always takes the !memcg branch.
> After MAX_RECLAIM_RETRIES empty walks, the worker simply gives up, so it
> fails to write back anything.
>
> Therefore, when memory cgroup is disabled, fall through with the !memcg
> branch and shrink the root memcg directly.
>
> With memcg disabled, shrink_memcg() only returns -ENOENT when the root
> LRU is empty, which means the total pages are already below thr. In the
> absence of heavy concurrent zswap stores, the loop then safely bails out
> via the zswap_total_pages() <= thr check; otherwise, it will resume
> shrinking the memcg after processing the reschedule check. For any other
> return value from shrink_memcg(), the loop is guaranteed to terminate,
> either after MAX_RECLAIM_RETRIES failures or once the threshold is met.
>
> Fixes: a65b0e7607cc ("zswap: make shrinking memcg-aware")
> Cc: stable@xxxxxxxxxxxxxxx
> Suggested-by: Nhat Pham <nphamcs@xxxxxxxxx>
> Acked-by: Nhat Pham <nphamcs@xxxxxxxxx>
> Acked-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> Reported-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/CAO9r8zPVzMKFbCixxD-qgtRrkFxWVrHiZZeLc=eyTPKPVQgX4g@xxxxxxxxxxxxxx
> Signed-off-by: Hao Jia <jiahao1@xxxxxxxxxxx>

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>