From: Yosry Ahmed <yosry.ahmed@linux.dev>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <zhouchengming@bytedance.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mm: zswap: interact directly with zsmalloc
Date: Mon, 15 Sep 2025 19:33:08 +0000 [thread overview]
Message-ID: <pduxj3r37ufwsbe2jxtx262dikjbbnwmzkagwfot5j4tajxmaf@4z3slwpmdsl4> (raw)
In-Reply-To: <20250915153640.GA828739@cmpxchg.org>
On Mon, Sep 15, 2025 at 11:36:40AM -0400, Johannes Weiner wrote:
> On Thu, Sep 11, 2025 at 02:30:31PM +0000, Yosry Ahmed wrote:
> > On Wed, Sep 10, 2025 at 09:42:40AM -0400, Johannes Weiner wrote:
> > > @@ -314,6 +314,10 @@ static struct zswap_pool *__zswap_pool_create_fallback(void)
> > > }
> > > }
> > >
> > > + /* Kconfig bug? */
> > > + if (WARN_ON(!crypto_has_acomp(zswap_compressor, 0, 0)))
> > > + return NULL;
> > > +
> > > return zswap_pool_create(zswap_compressor);
> > > }
> >
> > Sure, looks good, although I think it's clearer (and smaller diff) to
> > preserve the old structure instead, up to you:
> >
> > diff --git a/mm/zswap.c b/mm/zswap.c
> > index c88ad61b232cf..bbfc087792648 100644
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -300,18 +300,21 @@ static struct zswap_pool *zswap_pool_create(char *compressor)
> >
> > static struct zswap_pool *__zswap_pool_create_fallback(void)
> > {
> > - if (!crypto_has_acomp(zswap_compressor, 0, 0) &&
> > + bool has_comp = crypto_has_acomp(zswap_compressor, 0, 0);
> > +
> > + if (!has_comp &&
> > strcmp(zswap_compressor, CONFIG_ZSWAP_COMPRESSOR_DEFAULT)) {
> > pr_err("compressor %s not available, using default %s\n",
> > zswap_compressor, CONFIG_ZSWAP_COMPRESSOR_DEFAULT);
> > param_free_charp(&zswap_compressor);
> > zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT;
> > - if (!crypto_has_acomp(zswap_compressor, 0, 0)) {
> > - pr_err("default compressor %s not available\n",
> > - zswap_compressor);
> > - zswap_compressor = ZSWAP_PARAM_UNSET;
> > - return NULL;
> > - }
> > + has_comp = crypto_has_acomp(zswap_compressor, 0, 0);
> > + }
> > + if (!has_comp) {
> > + pr_err("default compressor %s not available\n",
> > + zswap_compressor);
> > + zswap_compressor = ZSWAP_PARAM_UNSET;
> > + return NULL;
> > }
>
> No objection to moving the branch instead of adding another one. I'd
> just like to retain the warning, since it shouldn't happen. And ditch
> the bool, IMO it pointlessly splits the test from the consequences.
>
> If you're fine with this Yosry, Andrew can you please fold it?
LGTM, with this folded:
Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Thanks!
>
> ---
>
> From b8fa4c7edd4f3c84853665b47acec8cebb4f4899 Mon Sep 17 00:00:00 2001
> From: Johannes Weiner <hannes@cmpxchg.org>
> Date: Mon, 15 Sep 2025 10:56:15 -0400
> Subject: [PATCH] mm: zswap: interact directly with zsmalloc fix
>
> Yosry points out that the default compressor check only applies when
> something else is configured and we fall back, but not if it was
> configured out of the box but isn't available. Move the test. Kconfig
> should not permit this, so replace the pr_err() with a WARN.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
> mm/zswap.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index cba7077fda40..c1af782e54ec 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -309,12 +309,12 @@ static struct zswap_pool *__zswap_pool_create_fallback(void)
> zswap_compressor, CONFIG_ZSWAP_COMPRESSOR_DEFAULT);
> param_free_charp(&zswap_compressor);
> zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT;
> - if (!crypto_has_acomp(zswap_compressor, 0, 0)) {
> - pr_err("default compressor %s not available\n",
> - zswap_compressor);
> - zswap_compressor = ZSWAP_PARAM_UNSET;
> - return NULL;
> - }
> + }
> +
> + /* Default compressor should be available. Kconfig bug? */
> + if (WARN_ON_ONCE(!crypto_has_acomp(zswap_compressor, 0, 0))) {
> + zswap_compressor = ZSWAP_PARAM_UNSET;
> + return NULL;
> }
>
> return zswap_pool_create(zswap_compressor);
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-09-15 19:33 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 16:15 [PATCH 0/3] mm: remove zpool Johannes Weiner
2025-08-29 16:15 ` [PATCH 1/3] mm: zswap: interact directly with zsmalloc Johannes Weiner
2025-09-05 18:53 ` Yosry Ahmed
2025-09-09 15:01 ` Johannes Weiner
2025-09-09 20:10 ` Yosry Ahmed
2025-09-10 13:42 ` Johannes Weiner
2025-09-11 14:30 ` Yosry Ahmed
2025-09-15 15:36 ` Johannes Weiner
2025-09-15 19:33 ` Yosry Ahmed [this message]
2025-08-29 16:15 ` [PATCH 2/3] mm: remove unused zpool layer Johannes Weiner
2025-08-29 19:07 ` SeongJae Park
2025-09-09 15:13 ` Johannes Weiner
2025-09-10 3:14 ` SeongJae Park
2025-09-05 18:58 ` Yosry Ahmed
2025-09-09 15:16 ` Johannes Weiner
2025-09-09 20:08 ` Yosry Ahmed
2025-09-09 20:09 ` Yosry Ahmed
2025-09-10 13:46 ` Johannes Weiner
2025-08-29 16:15 ` [PATCH 3/3] mm: zpdesc: minor naming and comment corrections Johannes Weiner
2025-09-05 19:05 ` Yosry Ahmed
2025-09-09 15:11 ` Johannes Weiner
2025-09-09 20:08 ` Yosry Ahmed
2025-09-04 9:33 ` [PATCH 0/3] mm: remove zpool Vitaly Wool
2025-09-04 10:13 ` Vlastimil Babka
2025-09-04 11:26 ` David Hildenbrand
2025-09-05 5:36 ` Vitaly Wool
2025-09-04 14:11 ` Vitaly Wool
2025-09-05 7:03 ` Vlastimil Babka
2025-09-05 18:02 ` Nhat Pham
2025-09-05 22:42 ` Vitaly Wool
2025-09-05 19:57 ` Yosry Ahmed
2025-09-06 5:25 ` Sergey Senozhatsky
2025-09-08 12:18 ` Sergey Senozhatsky
2025-09-09 20:12 ` Yosry Ahmed
2025-09-13 13:55 ` Vitaly Wool
2025-09-15 19:37 ` Yosry Ahmed
2025-09-16 11:16 ` Vitaly Wool
2025-09-16 3:29 ` Sergey Senozhatsky
2025-09-04 23:47 ` Andrew Morton
2025-09-05 5:42 ` Vitaly Wool
2025-09-05 18:30 ` Andrew Morton
2025-09-05 22:20 ` Vitaly Wool
2025-09-04 9:51 ` Vitaly Wool
2025-09-05 17:52 ` Nhat Pham
2025-09-05 19:45 ` Yosry Ahmed
2025-09-05 21:35 ` Nhat Pham
2025-09-09 15:03 ` Johannes Weiner
2025-09-09 20:11 ` 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=pduxj3r37ufwsbe2jxtx262dikjbbnwmzkagwfot5j4tajxmaf@4z3slwpmdsl4 \
--to=yosry.ahmed@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=zhouchengming@bytedance.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