diff options
author | Johannes Weiner <[email protected]> | 2022-05-19 14:08:53 -0700 |
---|---|---|
committer | akpm <[email protected]> | 2022-05-19 14:08:53 -0700 |
commit | f4840ccfca25db225b3371a8f7b5770febee87c5 (patch) | |
tree | c35709fc53e78d36681620d17d410bcc0c5d5785 /lib/fault-inject.c | |
parent | f6498b776d280b30a4614d8261840961e993c2c8 (diff) |
zswap: memcg accounting
Applications can currently escape their cgroup memory containment when
zswap is enabled. This patch adds per-cgroup tracking and limiting of
zswap backend memory to rectify this.
The existing cgroup2 memory.stat file is extended to show zswap statistics
analogous to what's in meminfo and vmstat. Furthermore, two new control
files, memory.zswap.current and memory.zswap.max, are added to allow
tuning zswap usage on a per-workload basis. This is important since not
all workloads benefit from zswap equally; some even suffer compared to
disk swap when memory contents don't compress well. The optimal size of
the zswap pool, and the threshold for writeback, also depends on the size
of the workload's warm set.
The implementation doesn't use a traditional page_counter transaction.
zswap is unconventional as a memory consumer in that we only know the
amount of memory to charge once expensive compression has occurred. If
zwap is disabled or the limit is already exceeded we obviously don't want
to compress page upon page only to reject them all. Instead, the limit is
checked against current usage, then we compress and charge. This allows
some limit overrun, but not enough to matter in practice.
[[email protected]: fix for CONFIG_SLOB builds]
Link: https://lkml.kernel.org/r/[email protected]
[[email protected]: opt out of cgroups v1]
Link: https://lkml.kernel.org/r/Yn6it9mBYFA+/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Seth Jennings <[email protected]>
Cc: Dan Streetman <[email protected]>
Cc: Minchan Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'lib/fault-inject.c')
0 files changed, 0 insertions, 0 deletions