[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8n6vA9BjNlIICss@google.com>
Date: Thu, 6 Mar 2025 19:42:52 +0000
From: Yosry Ahmed <yosry.ahmed@...ux.dev>
To: Kanchana P Sridhar <kanchana.p.sridhar@...el.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, hannes@...xchg.org,
nphamcs@...il.com, chengming.zhou@...ux.dev, usamaarif642@...il.com,
ryan.roberts@....com, 21cnbao@...il.com,
ying.huang@...ux.alibaba.com, akpm@...ux-foundation.org,
linux-crypto@...r.kernel.org, herbert@...dor.apana.org.au,
davem@...emloft.net, clabbe@...libre.com, ardb@...nel.org,
ebiggers@...gle.com, surenb@...gle.com, kristen.c.accardi@...el.com,
wajdi.k.feghali@...el.com, vinodh.gopal@...el.com
Subject: Re: [PATCH v8 12/14] mm: zswap: Simplify acomp_ctx resource
allocation/deletion and mutex lock usage.
On Mon, Mar 03, 2025 at 12:47:22AM -0800, Kanchana P Sridhar wrote:
> This patch modifies the acomp_ctx resources' lifetime to be from pool
> creation to deletion. A "bool __online" and "u8 nr_reqs" are added to
> "struct crypto_acomp_ctx" which simplify a few things:
>
> 1) zswap_pool_create() will initialize all members of each percpu acomp_ctx
> to 0 or NULL and only then initialize the mutex.
> 2) CPU hotplug will set nr_reqs to 1, allocate resources and set __online
> to true, without locking the mutex.
> 3) CPU hotunplug will lock the mutex before setting __online to false. It
> will not delete any resources.
> 4) acomp_ctx_get_cpu_lock() will lock the mutex, then check if __online
> is true, and if so, return the mutex for use in zswap compress and
> decompress ops.
> 5) CPU onlining after offlining will simply check if either __online or
> nr_reqs are non-0, and return 0 if so, without re-allocating the
> resources.
> 6) zswap_pool_destroy() will call a newly added zswap_cpu_comp_dealloc() to
> delete the acomp_ctx resources.
> 7) Common resource deletion code in case of zswap_cpu_comp_prepare()
> errors, and for use in zswap_cpu_comp_dealloc(), is factored into a new
> acomp_ctx_dealloc().
>
> The CPU hot[un]plug callback functions are moved to "pool functions"
> accordingly.
>
> The per-cpu memory cost of not deleting the acomp_ctx resources upon CPU
> offlining, and only deleting them when the pool is destroyed, is as follows:
>
> IAA with batching: 64.8 KB
> Software compressors: 8.2 KB
I am assuming this is specifically on x86_64, so let's call that out.
Powered by blists - more mailing lists