[PATCH v11 19/24] crypto: iaa - IAA acomp_algs register the get_batch_size() interface.

Kanchana P Sridhar posted 24 patches 6 months, 1 week ago
There is a newer version of this series
[PATCH v11 19/24] crypto: iaa - IAA acomp_algs register the get_batch_size() interface.
Posted by Kanchana P Sridhar 6 months, 1 week ago
The Fixed ("deflate-iaa") and Dynamic ("deflate-iaa-dynamic") IAA
acomp_algs register an implementation for get_batch_size(). zswap can
query crypto_acomp_batch_size() to get the maximum number of requests
that can be batch [de]compressed. zswap can use the minimum of this, and
any zswap-specific upper limits for batch-size to allocate batching
resources.

This enables zswap to compress/decompress pages in parallel in the IAA
hardware accelerator to improve swapout/swapin performance and memory
savings.

Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
index 480e12c1d77a5..b7c6fc334dae7 100644
--- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
+++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
@@ -2785,6 +2785,7 @@ static struct acomp_alg iaa_acomp_fixed_deflate = {
 	.init			= iaa_comp_init_fixed,
 	.compress		= iaa_comp_acompress_main,
 	.decompress		= iaa_comp_adecompress_main,
+	.get_batch_size		= iaa_comp_get_max_batch_size,
 	.base			= {
 		.cra_name		= "deflate",
 		.cra_driver_name	= "deflate-iaa",
@@ -2810,6 +2811,7 @@ static struct acomp_alg iaa_acomp_dynamic_deflate = {
 	.init			= iaa_comp_init_dynamic,
 	.compress		= iaa_comp_acompress_main,
 	.decompress		= iaa_comp_adecompress_main,
+	.get_batch_size		= iaa_comp_get_max_batch_size,
 	.base			= {
 		.cra_name		= "deflate",
 		.cra_driver_name	= "deflate-iaa-dynamic",
-- 
2.27.0
Re: [PATCH v11 19/24] crypto: iaa - IAA acomp_algs register the get_batch_size() interface.
Posted by Barry Song 5 months, 2 weeks ago
On Fri, Aug 1, 2025 at 4:36 PM Kanchana P Sridhar
<kanchana.p.sridhar@intel.com> wrote:
>
> The Fixed ("deflate-iaa") and Dynamic ("deflate-iaa-dynamic") IAA
> acomp_algs register an implementation for get_batch_size(). zswap can
> query crypto_acomp_batch_size() to get the maximum number of requests
> that can be batch [de]compressed. zswap can use the minimum of this, and
> any zswap-specific upper limits for batch-size to allocate batching
> resources.
>
> This enables zswap to compress/decompress pages in parallel in the IAA
> hardware accelerator to improve swapout/swapin performance and memory
> savings.
>
> Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
> ---
>  drivers/crypto/intel/iaa/iaa_crypto_main.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> index 480e12c1d77a5..b7c6fc334dae7 100644
> --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> @@ -2785,6 +2785,7 @@ static struct acomp_alg iaa_acomp_fixed_deflate = {
>         .init                   = iaa_comp_init_fixed,
>         .compress               = iaa_comp_acompress_main,
>         .decompress             = iaa_comp_adecompress_main,
> +       .get_batch_size         = iaa_comp_get_max_batch_size,
>         .base                   = {
>                 .cra_name               = "deflate",
>                 .cra_driver_name        = "deflate-iaa",
> @@ -2810,6 +2811,7 @@ static struct acomp_alg iaa_acomp_dynamic_deflate = {
>         .init                   = iaa_comp_init_dynamic,
>         .compress               = iaa_comp_acompress_main,
>         .decompress             = iaa_comp_adecompress_main,
> +       .get_batch_size         = iaa_comp_get_max_batch_size,

I feel the patches are being split too finely and are not fully
self-contained. You added iaa_comp_get_max_batch_size in the previous
patch, but the callback appears in this one. Why not combine them
together? Anyway, since you are moving to a static field, this patch
will be removed automatically. Could you reconsider organizing v12
to make it easier for everyone to follow? :-)

Thanks
Barry
RE: [PATCH v11 19/24] crypto: iaa - IAA acomp_algs register the get_batch_size() interface.
Posted by Sridhar, Kanchana P 5 months, 2 weeks ago
> -----Original Message-----
> From: Barry Song <21cnbao@gmail.com>
> Sent: Thursday, August 28, 2025 5:17 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; nphamcs@gmail.com;
> chengming.zhou@linux.dev; usamaarif642@gmail.com;
> ryan.roberts@arm.com; ying.huang@linux.alibaba.com; akpm@linux-
> foundation.org; senozhatsky@chromium.org; linux-crypto@vger.kernel.org;
> herbert@gondor.apana.org.au; davem@davemloft.net;
> clabbe@baylibre.com; ardb@kernel.org; ebiggers@google.com;
> surenb@google.com; Accardi, Kristen C <kristen.c.accardi@intel.com>;
> Gomes, Vinicius <vinicius.gomes@intel.com>; Feghali, Wajdi K
> <wajdi.k.feghali@intel.com>; Gopal, Vinodh <vinodh.gopal@intel.com>
> Subject: Re: [PATCH v11 19/24] crypto: iaa - IAA acomp_algs register the
> get_batch_size() interface.
> 
> On Fri, Aug 1, 2025 at 4:36 PM Kanchana P Sridhar
> <kanchana.p.sridhar@intel.com> wrote:
> >
> > The Fixed ("deflate-iaa") and Dynamic ("deflate-iaa-dynamic") IAA
> > acomp_algs register an implementation for get_batch_size(). zswap can
> > query crypto_acomp_batch_size() to get the maximum number of requests
> > that can be batch [de]compressed. zswap can use the minimum of this, and
> > any zswap-specific upper limits for batch-size to allocate batching
> > resources.
> >
> > This enables zswap to compress/decompress pages in parallel in the IAA
> > hardware accelerator to improve swapout/swapin performance and
> memory
> > savings.
> >
> > Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
> > ---
> >  drivers/crypto/intel/iaa/iaa_crypto_main.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> > index 480e12c1d77a5..b7c6fc334dae7 100644
> > --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> > +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> > @@ -2785,6 +2785,7 @@ static struct acomp_alg iaa_acomp_fixed_deflate
> = {
> >         .init                   = iaa_comp_init_fixed,
> >         .compress               = iaa_comp_acompress_main,
> >         .decompress             = iaa_comp_adecompress_main,
> > +       .get_batch_size         = iaa_comp_get_max_batch_size,
> >         .base                   = {
> >                 .cra_name               = "deflate",
> >                 .cra_driver_name        = "deflate-iaa",
> > @@ -2810,6 +2811,7 @@ static struct acomp_alg
> iaa_acomp_dynamic_deflate = {
> >         .init                   = iaa_comp_init_dynamic,
> >         .compress               = iaa_comp_acompress_main,
> >         .decompress             = iaa_comp_adecompress_main,
> > +       .get_batch_size         = iaa_comp_get_max_batch_size,
> 
> I feel the patches are being split too finely and are not fully
> self-contained. You added iaa_comp_get_max_batch_size in the previous
> patch, but the callback appears in this one. Why not combine them
> together? Anyway, since you are moving to a static field, this patch
> will be removed automatically.

Yes, based on your earlier suggestion I have made the note to bundle
related patches :)

Thanks,
Kanchana