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 EB53E606A322 for ; Fri, 4 Dec 2026 16:48:43 +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=O8B5ExLq Received: by kanga.kvack.org (Postfix) id 45A476B05B7; Fri, 4 Dec 2026 11:48:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 432576B05BA; Fri, 4 Dec 2026 11:48:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 347026B05BB; Fri, 4 Dec 2026 11:48:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0D4346B05B7 for ; Fri, 4 Dec 2026 11:48:23 -0500 (EST) Received: from smtpin27.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5C8FA80516 for ; Fri, 4 Dec 2026 16:48:22 +0000 (UTC) X-FDA: 85506883644.27.83DF87F Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf11.hostedemail.com (Postfix) with ESMTP id CA8444000B for ; Fri, 4 Dec 2026 16:48:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=O8B5ExLq; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 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=1796402900; b=7CPnFVJhlIFFLT6g1aKbuMCGlR7IiO4U2Hj8Bhd7vbGKDG7Bln2VcU/s0QtJgyNWeCHhYK t3ZnjHywF8DDOtkaCqwxG+kDdDtMFp9vnOaYNpzVmMfx6+QvNbsCUIAU86Yv396Uv/EIru PudJd3Zd8We83r8oBKbX4BIVGEPnrnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796402900; 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=U9RQS2AUiI+xNXiU5mZ5OrhSKCMGdsigdfbo/8hVgmM=; b=MjUqgZkSQmKblmdYqXtMlY7yjLCynyVq1Np8WEUedO8oda+ldJBwMx4sgz729UvT/9cMIV AW29SBn3HKKjT49jCR5NT4GobpEhC25aB1NXgH677hMkinJqqw/72PgBn33pv6NNWzMYVm hkFucWpMcGP4SePd0FsuOuxuPt4gs2c= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=O8B5ExLq; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6564361754; Fri, 4 Dec 2026 16:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1997B1F00933; Fri, 4 Dec 2026 16:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796402899; bh=U9RQS2AUiI+xNXiU5mZ5OrhSKCMGdsigdfbo/8hVgmM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=O8B5ExLqvPT/ASofAmkLd1sPK4372VvW9TEW68k7CU1B4J38Hg61NcB8lUYWvggzK UWpQV8OJXa8I6zor1hrCBlyTkAf8vg39/AqPNRGhch09Wb/EkIDfM+s10//PehhHXh V5VJF55t7tg9oSWWPwerOHh41cZe2Zc+TfxdVzHEr5ujGGcDHQmWBkt9mfG36wUABE QGZumKyR6hDOhzRaACc4eAyvYFoyHeuZuZpmhShxGmh5B7F0WBn6FsG5oxT7yYQeTq PL94vo3bfIMHlmh68C411zbBnA/e4eW5Aywqo6fJPVBxni3LP9gZ60oFmPWuj61OQN hmt3J/LJohC7w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 06/14] mm, swap: create the xswap device from swapon(2) 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, "Baoquan He" In-Reply-To: <20261203164336.864691-7-baoquan.he@linux.dev> References: <20261203164336.864691-1-baoquan.he@linux.dev> <20261203164336.864691-7-baoquan.he@linux.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:48:18 +0000 X-Rspamd-Server: rspam04 X-Rspam-User: X-Rspamd-Queue-Id: CA8444000B X-Stat-Signature: t6cftdza9xrpd7rdwh51yrrqwscxq95w 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-HE-Tag: 1796402900-47147 X-HE-Meta: U2FsdGVkX1+mvTBkyjq0mgIXOQvIxKAylgzX8F4NT9QnO8AFFpT/NEmgYZEpQJE5+2sVz/+Ek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7YcjpsqrqR3bPH+JxlTrbjhYvRNkqsUGjOAOR/ezLMJVrDlZj5cm0+93y/Yto9TfkbOOIB89nnOTzJN+VSU0BF5hFY38EMxWA2K56pp6MOihzT9vKT7roHqDvDxTBVJmeeIJApad1cLTH/1rtEtYbLcwU4pY3BOrVKVZA30lJ9xvehktBWAXs4VBO+vCumQ0azkUGfIxqU7RYfRnlJ9oRPr39akYL2lz/2xRyic+JwJbl31vpo1IDvI+YFvyxfQ3klCSqPwh+5xulz57/xxYrFRtpKydce9kyRL3IJrtFi6s0a97oFvTdF+DUI4Dj/IEQ823gAyFBWQjphHWtteQTnK30D/YgMZ1y2BUUclvyyUSoXua3QtWe/h209cGg1lAgJ4FuDv9uEYU9mMsmPiJcD+zIPxbcnn5qbk+XSW9+gkioaQqdX0MuFlLzVbW0BkX4NmTMmiUwokSOKWF/eEO2Qo9X/3waJN1SLiSv49vGeiwUiRLjmEtKA/P0s0/ynMaYBWb+DbI+3bHTqdr+KOXMB1eGlvOyDlRrYLZj33t+JWoo7dytHwBjO8ytBTChwHEbCemd3wf3oMmQvc4G0qq6JOJPEeGNRHkpJ/FyjIZwa8o3yVXRwhr2e/IVxPP4pn2F3vJJ3ce6admbd+KP+7+W8ausQC8LKtGddZb18Ds1wMCSZ6iowNIMHtxU0CNSTH09CUr4= 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 3 potential issues to consider: - [High] mm, swap: xswap_create() breaks large-folio swapout by omitting SWP_BLKDEV - [Medium] mm: unsynchronized si->flags reads and SWP_WRITEOK gating in /proc/swaps - [Medium] mm, swap: xswap_create() omits SWP_SYNCHRONOUS_IO, hurting packing and swapin -- commit 3ff5334f3639c75b784e10b181014a401d16ea84 Author: Baoquan He mm, swap: create the xswap device from swapon(2) This commit allows swapon(2) to create a file-less xswap device when passed the name "xswap" and no matching file exists, exposes it in /proc/swaps, and skips it during hibernation device discovery. > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 912cfa68ba01a..4e598ab8da656 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c [ ... ] > @@ -3497,7 +3522,8 @@ static void *swap_start(struct seq_file *swap, loff= _t *pos) > return SEQ_START_TOKEN; > =20 > for (type =3D 0; (si =3D swap_type_to_info(type)); type++) { > - if (!(si->swap_file)) > + if (!si->swap_file && > + !((si->flags & SWP_XSWAP) && (si->flags & SWP_WRITEOK))) > continue; > if (!--l) > return si; > @@ -3518,7 +3544,8 @@ static void *swap_next(struct seq_file *swap, void = *v, loff_t *pos) > =20 > ++(*pos); > for (; (si =3D swap_type_to_info(type)); type++) { > - if (!(si->swap_file)) > + if (!si->swap_file && > + !((si->flags & SWP_XSWAP) && (si->flags & SWP_WRITEOK))) > continue; > return si; > } [Severity: Medium] Can these unmarked reads of si->flags race with concurrent writers, and does gating on SWP_WRITEOK hide xswap from /proc/swaps during swapoff? swap_start() and swap_next() hold only swapon_mutex, which protects si->swap_file rather than si->flags: CPU0 (/proc/swaps) CPU1 (swapoff) swap_start() mutex_lock(&swapon_mutex) del_from_avail_list() spin_lock(&swap_lock) si->flags &=3D ~SWP_WRITEOK spin_unlock(&swap_lock) si->flags & SWP_WRITEOK <-- data race Similarly, xswap_create() modifies si->flags without holding swap_lock after alloc_swap_info() has already published si in swap_info[], racing with si_swapinfo() (via sysinfo(2)) which reads si->flags under swap_lock. Checking SWP_WRITEOK here also hides the xswap device from /proc/swaps as soon as swapoff clears SWP_WRITEOK before try_to_unuse(), instead of keeping it visible to show unuse progress as established by commit eca4d01b982d ("mm, swap: protect si->swap_file properly and use as a mount = indicator"). [ ... ] > +static int xswap_create(int prio) > +{ [ ... ] > + si->bdev =3D NULL; > + si->swap_file =3D NULL; > + si->flags |=3D SWP_XSWAP | SWP_SOLIDSTATE; [Severity: High] Does omitting SWP_BLKDEV here disable large-folio swapout system-wide once xswap is active? xswap defaults to DEF_XSWAP_PRIO (SWAP_FLAG_PRIO_MASK), placing it ahead of real swap partitions on swap_avail_head. When shrink_folio_list() calls folio_alloc_swap() -> swap_alloc_slow() on a large folio, cluster_alloc_swap_entry() rejects order > 0 because SWP_BLKDEV is unset. swap_alloc_slow() then returns immediately for large folios without trying lower-priority devices, so folio_alloc_swap() returns -E2BIG and shrink_folio_list() splits every THP and mTHP into order-0 pages. Since SWP_BLKDEV paths dereference si->bdev, should cluster_alloc_swap_entry() also allow SWP_XSWAP for order > 0 allocations? [Severity: Medium] Should SWP_SYNCHRONOUS_IO also be set on the RAM-only xswap device? Without SWP_SYNCHRONOUS_IO, swap_prefer_free_cluster() returns true, so cluster_alloc_swap_entry() allocates fresh free clusters and swap tables before reusing nonfull clusters, inflating the lazy cluster footprint. On read faults, should_try_to_free_swap() also returns false without SWP_SYNCHRONOUS_IO, leaving folios pinned in swapcache even after zswap_load() has deleted the zswap entry and dirtied the folio. Finally, swap_entry_synchronous() falls back to an extra zswap_is_present() XArray lookup on anonymous faults (and sends zero-mapped entries through swapin_readahead()), while shmem_swapin_folio() falls back to shmem_swapin_cluster() instead of direct synchronous swap-in. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203164336.8646= 91-1-baoquan.he@linux.dev?part=3D6