Re: [PATCH v1 7/8] mm: zswap: Optimally place members of struct zswap_pool, struct zswap_entry.
From: Yosry Ahmed
Date: Thu Oct 15 2026 - 18:06:33 EST
On Thu, Oct 15, 2026 at 2:49 PM Kanchana P. Sridhar
<kanchanapsridhar2026@xxxxxxxxx> wrote:
>
> On Wed, Oct 14, 2026 at 8:43 AM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> >
> > On Thu, Oct 08, 2026 at 11:28:13AM -0700, Kanchana P. Sridhar wrote:
> > > Place and align the members of struct zswap_pool and struct zswap_entry
> > > such that members used together in compress/decompress hot paths are
> > > able to share the same cacheline. Minimize holes within these structs
> > > while doing so.
> > >
> > > Signed-off-by: Kanchana P. Sridhar <kanchanapsridhar2026@xxxxxxxxx>
> > > ---
> > > mm/zswap.c | 10 +++++-----
> > > 1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/mm/zswap.c b/mm/zswap.c
> > > index 8ae67fd10522..ade84ac4076e 100644
> > > --- a/mm/zswap.c
> > > +++ b/mm/zswap.c
> > > @@ -160,11 +160,11 @@ struct crypto_acomp_ctx {
> > > struct zswap_pool {
> > > struct zs_pool *zs_pool;
> > > struct crypto_acomp_ctx __percpu *acomp_ctx;
> > > - u8 compr_batch_size;
> > > struct percpu_ref ref;
> > > - struct rcu_work release_rwork;
> > > - struct hlist_node node;
> > > u8 idx;
> > > + u8 compr_batch_size;
> > > + struct hlist_node node;
> > > + struct rcu_work release_rwork;
> >
> > compr_batch_size is added by this series, why not just add it before idx
> > to begin with?
>
> In patch 0006, where compr_batch_size is introduced, I was attempting
> to place it in the same cacheline as the acomp_ctx. This increased the
> size of struct zswap_pool to 248 bytes. I later optimized this in
> patch 0007, bringing back the size to 240 with the addition of
> compr_batch_size.
This doesn't make much sense, and the size of zswap_pool is not that
important (usually only one globally). I would drop the patch and add
compr_batch_size directly where it needs to end up.