From nobody Sat Feb 7 23:23:26 2026 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 AD41C23DEB6 for ; Fri, 3 Oct 2025 20:38:55 +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=1759523935; cv=none; b=eCs0/jI/v84hP34ygcqQrzvDqyy3WyIIz8bG9fg2Ycn1obWuWSwsC6fFqRlYPNB+9rn5qMhhnaWlM5kwNFYrN1vTfRILDsselXVZvSCwdWmX7SMKBXRh3W7uNRo2T7lmVfO3wASVMeVsx0KU1OkXswEusCVRTg4UVAyjvxiB3HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759523935; c=relaxed/simple; bh=QYf5NoN4iCNnsX/4rgyF4h8KGvpOZHNtyc2i/D4d3Fg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rw0AXqyBBjhMKzrBN2+sKWi/yjMrG9bSsmOwwFdGPfmCBeI8SA/eNc55kOhWiXqPnBXY1Xllzkg5VGJb2IKqc89FcFPjXz6axN5RmPT4QScoowAB9r2qkHjwLoOo3lHc5mTSKlT5tdBcQsAdmBF2v2E+Sxy7KcUGDXSriqEakQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dVv4/lhP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dVv4/lhP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FD7FC4CEFA; Fri, 3 Oct 2025 20:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759523935; bh=QYf5NoN4iCNnsX/4rgyF4h8KGvpOZHNtyc2i/D4d3Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVv4/lhP7CXRVGS6gZXty6SM2CuqqWMtV94l7WDc//YwsLdWRvA9OSEMFefrhAIc8 eD+0MkFrUaBHnOFc9MuMxvL1iv/8mtrG8Ant8Og95++U6GIAgmNKogDidifzS0tHlJ Qq3b3jfvhfLTtBfMV94YLQ6Y3hwNn1ZBNk9jjHiFhOwXOWUYPudbac5AyJaX6QC+4g tY9+XyBWcrd7FuttcbI76cyHxqzDkf1l8ZwzoyXp/dM0VPZutwFpp0yKW33ddZzQhP EH/lKPXUi64pNrLFlO9IYbWvxwLUsAkbVfTSleDoDk04Cwd7/XjIobzm7g7poJJcIa DEmVG9WD9KLeA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Chengming Zhou , Johannes Weiner , Nhat Pham , Yosry Ahmed , kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/4] mm/zswap: remove unnecessary dlen writes for incompressible pages Date: Fri, 3 Oct 2025 13:38:48 -0700 Message-Id: <20251003203851.43128-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251003203851.43128-1-sj@kernel.org> References: <20251003203851.43128-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Incompressible pages handling logic in zswap_compress() is setting 'dlen' as PAGE_SIZE twice. Once before deciding whether to save the content as is, and once again after it is decided to save it as is. But the value of 'dlen' is used only if it is decided to save the content as is, so the first write is unnecessary. It is not causing real user issues, but making code confusing to read. Remove the unnecessary write operation. Signed-off-by: SeongJae Park Acked-by: Nhat Pham Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- mm/zswap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index c1af782e54ec..80619c8589a7 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -894,7 +894,6 @@ static bool zswap_compress(struct page *page, struct zs= wap_entry *entry, * to the active LRU list in the case. */ if (comp_ret || !dlen || dlen >=3D PAGE_SIZE) { - dlen =3D PAGE_SIZE; if (!mem_cgroup_zswap_writeback_enabled( folio_memcg(page_folio(page)))) { comp_ret =3D comp_ret ? comp_ret : -EINVAL; --=20 2.39.5 From nobody Sat Feb 7 23:23:26 2026 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 598DE2459C6; Fri, 3 Oct 2025 20:38:56 +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=1759523936; cv=none; b=dFPEqdPnSyg3t4EwBR0buX3hb3x5qQAmaoQwB2U9/WJHuunlJ7yPyH42UCFPnxkUwmE0/6GWzDtmGqdvZFhHq4K7Zq9gJuKBqFVZ6UPZeCD7RGTfPr54SZc/dY9/dSRjyDykAp38/FhpuLrXuOdEWZMnAiLs9qdNYW5orxhVOfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759523936; c=relaxed/simple; bh=AeleWDuyUJnZpkc4cw1hO6AX2XUTuOPcOCcE8L+UJic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qZkShCx66SprrDrm7JO3zC6Dnqg/IbRmR+K/kZxCtJEgCeZAL1C6yWHYAtYCua7PSlYSVf8dVtibUvajHb68vKwSerKJxGYr0tkCStS6gbd0+lHER87Q0OQMvnms6sY/F9ixCeXIRU5V/zK0poV6n/TXMBmWWdJPgQfI8ykmGJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S4L3F+p0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S4L3F+p0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 150B2C4CEF5; Fri, 3 Oct 2025 20:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759523936; bh=AeleWDuyUJnZpkc4cw1hO6AX2XUTuOPcOCcE8L+UJic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4L3F+p0Ttkg83PfSG5zfqt7CI7+pPYaDjiPpSuK35EUoIoIVcuv6V3Srzu1o/oKT 9k5MNgcTUyTGP/6F/niObr5CU6kwDh1uTRUkFuXkatr32bordchdMQnkRl0y094nju eTi74st4JX/ZgYbTKIZ1GzKKL6KGtwE5YbGha4Hdwmh549xHD5PF9gkls4rkvCnAvD /4S6BzjJ4j7n+OEb1uZ6TWMF/GML3AsDTMWqhK9ESVCCjPXLQssq9I/yNoc0wl8jxO MjAoh0wHLzU652q6+EVeUyv5+wU4eC/gUVoPHunRMdBcZm25AoUQu1TZMn3rqkYwU0 JlYwX08bTtpVg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Chengming Zhou , Johannes Weiner , Michal Hocko , Muchun Song , Nhat Pham , Roman Gushchin , Shakeel Butt , Yosry Ahmed , cgroups@vger.kernel.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] mm/zswap: fix typos: s/zwap/zswap/ Date: Fri, 3 Oct 2025 13:38:49 -0700 Message-Id: <20251003203851.43128-3-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251003203851.43128-1-sj@kernel.org> References: <20251003203851.43128-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the subject says. Signed-off-by: SeongJae Park Acked-by: Nhat Pham Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- mm/memcontrol.c | 2 +- mm/zswap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 69c970554e85..74b1bc2252b6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5421,7 +5421,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg) * @size: size of compressed object * * This forces the charge after obj_cgroup_may_zswap() allowed - * compression and storage in zwap for this cgroup to go ahead. + * compression and storage in zswap for this cgroup to go ahead. */ void obj_cgroup_charge_zswap(struct obj_cgroup *objcg, size_t size) { diff --git a/mm/zswap.c b/mm/zswap.c index 80619c8589a7..f6b1c8832a4f 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -879,7 +879,7 @@ static bool zswap_compress(struct page *page, struct zs= wap_entry *entry, * acomp instance, then get those requests done simultaneously. but in th= is * case, zswap actually does store and load page by page, there is no * existing method to send the second page before the first page is done - * in one thread doing zwap. + * in one thread doing zswap. * but in different threads running on different cpu, we have different * acomp instance, so multiple threads can do (de)compression in parallel. */ @@ -1128,7 +1128,7 @@ static enum lru_status shrink_memcg_cb(struct list_he= ad *item, struct list_lru_o * * 1. We extract the swp_entry_t to the stack, allowing * zswap_writeback_entry() to pin the swap entry and - * then validate the zwap entry against that swap entry's + * then validate the zswap entry against that swap entry's * tree using pointer value comparison. Only when that * is successful can the entry be dereferenced. * --=20 2.39.5 From nobody Sat Feb 7 23:23:26 2026 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 6EEE324EAB1 for ; Fri, 3 Oct 2025 20:38:57 +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=1759523937; cv=none; b=OJxSOdd3YrguzzPht7XqefN0rKuVGkEKlOu4Ah7F7BR1STbtGv8oP5La89udXIFlP7QdAPCSVbMYvueD7f78lBE60FzB0QDH50U3PpuLBGzYuki5nxiKk2419T2HRfQlm1U6HJhgyCZWoUQ3U2xGvgbp7M8Sbyxjgt5xlsmrzoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759523937; c=relaxed/simple; bh=NgT9HuawGnR8STlvRUNA5Z4q86GZ1SZe6LmbwqF2RCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jqXO0x2zVsP8v4qL4SFbX8MQXG4wdweg5pxPbK0O1y2PYUZGsxG0905yDfwZvvnm54+NFtVgW7JfJJ5xa7XpqZonRWRsuOjovxvtrUQMG0GWAUtskgg1/S23jrFAYDOJbG1E45VcCcNYYqMqUXp0n1C2KAiF9K7hfb2sWGVfZBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J5WhN/8/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J5WhN/8/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29012C4CEFA; Fri, 3 Oct 2025 20:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759523937; bh=NgT9HuawGnR8STlvRUNA5Z4q86GZ1SZe6LmbwqF2RCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J5WhN/8/0/J9r/s9eimc704yu7UUGyVuANQo1hLuh6QEm1xUCf3itmIaTm9dMmk/x K4DCJnrUJ/SPeFUe1tRkOJ3zKRJe7Zs9XJwduKRZPGyFM6p2ae3syfmcP5VZxJiaj+ VzCVZlk3QUZVyskHaD1GEzX6V+juOdDk5WQoi5rZ328Zd/firom/7VV0tB42+wmzpo 2qUVzVWfUuSo7JorfDCq4TQjXBeTJM9YUQBDAHGGm6e8BNgwbxzzIvqoxxTNC/uMcB BEzykhLqaJl4+qFaSsuDrn8J+EiR8WuKD6ti2MiR+qPP5qeye0NwL71X1aY+GnvdMd 7BxpTAm2uqQzw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Chengming Zhou , Johannes Weiner , Nhat Pham , Yosry Ahmed , kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/4] mm/zswap: s/red-black tree/xarray/ Date: Fri, 3 Oct 2025 13:38:50 -0700 Message-Id: <20251003203851.43128-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251003203851.43128-1-sj@kernel.org> References: <20251003203851.43128-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Changes made by commit 796c2c23e14e ("zswap: replace RB tree with xarray") is not reflected on a comment. Update the comment. Signed-off-by: SeongJae Park Acked-by: Nhat Pham Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index f6b1c8832a4f..5d0f8b13a958 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -175,7 +175,7 @@ static struct shrinker *zswap_shrinker; * This structure contains the metadata for tracking a single compressed * page within zswap. * - * swpentry - associated swap entry, the offset indexes into the red-black= tree + * swpentry - associated swap entry, the offset indexes into the xarray * length - the length in bytes of the compressed page data. Needed during * decompression. * referenced - true if the entry recently entered the zswap pool. Unset b= y the --=20 2.39.5 From nobody Sat Feb 7 23:23:26 2026 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 E72E6257853; Fri, 3 Oct 2025 20:38:58 +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=1759523939; cv=none; b=LNVKgKr2zjjmY6Czowmv13hSJUcVq8bCl1lAnIUXxTlBiwek9lrgsV2lf1alZCYX2hyecRFNwPHTqyEQiA134elWXM+THBCbBGXiPAUVud0PdLwgde0uD3zf3kYqn9mLEvq4oWPiwPUrmcaCkZhQbxzcV88r8b41qmHBaToHQA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759523939; c=relaxed/simple; bh=ZzB74e8fLVOerMDvAZBDXxkrkPTdnq0MummdffmxbJQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G0A7aAjL6WbpbIrbPkxphpFMJC2J0GTz2stiZMHh/PXqdDKQm7UgpMm+36ct6AvJzom5A0IcnaCxZYEikzi3If3ldJy9HeNhKaTn7X2SWJhn6oGbV+UR3X3phd/9Ni/vq+OesgyFMFfcgxiDBEMxGxvwYAif7+f1fB4OqQvJ+Ns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M4+iEoqp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M4+iEoqp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4037FC4CEF5; Fri, 3 Oct 2025 20:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759523938; bh=ZzB74e8fLVOerMDvAZBDXxkrkPTdnq0MummdffmxbJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M4+iEoqpATZKahzganyMTsVKl1kJ/wiQ8Px8RLzYdqh37tRpnjf8uOl3qaMEL7pXh x6Omcw0vWP61pTvKgdbVG4UQgRqnNy63jcSGLu95EnAnANKV/y3oezHWVN0XVtlnDn vsni74areUTyOWzbC4zHIDP0PSdxtqmpx45wohX2Hq3tW5fknR4t0/snPQ1jgktqKs kFbhSneQRpzrwMXrOqys6faN4d65Ai/1HsxjyGMC7Qjc30QeOzNT2U/IxEK7PYpRK1 hWiAPQk+/4yVV/43rRDfVYP5fmu9cbh5rI8HJSeyg0i48Z+MVm/jABJDTBkU9IMMKx 5OPN0qtXCQ7ZA== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , Chengming Zhou , David Hildenbrand , Johannes Weiner , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Nhat Pham , Suren Baghdasaryan , Vlastimil Babka , Yosry Ahmed , kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/4] Docs/admin-guide/mm/zswap: s/red-black tree/xarray/ Date: Fri, 3 Oct 2025 13:38:51 -0700 Message-Id: <20251003203851.43128-5-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251003203851.43128-1-sj@kernel.org> References: <20251003203851.43128-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The change from commit 796c2c23e14e ("zswap: replace RB tree with xarray") is not reflected on the document. Update the document. Signed-off-by: SeongJae Park Acked-by: Nhat Pham Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- Documentation/admin-guide/mm/zswap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/admin-guide/mm/zswap.rst b/Documentation/admin-g= uide/mm/zswap.rst index 283d77217c6f..2464425c783d 100644 --- a/Documentation/admin-guide/mm/zswap.rst +++ b/Documentation/admin-guide/mm/zswap.rst @@ -59,11 +59,11 @@ returned by the allocation routine and that handle must= be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compr= essed pages are freed. The pool is not preallocated. =20 -When a swap page is passed from swapout to zswap, zswap maintains a mapping -of the swap entry, a combination of the swap type and swap offset, to the -zsmalloc handle that references that compressed swap page. This mapping is -achieved with a red-black tree per swap type. The swap offset is the sear= ch -key for the tree nodes. +When a swap page is passed from swapout to zswap, zswap maintains a mappin= g of +the swap entry, a combination of the swap type and swap offset, to the zsm= alloc +handle that references that compressed swap page. This mapping is achieved +with an xarray per swap type. The swap offset is the search key for the x= array +nodes. =20 During a page fault on a PTE that is a swap entry, the swapin code calls t= he zswap load function to decompress the page into the page allocated by the = page --=20 2.39.5