linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Usama Arif <usamaarif642@gmail.com>
To: akpm@linux-foundation.org
Cc: hannes@cmpxchg.org, shakeel.butt@linux.dev, david@redhat.com,
	ying.huang@intel.com, hughd@google.com, willy@infradead.org,
	yosryahmed@google.com, nphamcs@gmail.com,
	chengming.zhou@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com,
	Usama Arif <usamaarif642@gmail.com>
Subject: [PATCH v4 0/2] mm: store zero pages to be swapped out in a bitmap
Date: Wed, 12 Jun 2024 13:43:34 +0100	[thread overview]
Message-ID: <20240612124750.2220726-1-usamaarif642@gmail.com> (raw)

As shown in the patchseries that introduced the zswap same-filled
optimization [1], 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 [2] 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/20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1/
[2] https://lore.kernel.org/lkml/20240325235018.2028408-1-yosryahmed@google.com/

---
v3 -> v4:
- remove folio_start/end_writeback when folio is zero filled at
  swap_writepage (Matthew)
- check if a large folio is partially in zeromap and return without
  folio_mark_uptodate so that an IO error is emitted, rather than
  checking zswap/disk (Yosry)
- clear zeromap in swap_free_cluster (Nhat)

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         | 114 ++++++++++++++++++++++++++++++++++++++++++-
 mm/swapfile.c        |  24 ++++++++-
 mm/zswap.c           |  86 +++-----------------------------
 4 files changed, 144 insertions(+), 81 deletions(-)

-- 
2.43.0



             reply	other threads:[~2024-06-12 12:47 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 12:43 Usama Arif [this message]
2024-06-12 12:43 ` [PATCH v4 1/2] " Usama Arif
2024-06-12 20:13   ` Yosry Ahmed
2024-06-13 11:37     ` Usama Arif
2024-06-13 16:38       ` Yosry Ahmed
2024-06-13 19:21         ` Usama Arif
2024-06-13 19:26           ` Yosry Ahmed
2024-06-13 19:38             ` Usama Arif
2024-09-04  5:55   ` Barry Song
2024-09-04  7:12     ` Yosry Ahmed
2024-09-04  7:17       ` Barry Song
2024-09-04  7:22         ` Yosry Ahmed
2024-09-04  7:54           ` Barry Song
2024-09-04 17:40             ` Yosry Ahmed
2024-09-05  7:03               ` Barry Song
2024-09-05  7:55                 ` Yosry Ahmed
2024-09-05  8:49                   ` Barry Song
2024-09-05 10:10                     ` Barry Song
2024-09-05 10:33                       ` Barry Song
2024-09-05 10:53                         ` Usama Arif
2024-09-05 11:00                           ` Barry Song
2024-09-05 19:19                             ` Usama Arif
2024-09-05 17:36                         ` Yosry Ahmed
2024-09-05 19:28                         ` Yosry Ahmed
2024-09-06 10:22                           ` Barry Song
2024-09-05 10:37                       ` Usama Arif
2024-09-05 10:42                         ` Barry Song
2024-09-05 10:50                           ` Usama Arif
2024-09-04 11:14     ` Usama Arif
2024-09-04 23:44       ` Barry Song
2024-09-04 23:47         ` Barry Song
2024-09-04 23:57         ` Yosry Ahmed
2024-09-05  0:29           ` Barry Song
2024-09-05  7:38             ` Yosry Ahmed
2024-06-12 12:43 ` [PATCH v4 2/2] mm: remove code to handle same filled pages Usama Arif
2024-06-12 15:09   ` Nhat Pham
2024-06-12 16:34     ` Usama Arif

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=20240612124750.2220726-1-usamaarif642@gmail.com \
    --to=usamaarif642@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.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