[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230607204202.GA340728@cmpxchg.org>
Date: Wed, 7 Jun 2023 16:42:02 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Yosry Ahmed <yosryahmed@...gle.com>, Nhat Pham <nphamcs@...il.com>,
cerasuolodomenico@...il.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, sjenning@...hat.com,
ddstreet@...e.org, vitaly.wool@...sulko.com, kernel-team@...a.com
Subject: Re: [PATCH] zswap: do not shrink when memory.zswap.max is 0
On Wed, Jun 07, 2023 at 12:09:39PM -0700, Andrew Morton wrote:
> It's unclear (to me) whether we should proceed with this. Thoughts, please?
>
> Here's what I presently have in mm-hotfixes-unstable:
>
>
> From: Nhat Pham <nphamcs@...il.com>
> Subject: zswap: do not shrink if cgroup may not zswap
> Date: Tue, 30 May 2023 15:24:40 -0700
>
> Before storing a page, zswap first checks if the number of stored pages
> exceeds the limit specified by memory.zswap.max, for each cgroup in the
> hierarchy. If this limit is reached or exceeded, then zswap shrinking is
> triggered and short-circuits the store attempt.
>
> However, since the zswap's LRU is not memcg-aware, this can create the
> following pathological behavior: the cgroup whose zswap limit is 0 will
> evict pages from other cgroups continually, without lowering its own zswap
> usage. This means the shrinking will continue until the need for swap
> ceases or the pool becomes empty.
>
> As a result of this, we observe a disproportionate amount of zswap
> writeback and a perpetually small zswap pool in our experiments, even
> though the pool limit is never hit.
>
> More generally, a cgroup might unnecessarily evict pages from other
> cgroups before we drive the memcg back below its limit.
>
> This patch fixes the issue by rejecting zswap store attempt without
> shrinking the pool when obj_cgroup_may_zswap() returns false.
>
> [akpm@...ux-foundation.org: fix return of unintialized value]
> [akpm@...ux-foundation.org: s/ENOSPC/ENOMEM/]
> Link: https://lkml.kernel.org/r/20230530222440.2777700-1-nphamcs@gmail.com
> Link: https://lkml.kernel.org/r/20230530232435.3097106-1-nphamcs@gmail.com
> Fixes: f4840ccfca25 ("zswap: memcg accounting")
> Signed-off-by: Nhat Pham <nphamcs@...il.com>
> Cc: Dan Streetman <ddstreet@...e.org>
> Cc: Domenico Cerasuolo <cerasuolodomenico@...il.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Seth Jennings <sjenning@...hat.com>
> Cc: Vitaly Wool <vitaly.wool@...sulko.com>
> Cc: Yosry Ahmed <yosryahmed@...gle.com>
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Acked-by: Johannes Weiner <hannes@...xchg.org>
Powered by blists - more mailing lists