From: Yosry Ahmed <yosryahmed@google.com>
To: Chris Li <chrisl@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [RFC] Storing same-filled pages without a zswap_entry
Date: Thu, 21 Mar 2024 18:50:01 +0000 [thread overview]
Message-ID: <ZfyBWSTrc5t0xHuy@google.com> (raw)
In-Reply-To: <CANeU7QnP1KthUWRdqL2CiPCfA20P_1mPn8_jvT8AFwD8EUO5kQ@mail.gmail.com>
On Wed, Mar 20, 2024 at 09:26:43PM -0700, Chris Li wrote:
> On Wed, Mar 20, 2024 at 1:49 PM Yosry Ahmed <yosryahmed@google.com> wrote:
> >
> > Hey folks,
> >
> > I was looking at cleaning up the same-filled handling code in zswap,
> > when it hit me that after the xarray conversion, the only member of
> > struct zwap_entry that is relevant to same-filled pages is now the
> > objcg pointer.
> >
> > The xarray allows a pointer to be tagged by up to two tags (1 and 3),
> > so we can completely avoid allocating a zswap_entry for same-filled
> > pages by storing a tagged objcg pointer directly in the xarray
> > instead.
> >
> > Basically the xarray would then either have a pointer to struct
> > zswap_entry or struct obj_cgroup, where the latter is tagged as
> > SAME_FILLED_ONE or SAME_FILLED_ZERO.
> >
> > There are two benefits of this:
> > - Saving some memory (precisely 64 bytes per same-filled entry).
> > - Further separating handling of same-filled pages from compressed
> > pages, which results in some nice cleanups (especially in
> > zswap_store()). It also makes further improvements easier (e.g.
> > skipping limit checking for same-filled entries).
> >
> > The disadvantage is obviously the complexity needed to handle two
> > different types of pointers in the xarray, although I think with the
> > correct abstractions this is not a big deal.
>
> Another idea is we can make the zero fill zswap entry immutable and
> share by different pages. That way it does not depend on the xarray
> pointer tagging. It can share the same code path with existing zero
> fill page handling. Just don't free the zero fill entry.
The only relevant item in zswap_entry for same-filled pages is objcg.
That cannot be shared by different pages anyway. So basically the
immutable zswap entry will just be a magic value that encodes all
zero-filled pages.
If we are all fine with only supporting zero-filled pages, then I don't
see why we should not just store the objcg in the xarray and tag it as
such. In fact, we only need to use one of the two available tags in this
case.
>
> I want to reserve the zswap xarray tagging for another purpose.
Did you have another purpose in mind? or just for future expansion?
As I mentioned above, if we only support zero-filled pages, we only need
one of the two available tags. Also, this is an in-kernel change so I
think we could always take it back if we really need the tags in the
future.
>
> Just some food for thought. Might have less complexity because it
> doesn't need to deal with two different kinds of pointers.
I think the complexity is not that much with the right abstractions, but
this is best discussed with actual code imo.
>
> Chris
>
next prev parent reply other threads:[~2024-03-21 18:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 20:49 [RFC] Storing same-filled pages without a zswap_entry Yosry Ahmed
2024-03-20 21:07 ` Johannes Weiner
2024-03-20 21:14 ` Yosry Ahmed
2024-03-20 21:19 ` Johannes Weiner
2024-03-20 21:31 ` Yosry Ahmed
2024-03-21 3:40 ` Chengming Zhou
2024-03-21 18:44 ` Yosry Ahmed
2024-03-21 19:29 ` Johannes Weiner
2024-03-21 19:57 ` Yosry Ahmed
2024-03-22 0:28 ` Chris Li
2024-03-22 0:37 ` Yosry Ahmed
2024-03-20 21:42 ` Chris Li
2024-03-21 4:26 ` Chris Li
2024-03-21 18:50 ` Yosry Ahmed [this message]
2024-03-22 0:18 ` Chris Li
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=ZfyBWSTrc5t0xHuy@google.com \
--to=yosryahmed@google.com \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.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