From: "Sridhar, Kanchana P" <kanchana.p.sridhar@intel.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
"yosry.ahmed@linux.dev" <yosry.ahmed@linux.dev>,
"chengming.zhou@linux.dev" <chengming.zhou@linux.dev>,
"usamaarif642@gmail.com" <usamaarif642@gmail.com>,
"ryan.roberts@arm.com" <ryan.roberts@arm.com>,
"21cnbao@gmail.com" <21cnbao@gmail.com>,
"ying.huang@linux.alibaba.com" <ying.huang@linux.alibaba.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
"Feghali, Wajdi K" <wajdi.k.feghali@intel.com>,
"Gopal, Vinodh" <vinodh.gopal@intel.com>,
"Sridhar, Kanchana P" <kanchana.p.sridhar@intel.com>
Subject: RE: [PATCH v1 2/2] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources.
Date: Mon, 7 Jul 2025 23:59:33 +0000 [thread overview]
Message-ID: <PH7PR11MB8121BAECEF741F0D9AD8AF33C94FA@PH7PR11MB8121.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAKEwX=OLk308EDSc4ApXnuQYbR4_-Vi9Ca9rJ3dgRwV+Airz_Q@mail.gmail.com>
> -----Original Message-----
> From: Nhat Pham <nphamcs@gmail.com>
> Sent: Monday, July 7, 2025 2:36 PM
> To: Sridhar, Kanchana P <kanchana.p.sridhar@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-mm@kvack.org;
> hannes@cmpxchg.org; yosry.ahmed@linux.dev; chengming.zhou@linux.dev;
> usamaarif642@gmail.com; ryan.roberts@arm.com; 21cnbao@gmail.com;
> ying.huang@linux.alibaba.com; akpm@linux-foundation.org;
> senozhatsky@chromium.org; Feghali, Wajdi K <wajdi.k.feghali@intel.com>;
> Gopal, Vinodh <vinodh.gopal@intel.com>
> Subject: Re: [PATCH v1 2/2] mm: zswap: Consistently use IS_ERR_OR_NULL()
> to check acomp_ctx resources.
>
> On Mon, Jul 7, 2025 at 1:13 PM Kanchana P Sridhar
> <kanchana.p.sridhar@intel.com> wrote:
> >
> > This patch uses IS_ERR_OR_NULL() in zswap_cpu_comp_prepare() to check
> > for valid acomp/req, thereby making it consistent with acomp_ctx_dealloc().
>
> Is acomp_ctx_dealloc() introduced by the other patch series? I can't
> seem to find it.
Saw your follow-up response :)
>
> Also, why IS_ERR_OR_NULL() in the first place. Can
> crypto_alloc_acomp_node() returns NULL?
This is based on this earlier comment [1] from Yosry, when reviewing v8.
[1] https://patchwork.kernel.org/comment/26282128/
Since my commit was refactoring the code from zswap_cpu_comp_dead()
into the new acomp_ctx_dealloc(), my implementation of acomp_ctx_dealloc()
preserved the IS_ERR_OR_NULL() checks on acomp_ctx, req and acomp from
the existing implementation of zswap_cpu_comp_dead().
With this patch-series, the resulting acomp_ctx_dealloc() is called from:
1) zswap_cpu_comp_prepare() when an error is encountered,
2) zswap_pool_create() when an error is encountered, and
3) from zswap_pool_destroy().
Hope this clarifies the context some more.
Thanks,
Kanchana
>
> >
> > Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
> > ---
> > mm/zswap.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/zswap.c b/mm/zswap.c
> > index 7970bd67f010..efd501a7fe29 100644
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -893,7 +893,7 @@ static int zswap_cpu_comp_prepare(unsigned int
> cpu, struct hlist_node *node)
> > return ret;
> >
> > acomp_ctx->acomp = crypto_alloc_acomp_node(pool->tfm_name, 0, 0,
> cpu_to_node(cpu));
> > - if (IS_ERR(acomp_ctx->acomp)) {
> > + if (IS_ERR_OR_NULL(acomp_ctx->acomp)) {
> > pr_err("could not alloc crypto acomp %s : %ld\n",
> > pool->tfm_name, PTR_ERR(acomp_ctx->acomp));
> > ret = PTR_ERR(acomp_ctx->acomp);
> > @@ -902,7 +902,7 @@ static int zswap_cpu_comp_prepare(unsigned int
> cpu, struct hlist_node *node)
> > acomp_ctx->is_sleepable = acomp_is_async(acomp_ctx->acomp);
> >
> > acomp_ctx->req = acomp_request_alloc(acomp_ctx->acomp);
> > - if (!acomp_ctx->req) {
> > + if (IS_ERR_OR_NULL(acomp_ctx->req)) {
> > pr_err("could not alloc crypto acomp_request %s\n",
> > pool->tfm_name);
> > goto fail;
> > --
> > 2.27.0
> >
prev parent reply other threads:[~2025-07-07 23:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 20:13 [PATCH v1 0/2] zswap per-CPU acomp_ctx resources track the pool's lifetime Kanchana P Sridhar
2025-07-07 20:13 ` [PATCH v1 1/2] mm: zswap: Per-CPU acomp_ctx resources exist from pool creation to deletion Kanchana P Sridhar
2025-07-07 22:06 ` Al Viro
2025-07-08 0:03 ` Sridhar, Kanchana P
2025-07-07 20:13 ` [PATCH v1 2/2] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources Kanchana P Sridhar
2025-07-07 21:36 ` Nhat Pham
2025-07-07 21:36 ` Nhat Pham
2025-07-07 23:59 ` Sridhar, Kanchana P [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=PH7PR11MB8121BAECEF741F0D9AD8AF33C94FA@PH7PR11MB8121.namprd11.prod.outlook.com \
--to=kanchana.p.sridhar@intel.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--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=senozhatsky@chromium.org \
--cc=usamaarif642@gmail.com \
--cc=vinodh.gopal@intel.com \
--cc=wajdi.k.feghali@intel.com \
--cc=ying.huang@linux.alibaba.com \
--cc=yosry.ahmed@linux.dev \
/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