From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 046E6466B77 for ; Tue, 31 Mar 2026 22:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774995638; cv=none; b=ulwXTsSqRlVVv6Bhei6bpsts/CaCMV5jmMaBuvZxP7GPTbR2Ag1aKkTvhN3f86Gjrt+pxROc1QkT8vCcc7046TQXanfDrbJwqDs6YTwx/w2vEC0be0VymWYjtrxGAGjMCq4IRMbeRhndMoIZ3B09kYMCpS2z6QG3xCeZDKWUhxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774995638; c=relaxed/simple; bh=PBYG0pWHxZFX6ogNfSINx2OG3C0A5CXzU94xd8DQVok=; h=Date:To:From:Subject:Message-Id; b=uxC8/MhQjihyt4hJ7NjglSLgDGvxpEa96cOUP2Dna4L88AaU5Wl0n+VBEaGqusTuD/4PWOOMlSTKe0lDCiRPKxuwviGOaZ/PH7Oni5tdnymnD4QCIa5ylXI1O9MUosdZ2Xu/tCnd+rnFPLJH4MGlZRSNSOe9E2ogijZzU05JjWc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=GA3rOCJ9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="GA3rOCJ9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AA9EC19423; Tue, 31 Mar 2026 22:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774995637; bh=PBYG0pWHxZFX6ogNfSINx2OG3C0A5CXzU94xd8DQVok=; h=Date:To:From:Subject:From; b=GA3rOCJ9i5ti7Jh7tNok35UmDT4nuLW3cvkd/a1qbCLDzNk0hNrQdWSa5hFeAkb1V Rqn+D1i5nGoGIQ++MOdMa5E0VaO+NUkG2+2NEcBX+NGV5KH5uUnykiwzgj3I4ZXrQy xCbt5OvpQSzZ+3tcEI697l+SZn7TVDNyuH1MiXe0= Date: Tue, 31 Mar 2026 15:20:37 -0700 To: mm-commits@vger.kernel.org,yosry@kernel.org,kanchanapsridhar2026@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-zswap-remove-redundant-checks-in-zswap_cpu_comp_dead.patch added to mm-unstable branch Message-Id: <20260331222037.8AA9EC19423@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm: zswap: remove redundant checks in zswap_cpu_comp_dead() has been added to the -mm mm-unstable branch. Its filename is mm-zswap-remove-redundant-checks-in-zswap_cpu_comp_dead.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-zswap-remove-redundant-checks-in-zswap_cpu_comp_dead.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "Kanchana P. Sridhar" Subject: mm: zswap: remove redundant checks in zswap_cpu_comp_dead() Date: Tue, 31 Mar 2026 11:33:50 -0700 Patch series "zswap pool per-CPU acomp_ctx simplifications", v3. 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. This patch (of 2): There are presently redundant checks on the per-CPU acomp_ctx and it's "req" member in zswap_cpu_comp_dead(): redundant because they are inconsistent with zswap_pool_create() handling of failure in allocating the acomp_ctx, and with the expected NULL return value from the acomp_request_alloc() API when it fails to allocate an acomp_req. Fix these by converting to them to be NULL checks. Add comments in zswap_cpu_comp_prepare() clarifying the expected return values of the crypto_alloc_acomp_node() and acomp_request_alloc() API. Link: https://lkml.kernel.org/r/20260331183351.29844-2-kanchanapsridhar2026@gmail.com Link: https://patchwork.kernel.org/project/linux-mm/list/?series=1046677 Signed-off-by: Kanchana P. Sridhar Suggested-by: Yosry Ahmed Acked-by: Yosry Ahmed Signed-off-by: Andrew Morton --- mm/zswap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/mm/zswap.c~mm-zswap-remove-redundant-checks-in-zswap_cpu_comp_dead +++ a/mm/zswap.c @@ -749,6 +749,10 @@ static int zswap_cpu_comp_prepare(unsign goto fail; } + /* + * In case of an error, crypto_alloc_acomp_node() returns an + * error pointer, never NULL. + */ acomp = crypto_alloc_acomp_node(pool->tfm_name, 0, 0, cpu_to_node(cpu)); if (IS_ERR(acomp)) { pr_err("could not alloc crypto acomp %s : %pe\n", @@ -757,6 +761,7 @@ static int zswap_cpu_comp_prepare(unsign goto fail; } + /* acomp_request_alloc() returns NULL in case of an error. */ req = acomp_request_alloc(acomp); if (!req) { pr_err("could not alloc crypto acomp_request %s\n", @@ -802,7 +807,7 @@ static int zswap_cpu_comp_dead(unsigned struct crypto_acomp *acomp; u8 *buffer; - if (IS_ERR_OR_NULL(acomp_ctx)) + if (!acomp_ctx) return 0; mutex_lock(&acomp_ctx->mutex); @@ -817,8 +822,11 @@ static int zswap_cpu_comp_dead(unsigned /* * Do the actual freeing after releasing the mutex to avoid subtle * locking dependencies causing deadlocks. + * + * If there was an error in allocating @acomp_ctx->req, it + * would be set to NULL. */ - if (!IS_ERR_OR_NULL(req)) + if (req) acomp_request_free(req); if (!IS_ERR_OR_NULL(acomp)) crypto_free_acomp(acomp); _ Patches currently in -mm which might be from kanchanapsridhar2026@gmail.com are mm-zswap-remove-redundant-checks-in-zswap_cpu_comp_dead.patch mm-zswap-tie-per-cpu-acomp_ctx-lifetime-to-the-pool.patch