From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C71B606A33B for ; Fri, 4 Dec 2026 16:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kt5cCaa2 Received: by kanga.kvack.org (Postfix) id D338F6B05B3; Fri, 4 Dec 2026 11:48:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D0A746B05B4; Fri, 4 Dec 2026 11:48:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C20FC6B05B5; Fri, 4 Dec 2026 11:48:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 940E26B05B3 for ; Fri, 4 Dec 2026 11:48:18 -0500 (EST) Received: from smtpin24.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2CDE31C3C16 for ; Fri, 4 Dec 2026 16:48:18 +0000 (UTC) X-FDA: 85506883476.24.005D839 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf02.hostedemail.com (Postfix) with ESMTP id 6AF8880011 for ; Fri, 4 Dec 2026 16:48:16 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=kt5cCaa2; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796402896; b=eR6OwBeyOJdBfq8O2CVkkQpAjaN76zWZ/BGkz6HAmaQBHG4j4v252lUSaTS+As380JyTo8 ZKAQm+AcHw0N0W+5Aus5SJMa8mHxdtNu9Ujgh1FhasF6oANfZKvsQ8nvzfVqcWE3gOiav5 Tb4EnDC9XBcSx8fFTHQDOrjWfMOt8Vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796402896; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IW6/DMi14WyMFtcwaEOqw/A7t2yjm4JJSww6ILCCxjM=; b=waaOjGguPSVfzlwfg4m+VGPuCNiBLNEK5w+XM6659VC+GZrTQWoXEgIbxQWrdIYxr04LVS QgIaVdtqlP3Ves1BQlP+XF4og0/Iih4qT2bI0nc4Wv9v1Igm5fP7Vr0tPH9C1srmLz0vBr R08rEwbDCM7u4lNOcW/UOoz4toIzTec= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=kt5cCaa2; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id AE01F4372F; Fri, 4 Dec 2026 16:48:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B151C1F00931; Fri, 4 Dec 2026 16:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796402895; bh=IW6/DMi14WyMFtcwaEOqw/A7t2yjm4JJSww6ILCCxjM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kt5cCaa2p7a1RGcF3P/TDeKnUjWEDMV5IKkTcwliCi+pYQ8oJN4kqXIBiqUiQYZjm 7eIPmaXeu/gz/bAbvtVjQV1YAjJJ30NuDfOwLCIdN/9J5pnthSLlVi3UUjiS6rv+3T td1YnVtiFtOpduk6vY35Up/8lfkhjm5EULWN4UxkSs1reDyD7H0aRukmT6Ib5YHuIC +lrr6UuQtZmsY9D27M8+m19P9cWMVkhQwPchkzYLlhA/XAW+HdjAeuumNHqrj6iuC8 1ky/Judd2nCogmYfDO/9cuO3TYlitN4Yb1KdBwK6Dcz/RmPdTJhmUsgmuUBrPMMGFy 56ldP8DcsJn6Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 02/14] mm: xswap support for zswap Reply-To: sashiko-reviews@lists.linux.dev To: "Baoquan He" , linux-mm@kvack.org Cc: akpm@linux-foundation.org, david@kernel.org, corbet@lwn.net, chrisl@kernel.org, kasong@tencent.com, urezki@gmail.com, hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com, baohua@kernel.org, youngjun.park@lge.com, kunwu.chan@gmail.com, klarasmodin@gmail.com, "Kunwu Chan" , "Baoquan He" In-Reply-To: <20261203164336.864691-3-baoquan.he@linux.dev> References: <20261203164336.864691-1-baoquan.he@linux.dev> <20261203164336.864691-3-baoquan.he@linux.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:48:14 +0000 X-Rspamd-Server: rspam02 X-Rspam-User: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Stat-Signature: u4ep8nqwbe1hand19pg9k5b4y9a8oqnn X-Rspamd-Queue-Id: 6AF8880011 X-HE-Tag: 1796402896-694574 X-HE-Meta: U2FsdGVkX188kmnZpcGM+IwO1NxUZmEMI6HlL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rO3NQ0RjmS/g3uycOFs2hqi9qc8u/ip5VJSX/k6Tlm4rHMo/O4jd8fU7TqK2RmqNJdMXPaF54AwAshGA+Y23JADEK0sX48Jrwi/lHQLynCIt2TiuLUMAZVDgF4fsli7L0KM731x8UlCvvnq5SgkgkKWXMyLWsS8ZGmLG+muUXa5TVLJA+Ly11s0cWpsCAyncobLtAEVnuaQdEwhTqZP8F11KJRMiyHXsbLNakBMSf0X3pNyahjQ0gagAi8SnZKn8aDfgCZLYPy6/Jncx+eEOBwajkbvADnTD2PB7ttVNZTV5LqVTrgLKRsWANHSxPKhoiK0kfAxsHFRThqucxaxkIEmhtDscZnxH6AiTJ2+4Bhcy4HnE05cn57DfX8XHVGAh36LKsTB2NfQVl6S8EY1lEURUmJ/rYmzta5HVzoYlmScvAsC4/R2QEFsxSxbbN+Vb8/SvDvdOBSq0cXEo1B+PEJ3ZOO8V65cPbE3t/P9yFa6ES/3M1fsBX/i9qggVs6GSZs1OSA5gWpCuxS1FOdIDQecZddDGr2csLesrHhuSQHqOv91HOsxiGoTnq6RIu1Zf8S2P6ZxJZYzDzM5FkzS1dailW4uptkFGRY/adSfpN7p3KHlm/LnWo0aVuWrSB8WM50h2CX/qF1GoLWS29oV4nx8dNKVx0wbryILq5lVZnxK7Jk2Diu5HBwwVcGG+HynvvM/902G0CBaYL4MILGGndgy1haRHN+lb9Wi8ZorfjaD7zxuwr7OV9oe7Hf4S5uHw+Co4gAh7cpwwf7rbh/4weBJw= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] mm/zswap: unnecessary zswap_lru_del() locking and LRU alloc for xswap entries - [Medium] mm: zswap_store() queues shrink_worker() on empty LRU when xswap fills pool - [Low] mm: unmentioned add_to_avail_list() bug fix and /proc/swaps change - [Low] mm: zswap_store() calls shrink_memcg() without checking nr_real_swapfiles -- commit 9c57f7ef12d862357f940d3c5e67abd20d6102eb Author: Chris Li mm: xswap support for zswap This commit adds core swap and zswap support for extendable swap devices (SWP_XSWAP) that have no backing storage, skipping writeback, readahead, and zswap LRU insertion for xswap entries while tracking active non-xswap devices via nr_real_swapfiles. > diff --git a/mm/swapfile.c b/mm/swapfile.c > index d59fa82208620..558c4b75bf928 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c [ ... ] > @@ -1323,10 +1331,11 @@ static void add_to_avail_list(struct swap_info_st= ruct *si, bool swapon) > /* > * When device is full and device is on the plist, only one updater will > * see (inuse_pages =3D=3D si->pages) and will call del_from_avail_list= . If > - * that updater happen to be here, just skip adding. > + * that updater happen to be here, just skip adding. @val still has > + * the off-list bit, so compare its counter part. > */ > pages =3D si->pages; > - if (val =3D=3D pages) { > + if ((val & SWAP_USAGE_COUNTER_MASK) =3D=3D pages) { > /* Just like the cmpxchg in del_from_avail_list */ > if (atomic_long_try_cmpxchg(&si->inuse_pages, &pages, > pages | SWAP_USAGE_OFFLIST_BIT)) [Severity: Low] Should this fix in add_to_avail_list() be split into its own commit? Because atomic_long_fetch_and_relaxed() returns the value before clearing SWAP_USAGE_OFFLIST_BIT, the old (val =3D=3D pages) check was always false a= nd let a full swap device be added back to swap_avail_head. Splitting it out lets it carry Fixes: b228386cf237 ("mm, swap: clean up plist removal and adding") for stable backports. Also, the new "xswap" Type column value added to /proc/swaps by swap_type_str() is not mentioned in the commit message. [ ... ] > diff --git a/mm/zswap.c b/mm/zswap.c > index 6a66b898ab470..52f350b2c452f 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c [ ... ] > @@ -1598,7 +1617,8 @@ static bool zswap_store_page(struct folio *folio, l= ong index, > entry->objcg =3D objcg; > entry->referenced =3D true; > INIT_LIST_HEAD(&entry->lru); > - zswap_lru_add(entry); > + if (can_writeback) > + zswap_lru_add(entry); > =20 > return true; [Severity: Medium] Can zswap_entry_free() skip zswap_lru_del() for xswap entries? zswap_store_page() never adds SWP_XSWAP entries to zswap_list_lru, but zswap_entry_free() still calls zswap_lru_del() unconditionally on every xswap swap-in and slot invalidation. list_lru_del() then does the memcg XArray lookup and takes the shared per-(memcg, node) l->lock spinlock only to see list_empty(&entry->lru) is true; during slot freeing via swap_range_free(), that lock is acquired per page while holding ci->lock. Similarly, zswap_store() unconditionally calls memcg_list_lru_alloc() for xswap folios that will never be placed on zswap_list_lru. Gating both on !(__swap_entry_to_info(...)->flags & SWP_XSWAP) avoids the lock contention and unused per-memcg list_lru allocations. [ ... ] > @@ -1667,7 +1687,7 @@ bool zswap_store(struct folio *folio) > zswap_pool_put(pool); > put_objcg: > obj_cgroup_put(objcg); > - if (!ret && zswap_pool_reached_full) > + if (!ret && zswap_pool_reached_full && atomic_read(&nr_real_swapfiles)) > queue_work(shrink_wq, &zswap_shrink_work); > check_old: > /* [Severity: Medium] Does gating zswap_shrink_work on nr_real_swapfiles cause shrink_worker() to spin when xswap fills the zswap pool? When both xswap and a real swap device are active, xswap entries can fill the zswap pool to zswap_max_pages() without putting any entries on zswap_list_lru. Every subsequent rejected zswap_store() sees zswap_pool_reached_full and nr_real_swapfiles > 0 and re-queues zswap_shrink_work back-to-back while reclaim keeps retrying xswap folios. On each wakeup, shrink_worker() runs MAX_RECLAIM_RETRIES full passes over every online memcg and NUMA node, taking and dropping l->lock on every allocated empty list_lru_one (or 16 empty root LRU walks when memcg is disabled). Gating the wakeup on whether zswap_list_lru actually has entries would avoid this background spin. [Severity: Low] Should the synchronous shrink_memcg() call in zswap_store() also check nr_real_swapfiles? When no real swap device is active (nr_real_swapfiles =3D=3D 0) and a cgroup hits memory.zswap.max, dirty xswap folios already in swapcache still reach zswap_store() and call shrink_memcg() synchronously. Because zswap_store() allocated list_lru_one entries for the cgroup, shrink_memcg() starts a block plug and takes l->lock on every NUMA node even though zswap_list_lru is empty and no writeback target exists. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203164336.8646= 91-1-baoquan.he@linux.dev?part=3D2