RE: [PATCH v3 11/13] mm: zswap: Allocate acomp_batch_ctx resources for a given zswap_pool.

Sridhar, Kanchana P
2024-11-07T22:22:18Z

> -----Original Message-----
> From: Johannes Weiner <hannes@cmpxchg.org>
> Sent: Thursday, November 7, 2024 9:31 AM
> To: Sridhar, Kanchana P <kanchana.p.sridhar@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-mm@kvack.org;
> yosryahmed@google.com; nphamcs@gmail.com;
> chengming.zhou@linux.dev; usamaarif642@gmail.com;
> ryan.roberts@arm.com; Huang, Ying <ying.huang@intel.com>;
> 21cnbao@gmail.com; akpm@linux-foundation.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>; zanussi@kernel.org; Feghali, Wajdi K
> <wajdi.k.feghali@intel.com>; Gopal, Vinodh <vinodh.gopal@intel.com>
> Subject: Re: [PATCH v3 11/13] mm: zswap: Allocate acomp_batch_ctx
> resources for a given zswap_pool.
>
> On Wed, Nov 06, 2024 at 11:21:03AM -0800, Kanchana P Sridhar wrote:
> > If the zswap_pool is associated with an acomp_alg/crypto_acomp that has
> > registered batch_compress() and batch_decompress() API, we can allocate
> the
> > necessary batching resources for the pool's acomp_batch_ctx.
> >
> > This patch makes the above determination on incurring the per-cpu memory
> > footprint cost for batching, and if so, goes ahead and allocates
> > SWAP_CRYPTO_BATCH_SIZE (i.e. 8) acomp_reqs/buffers for the
> > pool->acomp_batch_ctx on that specific cpu.
> >
> > It also "remembers" the pool's batching readiness as a result of the above,
> > through a new
> >
> > enum batch_comp_status can_batch_comp;
> >
> > member added to struct zswap_pool, for fast retrieval during
> > zswap_store().
> >
> > This allows us a way to only incur the memory footprint cost of the
> > pool->acomp_batch_ctx resources for a given cpu on which zswap_store()
> > needs to process a large folio.
> >
> > Suggested-by: Yosry Ahmed <yosryahmed@google.com>
> > Suggested-by: Ying Huang <ying.huang@intel.com>
> > Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
>
> A general observation: this is a lot of code for a hardware specific
> feature that many CPUs and architectures do not support. Please keep
> the code self-contained, and wrap struct members and functions in a
> new CONFIG option, so that not everybody has to compile this in.

Thanks for this suggestion! Sure, I will address this in v4.

Thanks,
Kanchana