From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011066.outbound.protection.outlook.com [40.93.194.66]) (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 E11EA322B6D for ; Fri, 11 Sep 2026 02:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.66 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789094305; cv=fail; b=QJU9tgMwXycNEm18f+OZxi0ci389opUdf1fSqy/zaGVr44Gk5ypW+HCNFn1XZs/7mDg+iJeV8dMuSUiZlSSVPjRnuCGqVLgRWShmMUKSYblluGwN28D89oQAb/TP8gV7Et/Wc0zExJo143n/rYWtDZYZJ5hFyJIygpTb/nEs0qY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789094305; c=relaxed/simple; bh=rMfpvedtx1TvIKcA01IuFoYHffVEF4PH+8o1tDqzWOM=; h=Content-Type:Date:Message-Id:Cc:To:From:Subject:References: In-Reply-To:MIME-Version; b=fF+OTeVVtDZfXl800D6MpuhcMNsY/f3iZNkvu9qiGd0LDg2GClMr7jO1DYR+f0/57CnyM/YCuUOPLNWMII5G0c6L4FKoFZLhEzLz/lZSCX+mvrpTl5ytPjEuicaLTvqc9fpiR3/eyuBcyg2QOz5G8rebj8Tr0Tvg/8yxGl4Bcqo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=kdNSnGBZ; arc=fail smtp.client-ip=40.93.194.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="kdNSnGBZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r/tJlKYMmO4M4oq20qWeMWSSsgaPXaFMAiV5aGgekLQrF0fz1alT0lYbPHlHCzfBazS/3qTW2j2OaoFjcquhBRfvptGRzCQIAD0etPYb+TI6idoCkgslX+t4pJHt07zn72YtAUWU0Y0VENAXU+bLSE1mUd1S5pfS/y00+k4ekIRoLfD2gR4reC2iLO2kkvFDtq4AxpS/uanxmpSbXXQBXBnPcaQQlPKIem7dCHXsJEGo0vBRiNlZ43CXezvBKu6svzA+xpoENGqdmVp+QyHEIDKN4UzktHhfaWtuB9AdXIdDSNPE9FeumPyelT+dHfu7dXuDReXEB5K2wnDX7Qu7Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uLcyHGopRQOaCTBhCNb4mbosmdjsvInDdNFQrIVuV7k=; b=ByxyVqLn/SOs2qkf6QAvAe2xBQPYt0lHFA//x2VpB92DkG2iJoULgk9dhU5tMhfrSgf2cJsCHxsU+Vxfy5UsYr3dYkEuhSRl1Jtk7NTojBWbSrDj8ItaS53T/U6V8U4jbS1DLah6U3IyJWX/J6igUjEOC/HDfJ5TE5q1LGn9x+kQkxiNpVjPNQXPGiz5MLJMvPuigG4U9MV85WB7kKysPMmsG6K5qTNfwst/rH24bu719/gZgvqD0jQRuEMBVlpjQ8aG2PwfEOfny6faxJ58pKhsyrSPMxJn8SNO5RYRXtDrOsVrJ3A5AWyIyKkKEE7/NZVS2ubi9cWQprby2htx3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uLcyHGopRQOaCTBhCNb4mbosmdjsvInDdNFQrIVuV7k=; b=kdNSnGBZbqwBgMun3u+ijpGYeekxfr/yd/MUp+cSGh2FyBjpYyCMN+C49q9UlKJ0yNM+FsNFPy7OKv5bBnvDrdlGmEKEVBnV68IzZCAcXlM7wPk90h9lAGd5I2taiR0YZGVQegqqOOo64WEdeJugp1VOLKLS1XyYgBOanTKvlISa8Lgdt+XMBmhKt8c4Vi7QWoCHQ5MdSMQ7HUHRzmOOQ3/fwigAujS+Jep629aRxfwzHOkPmCqmLL5NbbiQU1vVUkDRDgrqK3r3Bo008zGFMuDj4IZgjnhKAFvjVbr1lkXYVIv6PrMhqkVjfneoUTfLjE0XHMqfn9QeBY78BCl3vg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from IA0PR12MB8374.namprd12.prod.outlook.com (2603:10b6:208:40e::7) by LV2PR12MB5774.namprd12.prod.outlook.com (2603:10b6:408:17a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.14; Fri, 11 Sep 2026 02:38:14 +0000 Received: from IA0PR12MB8374.namprd12.prod.outlook.com ([fe80::d85f:4c87:ae84:3f16]) by IA0PR12MB8374.namprd12.prod.outlook.com ([fe80::d85f:4c87:ae84:3f16%5]) with mapi id 15.21.0406.007; Fri, 11 Sep 2026 02:38:14 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 10 Sep 2026 22:38:13 -0400 Message-Id: Cc: "Kiryl Shutsemau (Meta)" , , , , "Liam R . Howlett" , "Nico Pache" , "Ryan Roberts" , "Dev Jain" , "Barry Song" , "Lance Yang" , "Usama Arif" , "Vlastimil Babka" , "Jann Horn" To: "Kiryl Shutsemau" , "Andrew Morton" , "David Hildenbrand" , "Lorenzo Stoakes" , "Baolin Wang" From: "Zi Yan" Subject: Re: [PATCH v2 08/12] mm/collapse: separate scanning a PTE table from collapsing it X-Mailer: aerc 0.22.0 References: <20260910120238.2529819-1-kirill@shutemov.name> <20260910120238.2529819-9-kirill@shutemov.name> In-Reply-To: <20260910120238.2529819-9-kirill@shutemov.name> X-ClientProxiedBy: BL1P222CA0023.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::28) To IA0PR12MB8374.namprd12.prod.outlook.com (2603:10b6:208:40e::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PR12MB8374:EE_|LV2PR12MB5774:EE_ X-MS-Office365-Filtering-Correlation-Id: 50d5350c-5a0f-4a31-867c-08df0fadba48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|23010399003|376014|7416014|366016|4143699003|10067099003|6133799003|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: d57eFfbOTAbI59dfixuy17oDCdaLL+glfBZqJAX9w9Vklz1d6N9OIMJog569DQ0MwMs1M1g7cJ62Xc26BoIUfmHy7oSAttwQozWhbe4mIHlvFz5DcXJgmHmhUBt+QGneUXBAX2WsB+8+xGt2BDlYunrEGJTIWRg8mfI1Chs0nFhQV07Y52Q5gs+7Ty6uODWjuKg58pgFcOjduaF0lcFaYYLHHWNvYLCS0jL3mGGrbv82pS5Qz6qsSuV6+LK3l71DjDy57GxfEfrvSfShxU7lLPrFv7As2O7U8SFu/vBTzD/nKli0t5HKSK9dDVvHiuaeJeVpDrTxky1ui8K3h7ZheOTfur1fmBu95UDE1taUG1i2bcDl302EXAcF5wT2pJ+50FjByzQ87CpQqpqW+nhJcbh9HNTqhvR5P9iuFik1IMPEDGwZ3s6sva3NU1xTDHjtOaE/zH1GUKTRWyzr/+Ns2sbkjCC9IIXmAoR9Fz5VvbYc1SwPV7ZOUP5mahF7I9FhY9JeiOxRetkwE0heZzlbt3muUDxqw8MLqBLP0IAw2owFwBRIr/5ku4Is9rfW38azWCpM7hu85FNRIiGapWjW2AdkOnjBK8jnKnvIgHuenIju8UFIaF5bCwvSAg7B+anFJFe9LM4MDuUHFGcb8HEWgEYju4DsrrdTPW7QC+aD8jo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA0PR12MB8374.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(23010399003)(376014)(7416014)(366016)(4143699003)(10067099003)(6133799003)(56012099006)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OUNsTVphQ2s2N0NpMHEvOFhhb2w3TndlMElWQWtpM0hRcnIySm1ZS1h3aDRn?= =?utf-8?B?dVEwZTNwWHlzUXN5Zk5aV0d4QTJ0THJZdmpYdjVlUTNzWEhpTGw2UXBNU3Y3?= =?utf-8?B?MFN3TFZuZ05RNGVzL2JtOUFEVUE4ZVRFZHFyQWdobXYxSGdoOFpUeWh0Wk4w?= =?utf-8?B?N1A1dVVWS1lmT0I0dThIWmxYYi9sOVk3QXplWWxET0RGMDFUbXZmYTdEdnJo?= =?utf-8?B?T09yRy9NUThObU96WDg3NHgvWnVMTVNMbE1sOExVcjhGbTVpNEtTeS83aENu?= =?utf-8?B?aDlKalEzZFpwTTU0UXhwdlAvSjh1aXJ5dkFLdEpZQ2htU0xTWU1IbGhPQ3ow?= =?utf-8?B?aURsVnJmYXNiS3pST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Uko1anJFbGVPNWd2WGpI?= =?utf-8?B?aU1xSFhoQ0poTHZwS0ZONGpCdHE3bkprQVBLMDl3Z1htRUlXcUExMEZYQzBu?= =?utf-8?B?TUhjZmQ4SWlKZzZLOW9yWUQyNkRPc0tGMTF1TmFLUzlpbE55dDRsQ3g5VXRO?= =?utf-8?Q?SevsLNMBBi374khhEA?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50d5350c-5a0f-4a31-867c-08df0fadba48 X-MS-Exchange-CrossTenant-AuthSource: IA0PR12MB8374.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2026 02:38:13.9994 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Adxu4jC0foXnGZsPBWqlSQvynuxMmyr0lzpYEO74PXTcnxGPLZSIx/d6M6vRim0K X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5774 On Thu Sep 10, 2026 at 8:02 AM EDT, Kiryl Shutsemau wrote: > From: "Kiryl Shutsemau (Meta)" > > A collapse is two jobs. One reads a PTE table under mmap_lock and decide= s > whether the range is worth collapsing. The other allocates, isolates, > copies and flushes, and wants the lock given up first. > > collapse_single_pmd() did both, so the boundary between them was somewher= e > in the middle of a function. > > Give each half its own function: > > - collapse_scan_pmd() scans one table and only reads. The anonymous > scan that used to carry that name keeps its body as > collapse_scan_anon_pmd(), and collapse_scan_pmd() is now the entry > that picks the anonymous or the file side. > > - collapse_run_pmd() does the collapse the scan asked for. > SCAN_SUCCEED from the scan means there is something to run; anything > else is why there is not. > > collapse_single_pmd() is now the two of them with the mmap_lock drop in > between, so its callers see what they saw before. > > What the scan found and the run needs travels in collapse_control. For > an anonymous table that is the orders and the referenced and swapped-out > counts. For a file it is the file itself, the offset in it, and whether > the PMD folio is already in the page cache. > > The file side moves with the anonymous one. collapse_scan_file() used to > run with mmap_lock already given up, and called collapse_file() itself > when the page cache looked worth it. It now runs under the lock like the > anonymous scan and only judges; the run does the collapse. A file > collapse works on the page cache and never sees a VMA, so the scan takes > the file reference while it still has one and the run gives it back. > > That changes what a refused file table costs khugepaged. Every file > table it scanned used to end its pass over that mm, because the lock had > been dropped to scan it; now only a table it goes on to collapse does. > > Two things on the file side stop being rescanned. When the page cache > already holds the PMD folio, the scan says so and the run goes straight > to retracting the PTE table. A run that refuses dirty pages and may > write them back retries collapse_file() alone. The checks the scan makes > ahead of it are ones collapse_file() repeats under the page cache lock. > > Tracing changes with it. mm_khugepaged_scan_pmd and > mm_khugepaged_scan_file used to fire after the collapse, so for an > accepted table their status field carried what the collapse made of it. > They now fire before it and read SCAN_SUCCEED for an accepted table. Wha= t > the collapse then made of it is for mm_collapse_huge_page and > mm_khugepaged_collapse_file to report. > > Assisted-by: LLM > Signed-off-by: Kiryl Shutsemau (Meta) > --- > mm/collapse.h | 16 ++++++ > mm/khugepaged.c | 147 ++++++++++++++++++++++++++++++++++++------------ > 2 files changed, 128 insertions(+), 35 deletions(-) > > diff --git a/mm/collapse.h b/mm/collapse.h > index 7044dc71c7c2..346859a2184f 100644 > --- a/mm/collapse.h > +++ b/mm/collapse.h > @@ -88,6 +88,22 @@ struct collapse_control { > =20 > /* Each bit marks a PTE the scan accepted as a collapse source */ > DECLARE_BITMAP(eligible_ptes, MAX_PTRS_PER_PTE); > + > + /* > + * What a scan found and the run after it needs. Live only between the > + * two, and read by nobody else. > + * > + * The file side takes a reference while it still has the VMA, since a > + * file collapse works on the page cache and never sees one; the run is > + * what gives it back. A scan that found the PMD folio already in the > + * cache leaves only the PTE table to retract. > + */ > + unsigned long scan_orders; > + int scan_referenced; > + int scan_unmapped; > + struct file *scan_file; > + pgoff_t scan_pgoff; > + bool scan_retract_only; scan_retract_pte_only ? > }; > =20 > =20 > -/* > - * Try to collapse a single PMD starting at a PMD aligned addr, and retu= rn > - * the results. > - */ > -static enum scan_result collapse_single_pmd(unsigned long addr, > - struct vm_area_struct *vma, bool *lock_dropped, > - struct collapse_control *cc) > +static void collapse_control_init(struct collapse_control *cc) > +{ > + cc->progress =3D 0; > + cc->scan_file =3D NULL; > +} > + > +static void collapse_control_release(struct collapse_control *cc) > +{ > + /* A scan that took a file reference should have been run */ > + if (WARN_ON_ONCE(cc->scan_file)) { > + fput(cc->scan_file); > + cc->scan_file =3D NULL; > + } > +} > + > +static enum scan_result collapse_scan_pmd(struct vm_area_struct *vma, > + unsigned long addr, struct collapse_control *cc) > { > - struct mm_struct *mm =3D vma->vm_mm; > - bool triggered_wb =3D false; > enum scan_result result; > - struct file *file; > pgoff_t pgoff; > =20 > - mmap_assert_locked(mm); > + mmap_assert_locked(vma->vm_mm); > + /* Whatever the last scan found has to have been run by now */ > + if (WARN_ON_ONCE(cc->scan_file)) { > + fput(cc->scan_file); > + cc->scan_file =3D NULL; > + } scan_file should be set to NULL by collapse_control_init(). Anyway, the code is duplicated here and in collapse_control_release(), maybe add a helper. > =20 > if (vma_is_anonymous(vma)) > - return collapse_scan_pmd(mm, vma, addr, lock_dropped, cc); > + return collapse_scan_anon_pmd(vma, addr, cc); > =20 > - file =3D get_file(vma->vm_file); > pgoff =3D linear_page_index(vma, addr); > + result =3D collapse_scan_file(vma->vm_mm, addr, vma->vm_file, pgoff, cc= ); > + switch (result) { > + case SCAN_SUCCEED: > + cc->scan_retract_only =3D false; > + break; > + case SCAN_PTE_MAPPED_HUGEPAGE: > + /* > + * The page cache already holds the PMD folio; what is left is > + * to retract the PTE table, which is the run's job. > + */ > + cc->scan_retract_only =3D true; > + result =3D SCAN_SUCCEED; > + > + if (cc->scan_retract_only) { > + result =3D SCAN_PTE_MAPPED_HUGEPAGE; > + goto retract; > + } > +retract: > fput(file); > =20 > + /* > + * A PMD folio is in the page cache, whether the collapse just put it > + * there or found it: retract the PTE table, and map the PMD if asked. > + */ > if (result =3D=3D SCAN_PTE_MAPPED_HUGEPAGE) { > mmap_read_lock(mm); > if (collapse_test_exit_or_disable(mm)) result is changed from SCAN_PTE_MAPPED_HUGEPAGE to SCAN_SUCCEED to SCAN_PTE_MAPPED_HUGEPAGE to get here. Is there a way of avoiding this result churn? > @@ -2805,6 +2857,28 @@ static enum scan_result collapse_single_pmd(unsign= ed long addr, > return result; > } > =20 > +/* > + * Try to collapse a single PMD starting at a PMD aligned addr, and retu= rn > + * the results. > + */ > +static enum scan_result collapse_single_pmd(unsigned long addr, > + struct vm_area_struct *vma, bool *lock_dropped, > + struct collapse_control *cc) > +{ > + struct mm_struct *mm =3D vma->vm_mm; > + enum scan_result result; > + > + result =3D collapse_scan_pmd(vma, addr, cc); > + if (result !=3D SCAN_SUCCEED) > + return result; Can it be changed to? if (result !=3D SCAN_SUCCEED && result !=3D SCAN_PTE_MAPPED_HUGEPAGE) return result; --=20 Best Regards, Yan, Zi