linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Chris Li <chrisl@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	 Nhat Pham <nphamcs@gmail.com>, Linux-MM <linux-mm@kvack.org>
Subject: Re: [RFC] Storing same-filled pages without a zswap_entry
Date: Thu, 21 Mar 2024 17:37:54 -0700	[thread overview]
Message-ID: <CAJD7tkYARgjQvv4D0C_+igfEjY2JFijOucEWTH6OHyvgQY2UWw@mail.gmail.com> (raw)
In-Reply-To: <CANeU7Q=tKCejX=w+0M-+GJG2k0txU7kR3dsJ8No9M1gJqJx6BA@mail.gmail.com>

On Thu, Mar 21, 2024 at 5:29 PM Chris Li <chrisl@kernel.org> wrote:
>
> On Thu, Mar 21, 2024 at 12:58 PM Yosry Ahmed <yosryahmed@google.com> wrote:
> >
> > On Thu, Mar 21, 2024 at 12:29 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > >
> > > On Thu, Mar 21, 2024 at 06:44:54PM +0000, Yosry Ahmed wrote:
> > > > > In some cases where the current objcg is not "correct", the testcases in
> > > > > test_zswap.c may break? Maybe we can use swap_cgroup info to charge the
> > > > > stats to the correct memcg? Not sure if this is feasible.
> > > >
> > > > For cgroup v1, swap_cgroup will be cleared from
> > > > mem_cgroup_swapin_uncharge_swap() before the zswap load.
> > > >
> > > > I think the current objcg will remain correct as long as swapin happens
> > > > from the same memcg as swapout (or if swapin happens from the parent
> > > > memcg and the swapout memcg was offlined).
> > >
> > > Swap readahead will pull in physically adjacent entries that may
> > > belong to somebody unrelated.
> >
> > Right. For those as well the current objcg would be correct if they
> > are readahead from the same memcg as the one they were swapped out
> > from, but I understand your point that readahead makes that more
> > likely to not be the case.
> >
> > I am slightly nervous about using the current objcg tbh, even though
> > it only affects the stats. It's just less straightforward this way. I
> > think I prefer either:
> > (a) Only supporting zero-filled pages and storing the objcg directly
> > in the xarray.
>
> We can add the zero-filled page as a special case to speed it up. I
> don't think we should remove non zero values of the same fill pages
> from zswap though. We can never declare the non zero same filled page
> is not going to happen. In that case, the current same fill is still
> better than going through the zsmalloc.

If we do this, we still need to support same-filled entries in
zswap_entry, which means we still cannot separate the logic
completely. Also, it would be weird to have zero-filled pages and
same-filled pages handled differently.

How common do we think same-filled but not zero-filled pages are? Are
there known user space usages or patterns that lead to this? The only
thing I can think of is if user space initializes a large array to the
same non-zero value, and then it gets swapped out before it is
modified.

If it is not common, perhaps it's not worth optimizing it.


  reply	other threads:[~2024-03-22  0:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 20:49 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 [this message]
2024-03-20 21:42   ` Chris Li
2024-03-21  4:26 ` Chris Li
2024-03-21 18:50   ` Yosry Ahmed
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=CAJD7tkYARgjQvv4D0C_+igfEjY2JFijOucEWTH6OHyvgQY2UWw@mail.gmail.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