linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Seth Jennings <sjenning@redhat.com>,
	Dan Streetman <ddstreet@ieee.org>,
	 Vitaly Wool <vitaly.wool@konsulko.com>,
	Nhat Pham <nphamcs@gmail.com>,
	 Domenico Cerasuolo <cerasuolodomenico@gmail.com>,
	Yu Zhao <yuzhao@google.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: zswap: support exclusive loads
Date: Wed, 7 Jun 2023 09:33:34 -0700	[thread overview]
Message-ID: <CAJD7tkbHHVJfbybP0gqHGPp9J2t34-1NC0np6PgMdfxLmX-kpg@mail.gmail.com> (raw)
In-Reply-To: <20230607141357.GA338934@cmpxchg.org>

On Wed, Jun 7, 2023 at 7:13 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Tue, May 30, 2023 at 09:02:51PM +0000, Yosry Ahmed wrote:
> > @@ -46,6 +46,19 @@ config ZSWAP_DEFAULT_ON
> >         The selection made here can be overridden by using the kernel
> >         command line 'zswap.enabled=' option.
> >
> > +config ZSWAP_EXCLUSIVE_LOADS
> > +     bool "Invalidate zswap entries when pages are loaded"
> > +     depends on ZSWAP
> > +     help
> > +       If selected, when a page is loaded from zswap, the zswap entry is
> > +       invalidated at once, as opposed to leaving it in zswap until the
> > +       swap entry is freed.
> > +
> > +       This avoids having two copies of the same page in memory
> > +       (compressed and uncompressed) after faulting in a page from zswap.
> > +       The cost is that if the page was never dirtied and needs to be
> > +       swapped out again, it will be re-compressed.
> > +
> >  choice
> >       prompt "Default compressor"
> >       depends on ZSWAP
> > diff --git a/mm/frontswap.c b/mm/frontswap.c
> > index 279e55b4ed87..e5d6825110f4 100644
> > --- a/mm/frontswap.c
> > +++ b/mm/frontswap.c
> > @@ -216,8 +216,13 @@ int __frontswap_load(struct page *page)
> >
> >       /* Try loading from each implementation, until one succeeds. */
> >       ret = frontswap_ops->load(type, offset, page);
> > -     if (ret == 0)
> > +     if (ret == 0) {
> >               inc_frontswap_loads();
> > +             if (frontswap_ops->exclusive_loads) {
> > +                     SetPageDirty(page);
> > +                     __frontswap_clear(sis, offset);
> > +             }
> > +     }
> >       return ret;
>
> This would be a much more accessible feature (distro kernels,
> experimenting, adapting to different workloads) if it were runtime
> switchable.
>
> That should be possible, right? As long as frontswap and zswap are
> coordinated, this can be done on a per-entry basis:
>
>         exclusive = READ_ONCE(frontswap_ops->exclusive_loads);
>         ret = frontswap_ops->load(type, offset, page, exclusive);
>         if (ret == 0) {
>                 if (exclusive) {
>                         SetPageDirty(page);
>                         __frontswap_clear(sis, offset);
>                 }
>         }

Sure, I can do that. My thought was that this isn't something that
someone usually wants to change at runtime, but at least for
experimentation, it does make things a lot easier. I can add a zswap
module parameter.

I am guessing for consistency with other zswap settings and for
convenience, I can leave the config option to set the default value
with, aka CONFIG_ZSWAP_EXCLUSIVE_LOADS_DEFAULT_ON or something. Does
this make sense?


      reply	other threads:[~2023-06-07 16:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 21:02 [PATCH] mm: zswap: support exclusive loads Yosry Ahmed
2023-05-30 21:15 ` Andrew Morton
2023-05-30 21:20   ` Yosry Ahmed
2023-05-30 23:54 ` Johannes Weiner
2023-05-30 23:56   ` Yosry Ahmed
2023-05-31  6:00   ` Christoph Hellwig
2023-06-07 14:13 ` Johannes Weiner
2023-06-07 16:33   ` 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=CAJD7tkbHHVJfbybP0gqHGPp9J2t34-1NC0np6PgMdfxLmX-kpg@mail.gmail.com \
    --to=yosryahmed@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.com \
    --cc=yuzhao@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;
as well as URLs for NNTP newsgroup(s).