]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: zswap: move allocations during CPU init outside the lock
authorYosry Ahmed <yosryahmed@google.com>
Mon, 13 Jan 2025 21:44:58 +0000 (21:44 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 16 Jan 2025 05:15:43 +0000 (21:15 -0800)
commit779b9955f64327c339a16f68055af98252fd3315
tree9b798f6e5170ad885db4f4fbc8d254057e40fa10
parentf1897f2f08b28ae59476d8b73374b08f856973af
mm: zswap: move allocations during CPU init outside the lock

In zswap_cpu_comp_prepare(), allocations are made and assigned to various
members of acomp_ctx under acomp_ctx->mutex.  However, allocations may
recurse into zswap through reclaim, trying to acquire the same mutex and
deadlocking.

Move the allocations before the mutex critical section.  Only the
initialization of acomp_ctx needs to be done with the mutex held.

Link: https://lkml.kernel.org/r/20250113214458.2123410-1-yosryahmed@google.com
Fixes: 12dcb0ef5406 ("mm: zswap: properly synchronize freeing resources during CPU hotunplug")
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zswap.c