From: Barry Song <21cnbao@gmail.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chris Li <chrisl@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: zswap: handle incorrect attempts to load of large folios
Date: Tue, 11 Jun 2024 12:02:45 +1200 [thread overview]
Message-ID: <CAGsJ_4zCuwi52BU3sW2tFj67NsxapQoS=g76QHwRo=R1i5ZBCA@mail.gmail.com> (raw)
In-Reply-To: <CAJD7tka2e1tG6vxU2XXKrzZBUBAc1EfcvaLU+yhQbzZO2gh0=g@mail.gmail.com>
On Tue, Jun 11, 2024 at 11:41 AM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> [..]
> > > > > We can't always WARN_ON for large folios, as this will fire even if
> > > > > zswap was never enabled. The alternative is tracking whether zswap was
> > > > > ever enabled, and checking that instead of checking if any part of the
> > > > > folio is in zswap.
> > > > >
> > > > > Basically replacing xa_find(..) with zswap_was_enabled(..) or something.
> > > >
> > > > My point is that mm core should always fallback
> > > >
> > > > if (zswap_was_or_is_enabled())
> > > > goto fallback;
> > > >
> > > > till zswap fixes the issue. This is the only way to enable large folios swap-in
> > > > development before we fix zswap.
> > >
> > > I agree with this, I just want an extra fallback in zswap itself in
> > > case something was missed during large folio swapin development (which
> > > can evidently happen).
> >
> > yes. then i feel we only need to warn_on the case mm-core fails to fallback.
> >
> > I mean, only WARN_ON is_zswap_ever_enabled&&large folio. there is no
> > need to do more. Before zswap brings up the large folio support, mm-core
> > will need is_zswap_ever_enabled() to do fallback.
>
> I don't have a problem with doing it this way instead of checking if
> any part of the folio is in zswap. Such a check may be needed for core
> MM to fallback to order-0 anyway, as we discussed. But I'd rather have
> this as a static key since it will never be changed.
right. This is better.
>
> Also, I still prefer we do not mark the folio as uptodate in this
> case. It is one extra line of code to propagate the kernel warning to
> userspace as well and make it much more noticeable.
right. I have no objection to returning true and skipping mark uptodate.
Just searching xa is not so useful as anyway, we have to either fallback
in mm-core or bring up large folios in zswap.
>
>
> >
> > diff --git a/include/linux/zswap.h b/include/linux/zswap.h
> > index 2a85b941db97..035e51ed89c4 100644
> > --- a/include/linux/zswap.h
> > +++ b/include/linux/zswap.h
> > @@ -36,6 +36,7 @@ void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg);
> > void zswap_lruvec_state_init(struct lruvec *lruvec);
> > void zswap_folio_swapin(struct folio *folio);
> > bool is_zswap_enabled(void);
> > +bool is_zswap_ever_enabled(void);
> > #else
> >
> > struct zswap_lruvec_state {};
> > @@ -65,6 +66,10 @@ static inline bool is_zswap_enabled(void)
> > return false;
> > }
> >
> > +static inline bool is_zswap_ever_enabled(void)
> > +{
> > + return false;
> > +}
> > #endif
> >
> > #endif /* _LINUX_ZSWAP_H */
> > diff --git a/mm/zswap.c b/mm/zswap.c
> > index b9b35ef86d9b..bf2da5d37e47 100644
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -86,6 +86,9 @@ static int zswap_setup(void);
> > static bool zswap_enabled = IS_ENABLED(CONFIG_ZSWAP_DEFAULT_ON);
> > static int zswap_enabled_param_set(const char *,
> > const struct kernel_param *);
> > +
> > +static bool zswap_ever_enable;
> > +
> > static const struct kernel_param_ops zswap_enabled_param_ops = {
> > .set = zswap_enabled_param_set,
> > .get = param_get_bool,
> > @@ -136,6 +139,11 @@ bool is_zswap_enabled(void)
> > return zswap_enabled;
> > }
> >
> > +bool is_zswap_ever_enabled(void)
> > +{
> > + return zswap_enabled || zswap_ever_enabled;
> > +}
> > +
> > /*********************************
> > * data structures
> > **********************************/
> > @@ -1734,6 +1742,7 @@ static int zswap_setup(void)
> > pr_info("loaded using pool %s/%s\n", pool->tfm_name,
> > zpool_get_type(pool->zpools[0]));
> > list_add(&pool->list, &zswap_pools);
> > + zswap_ever_enabled = true;
> > zswap_has_pool = true;
> > } else {
> > pr_err("pool creation failed\n");
> >
Thanks
Barry
next prev parent reply other threads:[~2024-06-11 0:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 2:36 Yosry Ahmed
2024-06-08 3:13 ` Barry Song
2024-06-10 17:42 ` Yosry Ahmed
2024-06-10 20:05 ` Barry Song
2024-06-10 20:11 ` Yosry Ahmed
2024-06-10 21:00 ` Barry Song
2024-06-10 21:11 ` Yosry Ahmed
2024-06-10 23:34 ` Barry Song
2024-06-10 23:41 ` Yosry Ahmed
2024-06-11 0:02 ` Barry Song [this message]
2024-06-08 4:08 ` Mika Penttilä
2024-06-10 17:35 ` Yosry Ahmed
2024-06-11 4:14 ` Mika Penttilä
2024-06-11 15:47 ` Yosry Ahmed
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='CAGsJ_4zCuwi52BU3sW2tFj67NsxapQoS=g76QHwRo=R1i5ZBCA@mail.gmail.com' \
--to=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--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