Skip to content

mm, swap: improve cluster scan strategy

Kairui Song linux-mm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 5 repliesIn review
  2. v12 patches 8 repliesSuperseded

Changelog from the cover letter

- Split into 3 patches, no code change [ Chris Li ]
- Rebase and rerun the test to see if removing the fragment cluster counter helps to improve the performance, as expected, it's marginal.
- Collect Ack/Review-by [ Nhat Pham, Chris Li ]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm, swap: only scan one cluster in fragment listmm/swapfile.c+8 -152 replies
2/3mm, swap: remove fragment clusters counterinclude/linux/swap.h mm/swapfile.c+0 -83 replies
3/3mm, swap: prefer nonfull over free clustersmm/swapfile.c+28 -100 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchNhat PhamChris Li
1/3A-b A-b
2/3R-b A-b A-b
3/3R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] mm, swap: improve cluster scan strategy

From: Kairui Song <[email protected]>

This series improves the large allocation performance and reduces the failure rate. Some design of the cluster alloactor was later found to be improvable after thorough testing.

The allocator spent too much effort scanning the fragment list, which is not helpful in most setups, but causes serious contention of the list lock (si->lock). Besides, the allocator prefers free clusters when searching for a new cluster due to historical reasons, which causes fragmentation issues.

So make the allocator only scan one cluster for high order allocation, and prefer nonfull cluster. This both improves the performance and reduces fragmentation.

For example, build kernel test with make -j96 and 10G ZRAM with 64kB mTHP enabled shows better performance and a lower failure rate:

Before: sys time: 11609.69s  64kB/swpout: 1787051  64kB/swpout_fallback: 20917
After:  sys time: 5587.53s   64kB/swpout: 1811598  64kB/swpout_fallback: 0

System time is cut in half, and the failure rate drops to zero. Larger allocations in a hybrid workload also showed a major improvement:

512kB swap failure rate:

Before: swpout:11663  swpout_fallback:1767
After:  swpout:14480  swpout_fallback:6

2M swap failure rate:

Before: swpout:24     swpout_fallback:1442
After:  swpout:1329   swpout_fallback:7

Kairui Song (3):
mm, swap: only scan one cluster in fragment list mm, swap: remove fragment clusters counter mm, swap: prefer nonfull over free clusters

 include/linux/swap.h |  1 -
 mm/swapfile.c        | 68 +++++++++++++++++++++++---------------------
 2 files changed, 36 insertions(+), 33 deletions(-)

---

V1: https://lore.kernel.org/linux-mm/[email protected]/
Changelog:
- Split into 3 patches, no code change [ Chris Li ]
- Rebase and rerun the test to see if removing the fragment cluster counter helps to improve the performance, as expected, it's marginal.
- Collect Ack/Review-by [ Nhat Pham, Chris Li ]

Signature · 1 line
2.50.1