From: Nhat Pham <nphamcs@gmail.com>
To: akpm@linux-foundation.org
Cc: hannes@cmpxchg.org, cerasuolodomenico@gmail.com,
yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org,
vitaly.wool@konsulko.com, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeelb@google.com,
muchun.song@linux.dev, linux-mm@kvack.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: [PATCH 0/2] workload-specific and memory pressure-driven zswap writeback
Date: Mon, 11 Sep 2023 09:40:22 -0700 [thread overview]
Message-ID: <20230911164024.2541401-1-nphamcs@gmail.com> (raw)
There are currently several issues with zswap writeback:
1. There is only a single global LRU for zswap. This makes it impossible
to perform worload-specific shrinking - an memcg under memory
pressure cannot determine which pages in the pool it owns, and often
ends up writing pages from other memcgs. This issue has been
previously observed in practice and mitigated by simply disabling
memcg-initiated shrinking:
https://lore.kernel.org/all/20230530232435.3097106-1-nphamcs@gmail.com/T/#u
But this solution leaves a lot to be desired, as we still do not have an
avenue for an memcg to free up its own memory locked up in zswap.
2. We only shrink the zswap pool when the user-defined limit is hit.
This means that if we set the limit too high, cold data that are
unlikely to be used again will reside in the pool, wasting precious
memory. It is hard to predict how much zswap space will be needed
ahead of time, as this depends on the workload (specifically, on
factors such as memory access patterns and compressibility of the
memory pages).
This patch series solves these issues by separating the global zswap
LRU into per-memcg and per-NUMA LRUs, and performs workload-specific
(i.e memcg- and NUMA-aware) zswap writeback under memory pressure. The
new shrinker does not have any parameter that must be tuned by the
user, and can be opted in or out on a per-memcg basis.
On a benchmark that we have run:
(without the shrinker)
real -- mean: 153.27s, median: 153.199s
sys -- mean: 541.652s, median: 541.903s
user -- mean: 4384.9673999999995s, median: 4385.471s
(with the shrinker)
real -- mean: 151.4956s, median: 151.456s
sys -- mean: 461.14639999999997s, median: 465.656s
user -- mean: 4384.7118s, median: 4384.675s
We observed a 14-15% reduction in kernel CPU time, which translated to
over 1% reduction in real time.
On another benchmark, where there was a lot more cold memory residing in
zswap, we observed even more pronounced gains:
(without the shrinker)
real -- mean: 157.52519999999998s, median: 157.281s
sys -- mean: 769.3082s, median: 780.545s
user -- mean: 4378.1622s, median: 4378.286s
(with the shrinker)
real -- mean: 152.9608s, median: 152.845s
sys -- mean: 517.4446s, median: 506.749s
user -- mean: 4387.694s, median: 4387.935s
Here, we saw around 32-35% reduction in kernel CPU time, which
translated to 2.8% reduction in real time. These results confirm our
hypothesis that the shrinker is more helpful the more cold memory we
have.
Domenico Cerasuolo (1):
zswap: make shrinking memcg-aware
Nhat Pham (1):
zswap: shrinks zswap pool based on memory pressure
Documentation/admin-guide/mm/zswap.rst | 12 +
include/linux/list_lru.h | 39 +++
include/linux/memcontrol.h | 1 +
include/linux/mmzone.h | 14 +
include/linux/zswap.h | 9 +
mm/list_lru.c | 46 ++-
mm/memcontrol.c | 33 +++
mm/swap_state.c | 50 +++-
mm/zswap.c | 369 ++++++++++++++++++++++---
9 files changed, 518 insertions(+), 55 deletions(-)
--
2.34.1
next reply other threads:[~2023-09-11 16:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 16:40 Nhat Pham [this message]
2023-09-11 16:40 ` [PATCH 1/2] zswap: make shrinking memcg-aware Nhat Pham
2023-09-14 9:34 ` kernel test robot
2023-09-11 16:40 ` [PATCH 2/2] zswap: shrinks zswap pool based on memory pressure Nhat Pham
2023-09-15 12:13 ` kernel test robot
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=20230911164024.2541401-1-nphamcs@gmail.com \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=sjenning@redhat.com \
--cc=vitaly.wool@konsulko.com \
--cc=yosryahmed@google.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;
as well as URLs for NNTP newsgroup(s).