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 B5BA6606A33F for ; Fri, 4 Dec 2026 22:09:50 +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=fm1dQhnD Received: by kanga.kvack.org (Postfix) id A0D336B05BF; Fri, 4 Dec 2026 17:09:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BDA56B05C0; Fri, 4 Dec 2026 17:09:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D4286B05C1; Fri, 4 Dec 2026 17:09:27 -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 67D196B05BF for ; Fri, 4 Dec 2026 17:09:27 -0500 (EST) Received: from smtpin20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DFD2C80621 for ; Fri, 4 Dec 2026 22:09:26 +0000 (UTC) X-FDA: 85507692732.20.2CBA60D Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf09.hostedemail.com (Postfix) with ESMTP id 2DA4614000B for ; Fri, 4 Dec 2026 22:09:24 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=fm1dQhnD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.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=1796422165; b=fCDfSGFXux2iYL622GsSjHDyQlCKBrIv3wkrEHnEX5sMLzJjrubGUNdeLK/oLk/6WBZ2a5 ZyzB1ujfLAb2/NT8CiZ5QIWYdVPuZSR+bJvxr4GIRpVexjL+Qg7SH/FYKn0GJgkOWfPhEB JFQZdtX5LWNvvrKxjQ0xyIQUop8KphU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796422165; 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=bdkWiJ8gMPJgH1WjzShoBLJrZjLOjQdc4b1MlRpJPQg=; b=Je4u3twK10IE9ih3jaCtNS+yvz/xDmeiY7a6m4PY3LvWdcfhxW+h/qspsZZ8RgfqDhJJBq BxHNomyN38XoZoSa2Fe7a66vAJVadchfN1ZxBP8W4hAlx3JKSSw3fR3Qb5C6Cbl7SwonMc bzPhMc+54TKOIXc3dFE0xWa8F70u4RM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=fm1dQhnD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.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 6D40340A5F; Fri, 4 Dec 2026 22:09:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 100341F0093B; Fri, 4 Dec 2026 22:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796422164; bh=bdkWiJ8gMPJgH1WjzShoBLJrZjLOjQdc4b1MlRpJPQg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fm1dQhnDPSzTME2U+XxTUXuyGl5xDwuPFce+T807PanDJk9QQYDtcY21SFMY8HN5C 844DTPx883Asa+LjyBs8EKwDRvN92wT2+jH8xWBUtRjzn7cEXb7Hu0ZTw8I4/k11wd nQr6pyexFz31U4rLjfuyE2FcLsAbXCdUm40w3cqmt23jg74nhugUOkCnJdePPHHR5u YBOmU2wf6JRcjx6240wFpeeYTTkxfPSsg5TV0ERK5OvHrNwzGTHBF5lM9iKtWhIawM rY65L8RuokLWPmushyYGAsNK312Ki0tA7Nm+6y0XH4pZnKv7jRimlhSR/VehXjxuQH EkVG7ac98htPw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7 09/20] mm, swap: enable THP swapin for vswap entries Reply-To: sashiko-reviews@lists.linux.dev To: "Nhat Pham" , linux-mm@kvack.org Cc: "Andrew Morton" , "Chris Li" , "Kairui Song" , "Kemeng Shi" , "Baoquan He" , "Barry Song" , "Youngjun Park" , "Johannes Weiner" , "Yosry Ahmed" , "Chengming Zhou" , "Qi Zheng" , "Shakeel Butt" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Baolin Wang" , "Michal Hocko" , "David Hildenbrand" , "Liam R. Howlett" , "Vlastimil Babka" , "Mike Rapoport" , "Hugh Dickins" , "Jonathan Corbet" , "Shuah Khan" , "Randy Dunlap" , "Roman Gushchin" , "Muchun Song" , "Arnd Bergmann" , "Karl Mehltretter" , "Dapeng Mi" , "Marco Elver" , "Ethan Nelson-Moore" , =?utf-8?b?Qm9yaXNsYXYgUGV0a292IChBTUQp?= , "Jeff Layton" , "Tejun Heo" , =?utf-8?b?TWljaGFsIEtvdXRuw70=?= In-Reply-To: <20261203220010.1302207-10-nphamcs@gmail.com> References: <20261203220010.1302207-1-nphamcs@gmail.com> <20261203220010.1302207-10-nphamcs@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 22:09:22 +0000 X-Rspamd-Queue-Id: 2DA4614000B X-Stat-Signature: 73jh7sscawy3s87j6kxddxe6g1x76dfe 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-Rspamd-Server: rspam08 X-HE-Tag: 1796422164-471268 X-HE-Meta: U2FsdGVkX1+FaXiF75SyshnwEJSSY+y0GfyA6toH/Cq0ZvgJu/0tNIzABRpDQJMsZUUjfRE0lfAnNmGNtbN3U6FgXNAiTnTzFQMD3Hkh+5Wd2+eJK2FA2oKsrV7tKCwvhTFPs5BI+L66d6iGxZu79eIG3vKrubBwn2gm0emXIXxEbd5lWFPNrxss9+tEKm0cdnR0ROgZzZnwunN8if8RxK+W/yEiTXQepZ67wZiz2kcf8/0qNycVnTqHjK802+CDBWJJ1gCWPMkW3P58bXNBsYW4XJrXfmLokQIVKWd1RmXry8eYwE90qOHWfZKDyIWQPN70SA1ni5V9RatU+8zBY6vOGIPsBVNzIn4tioPOrpwA2Zyo9mjfVqBjirY50/DiCKYD5thXfli9lS86r3Zia8ehR7/juQb0eCvetINYaksD294HNlnEc/mmiO9Tt2ABTUZinfCpONVNOu4SiOgL4JnUGQ9Z57EWdpM9kynY4fAKv7vwNhn2fhK/XAnY7rfKDLLnKtO0KMZ93IcZ8aKfG7wTT1PfVuVeaE2egJ7uCNfXURZEyRZGAkyKDP4fTUmybbNTiO5ISyN5i6mm090+WZp58h3WFoEY9+N/hF/DrQcKW4CEOjchDTmr7oEtsbzqqiCVzJe3bdKOvNHgDg5cwRToj1uoWdWjTPYeAT7UpzbI6yntGYRbSd9uJfuM/wwFl7T1KEWIaAdtDcHaOtP8Z9pFQyLLpMU/IU8MACDcyPS7Tj0EnEJ53Lfqb5cCwB1BaMSnuhZEk6KJQ/hKHJlcvUzKkXrj77phcwGeLbxBAYAMZDfBq9Ml5Cmp0haY/DdG393X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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 2 potential issues to consider: - [High] mm, swap: zswap vswap faults trigger PTL scans and mTHP fallback cascade - [Low] mm: redundant and contradictory dirty guard in do_swap_page() -- commit 75209e7921ed8209524c9062f6295ef362c17766 Author: Nhat Pham mm, swap: enable THP swapin for vswap entries This commit enables large-folio swapin for vswap entries backed by contiguous physical swap slots on a synchronous block device, checking the vswap backing under the cluster lock in __swap_cache_add_check() and clampi= ng the order mask to a single swap cluster. Link: https://lore.kernel.org/all/sashiko-outbox-181079@kernel.org/ > diff --git a/mm/memory.c b/mm/memory.c > index 3eb1841530bb3..ae9d5e69622f9 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -4924,9 +4924,10 @@ static unsigned long thp_swapin_suitable_orders(st= ruct swap_info_struct *si, > * lack handling for such cases, so fallback to swapping in order-0 > * folio. > * > - * THP swapin for vswap is not supported yet either. > + * Vswap entries are checked later, under the cluster lock in > + * __swap_cache_add_check(). > */ > - if (is_vswap_entry(entry) || !zswap_never_enabled()) > + if (!is_vswap_entry(entry) && !zswap_never_enabled()) > return 0; > =20 > /* > @@ -4934,7 +4935,7 @@ static unsigned long thp_swapin_suitable_orders(str= uct swap_info_struct *si, > * is read with one bio. The flag is set in swapon() and stays, so the > * race is benign. > */ > - if (!data_race(si->flags & SWP_BLKDEV)) > + if (!is_vswap_entry(entry) && !data_race(si->flags & SWP_BLKDEV)) > return 0; > =20 > /* [Severity: High] Can bypassing these early exits for vswap entries cause every zswap-backed vswap fault in an mTHP-aligned range to take the page-table lock, scan PTEs, and cascade through every enabled large order before falling back to order = 0? When a large anon folio is swapped out to zswap under vswap, its virtual offsets are contiguous and aligned. On a 4 KiB fault, do_swap_page() calls thp_swapin_suitable_orders() even after swap_entry_synchronous() matched zswap_is_present(), acquiring the PTE lock and scanning up to PMD_ORDER PTE= s. __swap_cache_alloc_folio() then loops from highest_order() down to order 1, taking ci->lock and scanning all nr virtual_table slots in __vswap_check_backing() (up to 510 atomic reads for order 8) before returni= ng -EBUSY and spuriously incrementing MTHP_STAT_SWPIN_FALLBACK on each order. The same regression also hits synchronous regular swapfiles without SWP_BLKDEV. Checking for non-zswap SWP_BLKDEV backing before scanning PTEs, and short-circuiting to order 0 in __swap_cache_add_check() when targ_entry precludes large swapin, would avoid the lock/scan cost and bogus stats. > @@ -5250,7 +5251,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > * large folio is fully applicable before use. > */ > if (!swap_cache_folio_mappable(folio, nr_pages)) { > - swap_cache_del_folio(folio); > + if (!is_vswap_entry(entry) || !folio_test_dirty(folio)) > + swap_cache_del_folio(folio); > goto out_nomap; > } [Severity: Low] Is this folio_test_dirty() guard dead code that contradicts swap_cache_folio_mappable()? swap_cache_folio_mappable() already warns via VM_WARN_ON_ONCE_FOLIO() if the folio is dirty, and a non-anon large swapcache folio cannot be dirty here. If one ever were, skipping swap_cache_del_folio() would leave it in the swap cache while the swap PTE stays present, causing the fault to livelock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203220010.1302= 207-1-nphamcs@gmail.com?part=3D9