mm/zswap.c | 182 +++++++++++++++++++++++++---------------------------- 1 file changed, 85 insertions(+), 97 deletions(-)
This patchset first removes redundant checks on the acomp_ctx and its "req" member in zswap_cpu_comp_dead(). Next, it persists the zswap pool's per-CPU acomp_ctx resources to last until the pool is destroyed. It then simplifies the per-CPU acomp_ctx mutex locking in zswap_compress()/zswap_decompress(). Code comments added after allocation and before checking to deallocate the per-CPU acomp_ctx's members, based on expected crypto API return values and zswap changes this patchset makes. Patch 2 is an independent submission of patch 23 from [1], to facilitate merging. [1]: https://patchwork.kernel.org/project/linux-mm/list/?series=1046677 Changes since v1: ================= 1) Made the changes to eliminate redundant checks on acomp_ctx/acomp_ctx->req in zswap_cpu_comp_dead(), per Yosry. 2) Renamed acomp_ctx_dealloc() to acomp_ctx_free(), per Yosry. 3) Incorporated suggestions from Yosry and Sashiko to reset the acomp_ctx's members to NULL after freeing them, to prevent UAF and double free issues. 4) Replaced v1's patch 2 with v2's patch 1. Kanchana P. Sridhar (2): mm: zswap: Remove redundant checks in zswap_cpu_comp_dead(). mm: zswap: Tie per-CPU acomp_ctx lifetime to the pool. mm/zswap.c | 182 +++++++++++++++++++++++++---------------------------- 1 file changed, 85 insertions(+), 97 deletions(-) -- 2.39.5
On Mon, 16 Mar 2026 18:48:00 -0700 "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com> wrote: > This patchset first removes redundant checks on the acomp_ctx and its > "req" member in zswap_cpu_comp_dead(). > > Next, it persists the zswap pool's per-CPU acomp_ctx resources to > last until the pool is destroyed. It then simplifies the per-CPU > acomp_ctx mutex locking in zswap_compress()/zswap_decompress(). > > Code comments added after allocation and before checking to deallocate > the per-CPU acomp_ctx's members, based on expected crypto API return > values and zswap changes this patchset makes. > > Patch 2 is an independent submission of patch 23 from [1], to > facilitate merging. Thanks. What happened with "mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources"? Still relevant? https://lkml.kernel.org/r/20260314051632.17931-3-kanchanapsridhar2026@gmail.com
On Tue, Mar 17, 2026 at 12:45 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Mon, 16 Mar 2026 18:48:00 -0700 "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com> wrote: > > > This patchset first removes redundant checks on the acomp_ctx and its > > "req" member in zswap_cpu_comp_dead(). > > > > Next, it persists the zswap pool's per-CPU acomp_ctx resources to > > last until the pool is destroyed. It then simplifies the per-CPU > > acomp_ctx mutex locking in zswap_compress()/zswap_decompress(). > > > > Code comments added after allocation and before checking to deallocate > > the per-CPU acomp_ctx's members, based on expected crypto API return > > values and zswap changes this patchset makes. > > > > Patch 2 is an independent submission of patch 23 from [1], to > > facilitate merging. > > Thanks. > > What happened with "mm: zswap: Consistently use IS_ERR_OR_NULL() to > check acomp_ctx resources"? Still relevant? > > https://lkml.kernel.org/r/20260314051632.17931-3-kanchanapsridhar2026@gmail.com We decided to drop it (and patch 1 here kinda sorta takes its place): https://lore.kernel.org/all/CACpmpoeo0LhxkoA5Wx6q+9=2scn_az0u=3bar-JgBvTA-ZBkZg@mail.gmail.com/
On Tue, Mar 17, 2026 at 12:48 PM Yosry Ahmed <yosry@kernel.org> wrote: > > On Tue, Mar 17, 2026 at 12:45 PM Andrew Morton > <akpm@linux-foundation.org> wrote: > > > > On Mon, 16 Mar 2026 18:48:00 -0700 "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com> wrote: > > > > > This patchset first removes redundant checks on the acomp_ctx and its > > > "req" member in zswap_cpu_comp_dead(). > > > > > > Next, it persists the zswap pool's per-CPU acomp_ctx resources to > > > last until the pool is destroyed. It then simplifies the per-CPU > > > acomp_ctx mutex locking in zswap_compress()/zswap_decompress(). > > > > > > Code comments added after allocation and before checking to deallocate > > > the per-CPU acomp_ctx's members, based on expected crypto API return > > > values and zswap changes this patchset makes. > > > > > > Patch 2 is an independent submission of patch 23 from [1], to > > > facilitate merging. > > > > Thanks. > > > > What happened with "mm: zswap: Consistently use IS_ERR_OR_NULL() to > > check acomp_ctx resources"? Still relevant? > > > > https://lkml.kernel.org/r/20260314051632.17931-3-kanchanapsridhar2026@gmail.com > > We decided to drop it (and patch 1 here kinda sorta takes its place): > https://lore.kernel.org/all/CACpmpoeo0LhxkoA5Wx6q+9=2scn_az0u=3bar-JgBvTA-ZBkZg@mail.gmail.com/ Thanks for the clarification, Yosry! Thanks Andrew, for adding the two patches in v2 to mm-new! Thanks also for obsoleting the "mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources" patch - we decided to replace this with the "[v2,1/2] mm: zswap: Remove redundant checks in zswap_cpu_comp_dead().", which makes the acomp_ctx consistency checks changes in the original mainline code, before refactoring that code into the new acomp_ctx_free() in "[v2,2/2] mm: zswap: Tie per-CPU acomp_ctx lifetime to the pool." Best regards, Kanchana
© 2016 - 2026 Red Hat, Inc.