Re: [PATCH v5 2/2] mm: zswap: fix global shrinker error handling logic
From: Nhat Pham
Date: Fri Aug 02 2024 - 18:52:10 EST
On Tue, Jul 30, 2024 at 5:49 PM Takero Funaki <flintglass@xxxxxxxxx> wrote:
>
> This patch fixes the zswap global shrinker, which did not shrink the
> zpool as expected.
>
> The issue addressed is that shrink_worker() did not distinguish between
> unexpected errors and expected errors, such as failed writeback from an
> empty memcg. The shrinker would stop shrinking after iterating through
> the memcg tree 16 times, even if there was only one empty memcg.
>
> With this patch, the shrinker no longer considers encountering an empty
> memcg, encountering a memcg with writeback disabled, or reaching the end
> of a memcg tree walk as a failure, as long as there are memcgs that are
> candidates for writeback. Systems with one or more empty memcgs will now
> observe significantly higher zswap writeback activity after the zswap
> pool limit is hit.
>
> To avoid an infinite loop when there are no writeback candidates, this
> patch tracks writeback attempts during memcg tree walks and limits
> reties if no writeback candidates are found.
>
> To handle the empty memcg case, the helper function shrink_memcg() is
> modified to check if the memcg is empty and then return -ENOENT.
>
> Fixes: a65b0e7607cc ("zswap: make shrinking memcg-aware")
> Signed-off-by: Takero Funaki <flintglass@xxxxxxxxx>
Nice! LGTM FWIW.
Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>
Thank you so much for working on this, Takero! I look forward to your
other global shrinker fixes :)