[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240817050921.18462-1-kanchana.p.sridhar@intel.com>
Date: Fri, 16 Aug 2024 22:09:17 -0700
From: Kanchana P Sridhar <kanchana.p.sridhar@...el.com>
To: linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
hannes@...xchg.org,
yosryahmed@...gle.com,
nphamcs@...il.com,
ryan.roberts@....com,
ying.huang@...el.com,
21cnbao@...il.com,
akpm@...ux-foundation.org
Cc: nanhai.zou@...el.com,
wajdi.k.feghali@...el.com,
vinodh.gopal@...el.com,
kanchana.p.sridhar@...el.com
Subject: [PATCH v3 0/4] mm: ZSWAP swap-out of mTHP folios
Hi All,
This patch-series enables zswap_store() to accept and store mTHP
folios. The most significant contribution in this series is from the
earlier RFC submitted by Ryan Roberts [1]. Ryan's original RFC has been
migrated to v6.11-rc3 in patch 2/4 of this series.
[1]: [RFC PATCH v1] mm: zswap: Store large folios without splitting
https://lore.kernel.org/linux-mm/20231019110543.3284654-1-ryan.roberts@arm.com/T/#u
Additionally, there is an attempt to modularize some of the functionality
in zswap_store(), to make it more amenable to supporting any-order
mTHPs.
For instance, the determination of whether a folio is same-filled is
based on mapping an index into the folio to derive the page. Likewise,
there is a function "zswap_store_entry" added to store a zswap_entry in
the xarray.
For accounting purposes, the patch-series adds per-order mTHP sysfs
"zswpout" counters that get incremented upon successful zswap_store of
an mTHP folio:
/sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/zswpout
This patch-series is a precursor to ZSWAP compress batching of mTHP
swap-out and decompress batching of swap-ins based on swapin_readahead(),
using Intel IAA hardware acceleration, which we would like to submit in
subsequent RFC patch-series, with performance improvement data.
Thanks to Ying Huang for pre-posting review feedback and suggestions!
Changes since v2:
=================
1) Gathered usemem data using SSD as the backing swap device for zswap,
as suggested by Ying Huang. Ying, I would appreciate it if you can
review the latest data. Thanks!
2) Generated the base commit info in the patches to attempt to address
the kernel test robot build errors.
3) No code changes to the individual patches themselves.
Changes since RFC v1:
=====================
1) Use sysfs for zswpout mTHP stats, as per Barry Song's suggestion.
Thanks Barry!
2) Addressed some of the code review comments that Nhat Pham provided in
Ryan's initial RFC [1]:
- Added a comment about the cgroup zswap limit checks occuring once per
folio at the beginning of zswap_store().
Nhat, Ryan, please do let me know if the comments convey the summary
from the RFC discussion. Thanks!
- Posted data on running the cgroup suite's zswap kselftest.
3) Rebased to v6.11-rc3.
4) Gathered performance data with usemem and the rebased patch-series.
Performance Testing:
====================
Testing of this patch-series was done with the v6.11-rc3 mainline, without
and with this patch-series, on an Intel Sapphire Rapids server,
dual-socket 56 cores per socket, 4 IAA devices per socket.
The system has 503 GiB RAM, with a 4G SSD as the backing swap device for
ZSWAP. Core frequency was fixed at 2500MHz.
The vm-scalability "usemem" test was run in a cgroup whose memory.high
was fixed. Following a similar methodology as in Ryan Roberts'
"Swap-out mTHP without splitting" series [2], 70 usemem processes were
run, each allocating and writing 1G of memory:
usemem --init-time -w -O -n 70 1g
Since I was constrained to get the 70 usemem processes to generate
swapout activity with the 4G SSD, I ended up using different cgroup
memory.high fixed limits for the experiments with 64K mTHP and 2M THP:
64K mTHP experiments: cgroup memory fixed at 60G
2M THP experiments : cgroup memory fixed at 55G
The vm/sysfs stats included after the performance data provide details
on the swapout activity to SSD/ZSWAP.
Other kernel configuration parameters:
ZSWAP Compressor : LZ4, DEFLATE-IAA
ZSWAP Allocator : ZSMALLOC
SWAP page-cluster : 2
In the experiments where "deflate-iaa" is used as the ZSWAP compressor,
IAA "compression verification" is enabled. Hence each IAA compression
will be decompressed internally by the "iaa_crypto" driver, the crc-s
returned by the hardware will be compared and errors reported in case of
mismatches. Thus "deflate-iaa" helps ensure better data integrity as
compared to the software compressors.
Throughput reported by usemem and perf sys time for running the test
are as follows, averaged across 3 runs:
64KB mTHP (cgroup memory.high set to 60G):
==========================================
------------------------------------------------------------------
| | | | |
|Kernel | mTHP SWAP-OUT | Throughput | Improvement|
| | | KB/s | |
|--------------------|-------------------|------------|------------|
|v6.11-rc3 mainline | SSD | 335,346 | Baseline |
|zswap-mTHP-Store | ZSWAP lz4 | 271,558 | -19% |
|zswap-mTHP-Store | ZSWAP deflate-iaa | 388,154 | 16% |
|------------------------------------------------------------------|
| | | | |
|Kernel | mTHP SWAP-OUT | Sys time | Improvement|
| | | sec | |
|--------------------|-------------------|------------|------------|
|v6.11-rc3 mainline | SSD | 91.37 | Baseline |
|zswap-mTHP=Store | ZSWAP lz4 | 265.43 | -191% |
|zswap-mTHP-Store | ZSWAP deflate-iaa | 235.60 | -158% |
------------------------------------------------------------------
-----------------------------------------------------------------------
| VMSTATS, mTHP ZSWAP/SSD stats| v6.11-rc3 | zswap-mTHP | zswap-mTHP |
| | mainline | Store | Store |
| | | lz4 | deflate-iaa |
|-----------------------------------------------------------------------|
| pswpin | 0 | 0 | 0 |
| pswpout | 174,432 | 0 | 0 |
| zswpin | 703 | 534 | 721 |
| zswpout | 1,501 | 1,491,654 | 1,398,805 |
|-----------------------------------------------------------------------|
| thp_swpout | 0 | 0 | 0 |
| thp_swpout_fallback | 0 | 0 | 0 |
| pgmajfault | 3,364 | 3,650 | 3,431 |
|-----------------------------------------------------------------------|
| hugepages-64kB/stats/zswpout | | 63,200 | 63,244 |
|-----------------------------------------------------------------------|
| hugepages-64kB/stats/swpout | 10,902 | 0 | 0 |
-----------------------------------------------------------------------
2MB PMD-THP/2048K mTHP (cgroup memory.high set to 55G):
=======================================================
------------------------------------------------------------------
| | | | |
|Kernel | mTHP SWAP-OUT | Throughput | Improvement|
| | | KB/s | |
|--------------------|-------------------|------------|------------|
|v6.11-rc3 mainline | SSD | 190,827 | Baseline |
|zswap-mTHP-Store | ZSWAP lz4 | 32,026 | -83% |
|zswap-mTHP-Store | ZSWAP deflate-iaa | 203,772 | 7% |
|------------------------------------------------------------------|
| | | | |
|Kernel | mTHP SWAP-OUT | Sys time | Improvement|
| | | sec | |
|--------------------|-------------------|------------|------------|
|v6.11-rc3 mainline | SSD | 27.23 | Baseline |
|zswap-mTHP-Store | ZSWAP lz4 | 156.52 | -475% |
|zswap-mTHP-Store | ZSWAP deflate-iaa | 171.45 | -530% |
------------------------------------------------------------------
-------------------------------------------------------------------------
| VMSTATS, mTHP ZSWAP/SSD stats | v6.11-rc3 | zswap-mTHP | zswap-mTHP |
| | mainline | Store | Store |
| | | lz4 | deflate-iaa |
|-------------------------------------------------------------------------|
| pswpin | 0 | 0 | 0 |
| pswpout | 797,184 | 0 | 0 |
| zswpin | 690 | 649 | 669 |
| zswpout | 1,465 | 1,596,382 | 1,540,766 |
|-------------------------------------------------------------------------|
| thp_swpout | 1,557 | 0 | 0 |
| thp_swpout_fallback | 0 | 3,248 | 3,752 |
| pgmajfault | 3,726 | 6,470 | 5,691 |
|-------------------------------------------------------------------------|
| hugepages-2048kB/stats/zswpout | | 2,416 | 2,261 |
|-------------------------------------------------------------------------|
| hugepages-2048kB/stats/swpout | 1,557 | 0 | 0 |
-------------------------------------------------------------------------
In the "Before" scenario, when zswap does not store mTHP, only allocations
count towards the cgroup memory limit, as against in the "After" scenario
with the introduction of zswap_store mTHP, that causes both allocations
and the zswap usage count towards the memory limit. As a result, we see
higher swapout activity in the "After" data, and consequent sys time
degradation.
We do observe considerable throughput improvement in the "After" data
when DEFLATE-IAA is the zswap compressor. This observation holds for
64K mTHP and 2MB THP experiments. This can be attributed to IAA's better
compress/decompress latency and compression ratio as compared to
software compressors.
In my opinion, even though the test set up does not provide an accurate
way for a direct before/after comparison (because of zswap usage being
counted in cgroup, hence towards the memory.high), it still seems
reasonable for zswap_store to support mTHP, so that further performance
improvements can be implemented.
One of the ideas that has shown promise in our experiments is to improve
ZSWAP mTHP store performance using batching. With IAA compress/decompress
batching used in ZSWAP, we are able to demonstrate significant
performance improvements and memory savings with IAA in scalability
experiments, as compared to software compressors. We hope to submit
this work as subsequent RFCs.
cgroup zswap kselftest with 4G SSD as zswap's backing device:
=============================================================
mTHP 64K set to 'always'
zswap compressor set to 'lz4'
page-cluster = 3
"Before":
=========
Test run with v6.11-rc3 and no code changes:
zswap shrinker_enabled = Y:
---------------------------
not ok 1 test_zswap_usage
not ok 2 test_swapin_nozswap
not ok 3 test_zswapin
# Failed to reclaim all of the requested memory
not ok 4 test_zswap_writeback_enabled
# Failed to reclaim all of the requested memory
not ok 5 test_zswap_writeback_disabled
ok 6 # SKIP test_no_kmem_bypass
not ok 7 test_no_invasive_cgroup_shrink
"After":
========
Test run with this patch-series and v6.11-rc3:
zswap shrinker_enabled = Y:
---------------------------
ok 1 test_zswap_usage
not ok 2 test_swapin_nozswap
ok 3 test_zswapin
ok 4 test_zswap_writeback_enabled
ok 5 test_zswap_writeback_disabled
ok 6 # SKIP test_no_kmem_bypass
not ok 7 test_no_invasive_cgroup_shrink
I haven't taken an in-depth look into the cgroup zswap tests, but it
looks like the results with the patch-series are no worse than without,
and in some cases better (this needs more analysis).
I would greatly appreciate your code review comments and suggestions!
Thanks,
Kanchana
[2] https://lore.kernel.org/linux-mm/20240408183946.2991168-1-ryan.roberts@arm.com/
Kanchana P Sridhar (4):
mm: zswap: zswap_is_folio_same_filled() takes an index in the folio.
mm: zswap: zswap_store() extended to handle mTHP folios.
mm: Add MTHP_STAT_ZSWPOUT to sysfs per-order mthp stats.
mm: swap: Count successful mTHP ZSWAP stores in sysfs mTHP stats.
include/linux/huge_mm.h | 1 +
mm/huge_memory.c | 2 +
mm/page_io.c | 7 ++
mm/zswap.c | 238 +++++++++++++++++++++++++++++-----------
4 files changed, 184 insertions(+), 64 deletions(-)
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
--
2.27.0
Powered by blists - more mailing lists