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 v2: ================= 1) Rebased to mm-unstable as of 3-31-2026 (commit 24e341657c28). 2) Collected Acks. 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 Tue, Mar 31, 2026 at 11:34 AM 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. > > [1]: https://patchwork.kernel.org/project/linux-mm/list/?series=1046677 > > Changes since v2: > ================= > 1) Rebased to mm-unstable as of 3-31-2026 (commit 24e341657c28). > 2) Collected Acks. > > 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. Sashiko was able to apply the patches and doesn't seem to find any regressions: https://sashiko.dev/#/patchset/20260331183351.29844-1-kanchanapsridhar2026%40gmail.com.
On Tue, Mar 31, 2026 at 12:23 PM Yosry Ahmed <yosry@kernel.org> wrote: > > On Tue, Mar 31, 2026 at 11:34 AM 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. > > > > [1]: https://patchwork.kernel.org/project/linux-mm/list/?series=1046677 > > > > Changes since v2: > > ================= > > 1) Rebased to mm-unstable as of 3-31-2026 (commit 24e341657c28). > > 2) Collected Acks. > > > > 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. > > Sashiko was able to apply the patches and doesn't seem to find any > regressions: https://sashiko.dev/#/patchset/20260331183351.29844-1-kanchanapsridhar2026%40gmail.com. That's good to know, thanks for confirming Yosry!
On Tue, 31 Mar 2026 13:58:37 -0700 "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com> wrote: > > > 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. > > > > Sashiko was able to apply the patches and doesn't seem to find any > > regressions: https://sashiko.dev/#/patchset/20260331183351.29844-1-kanchanapsridhar2026%40gmail.com. > > That's good to know, thanks for confirming Yosry! Thanks, both. I'm surprised that a patchset of this signficance got through AI review without comment, actually. I've confirmed that the code changes in v3 are identical to those in v2, which I removed a couple of days ago for Sashiko's benefit. v2 was added to mm.git March 16. So all good, I've re-added this series.
On Tue, Mar 31, 2026 at 3:19 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Tue, 31 Mar 2026 13:58:37 -0700 "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com> wrote: > > > > > 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. > > > > > > Sashiko was able to apply the patches and doesn't seem to find any > > > regressions: https://sashiko.dev/#/patchset/20260331183351.29844-1-kanchanapsridhar2026%40gmail.com. > > > > That's good to know, thanks for confirming Yosry! > > Thanks, both. > > I'm surprised that a patchset of this signficance got through AI review > without comment, actually. Thanks Andrew! I must thank Yosry because he pointed out end cases that helped make the solution more fail-safe. I am also very impressed by Sashiko's thorough analysis. > > I've confirmed that the code changes in v3 are identical to those in > v2, which I removed a couple of days ago for Sashiko's benefit. v2 was > added to mm.git March 16. So all good, I've re-added this series. Sounds great, thanks again! Best regards, Kanchana > >
© 2016 - 2026 Red Hat, Inc.