linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>,
	akpm@linux-foundation.org, hannes@cmpxchg.org,  david@redhat.com,
	ying.huang@intel.com, hughd@google.com, willy@infradead.org,
	 nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org, kernel-team@meta.com,
	 Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap
Date: Thu, 13 Jun 2024 15:59:53 -0700	[thread overview]
Message-ID: <CAJD7tkYCr1cUf7jeUPiXQk+bQBzYCB-yHTm-8Ns9SJJB5QgCpQ@mail.gmail.com> (raw)
In-Reply-To: <etjzs45r7derztzgrb5b4tub4c72vobo6esc3ndksyke6kpiov@qj3ar7xwh6ee>

On Thu, Jun 13, 2024 at 3:41 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> On Thu, Jun 13, 2024 at 02:50:31PM GMT, Yosry Ahmed wrote:
> > On Mon, Jun 10, 2024 at 5:18 AM Usama Arif <usamaarif642@gmail.com> wrote:
> > >
> > > 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.
> >
> > There is also code to handle same-filled pages in zram, should we
> > remove this as well? It is worth noting that the handling in zram was
> > initially for zero-filled pages only, but it was extended to cover
> > same-filled pages as well by commit 8e19d540d107 ("zram: extend zero
> > pages to same element pages"). Apparently in a test on Android, about
> > 2.5% of the swapped out pages were non-zero same-filled pages.
> >
> > However, the leap from handling zero-filled pages to handling all
> > same-filled pages in zram wasn't a stretch. But now that zero-filled
> > pages handling in zram is redundant with this series, I wonder if it's
> > still worth keeping the same-filled pages handling.
>
> Please correct me if I am wrong but zram same-filled page handling is
> not just limited to swap-on-zram use-case and any zram as block device
> user can benefit from it. Also zram might not see any simplification
> similar to zswap in this patch series. I would say motivation behind
> zswap changes seems quite different from possible zram changes. I would
> recommed to evaluate these cases independently.

Uh yes. I keep forgetting that zram is used for other use cases than
swap. Please dismiss my comments then (unless it's uncommon to have
zero-filled / same-filled pages in other use cases).


      reply	other threads:[~2024-06-13 23:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 12:15 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 message]

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=CAJD7tkYCr1cUf7jeUPiXQk+bQBzYCB-yHTm-8Ns9SJJB5QgCpQ@mail.gmail.com \
    --to=yosryahmed@google.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=minchan@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=shakeel.butt@linux.dev \
    --cc=usamaarif642@gmail.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.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