From: Nhat Pham <nphamcs@gmail.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
akpm@linux-foundation.org, tj@kernel.org,
lizefan.x@bytedance.com, cerasuolodomenico@gmail.com,
sjenning@redhat.com, ddstreet@ieee.org,
vitaly.wool@konsulko.com, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeelb@google.com,
muchun.song@linux.dev, hughd@google.com, corbet@lwn.net,
konrad.wilk@oracle.com, senozhatsky@chromium.org,
rppt@kernel.org, linux-mm@kvack.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
david@ixit.cz
Subject: Re: [RFC PATCH v2] zswap: memcontrol: implement zswap writeback disabling
Date: Thu, 2 Nov 2023 15:40:17 -0700 [thread overview]
Message-ID: <CAKEwX=MwNE_q3m+in8gO7XnjE5uhdFOpUyGzdteimSP1FJN7hg@mail.gmail.com> (raw)
In-Reply-To: <CAJD7tkacw52fwr6bUk5frepaRN071mmCeGke4s-jMwAXjKqSPg@mail.gmail.com>
On Thu, Nov 2, 2023 at 1:54 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> On Thu, Nov 2, 2023 at 1:50 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> > On Thu, Nov 02, 2023 at 01:27:24PM -0700, Yosry Ahmed wrote:
> > > On Thu, Nov 2, 2023 at 1:02 PM Nhat Pham <nphamcs@gmail.com> wrote:
> > > > @@ -201,6 +201,12 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
> > > > folio_end_writeback(folio);
> > > > return 0;
> > > > }
> > > > +
> > > > + if (!mem_cgroup_zswap_writeback_enabled(folio_memcg(folio))) {
> > > > + folio_mark_dirty(folio);
> > > > + return AOP_WRITEPAGE_ACTIVATE;
> > > > + }
> > > > +
> > >
> > > I am not a fan of this, because it will disable using disk swap if
> > > "zswap_writeback" is disabled, even if zswap is disabled or the page
> > > was never in zswap. The term zswap_writeback makes no sense here tbh.
> > >
> > > I am still hoping someone else will suggest better semantics, because
> > > honestly I can't think of anything. Perhaps something like
> > > memory.swap.zswap_only or memory.swap.types which accepts a string
> > > (e.g. "zswap"/"all",..).
> >
> > I had suggested the writeback name.
> >
> > My thinking was this: from a user pov, the way zswap is presented and
> > described, is a fast writeback cache that sits on top of swap. It's
> > implemented as this lookaside thing right now, but that's never how it
> > was sold. And frankly, that's not how it's expected to work, either.
> >
> > From the docs:
> >
> > Zswap is a lightweight compressed cache for swap pages.
> >
> > Zswap evicts pages from compressed cache on an LRU basis to the
> > backing swap device when the compressed pool reaches its size limit.
> >
> > When zswap is enabled, IO to the swap device is expected to come from
> > zswap. Everything else would be a cache failure. There are a few cases
> > now where zswap rejects and bypasses to swap. It's not a stretch to
> > call them accelerated writeback or writethrough. But also, these
> > represent failures and LRU inversions, we're working on fixing them.
> >
> > So from a user POV it's reasonable to say if I have zswap enabled and
> > disable writeback, I don't expect swapfile IO.
>
> Makes sense (although now you had me thinking whether
> memory.zswap.writethrough is a better name).
Hmmm I lean towards writeback because it's already used in zswap
context. Users not familiar with the writethrough concept might be
confused by the naming.
>
> >
> > But yes, if zswap isn't enabled at all, this shouldn't prevent pages
> > from going to swap.
>
> Right, at least mem_cgroup_zswap_writeback_enabled() should always
> return true if zswap is disabled.
Sure enough! In the next version, I'll always return true in this case.
>
> One more unrelated thing, I think we should drop the
> cgroup_subsys_on_dfl() check there. I understand the interface is only
> exposed in v2, but I don't see any reason why it wouldn't work in v1.
> Let's not make it harder for anyone who tries to expose this in v1
> (whether upstream or in an internal patch).
I don't have anything against cgroup v1 per se :) I just happened to
notice that zswap charging is not available in v1, so I just played it
safe here.
If nobody objects I can unguard this feature from v1. Seems
reasonable to me tbh.
next prev parent reply other threads:[~2023-11-02 22:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 20:02 Nhat Pham
2023-11-02 20:27 ` Yosry Ahmed
2023-11-02 20:44 ` Nhat Pham
2023-11-02 20:50 ` Johannes Weiner
2023-11-02 20:54 ` Yosry Ahmed
2023-11-02 22:40 ` Nhat Pham [this message]
2023-11-02 20:58 ` [RFC PATCH v2] zswap: memcontrol: mplement zswap writeback disabling (fix) Nhat Pham
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='CAKEwX=MwNE_q3m+in8gO7XnjE5uhdFOpUyGzdteimSP1FJN7hg@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=corbet@lwn.net \
--cc=david@ixit.cz \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kernel-team@meta.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=shakeelb@google.com \
--cc=sjenning@redhat.com \
--cc=tj@kernel.org \
--cc=vitaly.wool@konsulko.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