linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap
@ 2024-06-10 12:15 Usama Arif
  2024-06-10 12:15 ` [PATCH v3 1/2] " Usama Arif
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Usama Arif @ 2024-06-10 12:15 UTC (permalink / raw)
  To: akpm
  Cc: hannes, david, ying.huang, hughd, willy, yosryahmed, nphamcs,
	chengming.zhou, linux-mm, linux-kernel, kernel-team, Usama Arif

Going back to the v1 implementation of the patchseries. The main reason
is that a correct version of v2 implementation requires another rmap
walk in shrink_folio_list to change the ptes from swap entry to zero pages to
work (i.e. more CPU used) [1], is more complex to implement compared to v1
and is harder to verify correctness compared to v1, where everything is
handled by swap.

---
As shown in the patchseries that introduced the zswap same-filled
optimization [2], 10-20% of the pages stored in zswap are same-filled.
This is also observed across Meta's server fleet.
By using VM counters in swap_writepage (not included in this
patchseries) it was found that less than 1% of the same-filled
pages to be swapped out are non-zero pages.

For conventional swap setup (without zswap), rather than reading/writing
these pages to flash resulting in increased I/O and flash wear, a bitmap
can be used to mark these pages as zero at write time, and the pages can
be filled at read time if the bit corresponding to the page is set.

When using zswap with swap, this also means that a zswap_entry does not
need to be allocated for zero filled pages resulting in memory savings
which would offset the memory used for the bitmap.

A similar attempt was made earlier in [3] where zswap would only track
zero-filled pages instead of same-filled.
This patchseries adds zero-filled pages optimization to swap
(hence it can be used even if zswap is disabled) and removes the
same-filled code from zswap (as only 1% of the same-filled pages are
non-zero), simplifying code.

This patchseries is based on mm-unstable.


[1] https://lore.kernel.org/all/e4d167fe-cb1e-41d1-a144-00bfa14b7148@gmail.com/
[2] https://lore.kernel.org/all/20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1/
[3] https://lore.kernel.org/lkml/20240325235018.2028408-1-yosryahmed@google.com/

---
v2->v3:
- Going back to the v1 version of the implementation (David and Shakeel)
- convert unatomic bitmap_set/clear to atomic set/clear_bit (Johannes)
- use clear_highpage instead of folio_page_zero_fill (Yosry)

v1 -> v2:
- instead of using a bitmap in swap, clear pte for zero pages and let
  do_pte_missing handle this page at page fault. (Yosry and Matthew)
- Check end of page first when checking if folio is zero filled as
  it could lead to better performance. (Yosry)
 
Usama Arif (2):
  mm: store zero pages to be swapped out in a bitmap
  mm: remove code to handle same filled pages

 include/linux/swap.h |  1 +
 mm/page_io.c         | 92 +++++++++++++++++++++++++++++++++++++++++++-
 mm/swapfile.c        | 21 +++++++++-
 mm/zswap.c           | 86 ++++-------------------------------------
 4 files changed, 119 insertions(+), 81 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2024-06-14  9:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 12:15 [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap Usama Arif
2024-06-10 12:15 ` [PATCH v3 1/2] " Usama Arif
2024-06-10 13:07   ` Matthew Wilcox
2024-06-10 13:56     ` Usama Arif
2024-06-10 14:06       ` Matthew Wilcox
2024-06-10 14:14         ` Usama Arif
2024-06-10 14:33           ` Usama Arif
2024-06-10 17:57   ` Yosry Ahmed
2024-06-10 18:36     ` Usama Arif
2024-06-10 18:47       ` Yosry Ahmed
2024-06-11 11:49         ` Usama Arif
2024-06-11 15:42           ` Yosry Ahmed
2024-06-11 16:52             ` Usama Arif
2024-06-11 17:51               ` Yosry Ahmed
2024-06-11 18:43                 ` Usama Arif
2024-06-11 18:39   ` Nhat Pham
2024-06-11 18:46     ` Yosry Ahmed
2024-06-11 18:53       ` Nhat Pham
2024-06-11 18:50     ` Usama Arif
2024-06-11 19:33       ` Nhat Pham
2024-06-12 10:42         ` Usama Arif
2024-06-10 12:16 ` [PATCH v3 2/2] mm: remove code to handle same filled pages Usama Arif
2024-06-13 21:21 ` [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap Yosry Ahmed
2024-06-14  9:22   ` Usama Arif
2024-06-14  9:28     ` Yosry Ahmed
2024-06-13 21:50 ` Yosry Ahmed
2024-06-13 22:41   ` Shakeel Butt
2024-06-13 22:59     ` Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox