From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.44 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796229462; b=w0qkXuK73XxJAGthD4IYzSUd5GoZBDbb/7on4wcnP4UPuEEu0K5Se0a4XemqjNdVc8JN YVqqtb6FevIYRFAhnRgf0y0i9zQ1j/BtAEVxKTpEoSeHn3WeV4oym04Xjls/HZsLxdsNG bkQLBvrXUb0dEbIiE1STptpVOwoUDMnl9GnMk4aOVei4lih2B6QFwm3m56yGztDMf3uX7 XXz8fNSgy9hzIuY70m+/BbkkJDfSAUlSQZBXuGViEES8MWlpoNmRwVDsEjdfn1Vl2epJG WLF1e5nSinLDGdyRAxrgk/ltJPQXtC3Evf/vGBfUEVJDLB2pW/xvSyKFVVmOBhyOH1w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796229462; h=DMARC-Filter:DKIM-Signature:Received:Received: Content-Transfer-Encoding:Content-Type:Date:Message-Id:Subject:Cc:To: From:X-Mailer:References:In-Reply-To:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=f3xuXwlCUGjay2jd/Xe0iuVmjixd6zIoi6QuvwS+Dt0=; b=TOuTs1vvCkYKZp0AK81tm3sobaQCEb6hARGabAMXExmVoEPKdSwoP6lCd6RPLv0cdnK2 WrDJ5wy2K+vZDONlczoldoxI46CWhz5iwpirQzzz43mq4Qn2T/yrTo7bl54WLgF0B/Lh9 8Dz48dPfu6+fTGbK7TtIclEkPYQ4SqWL9L0IWP0mkUdsZNMCDamFr/lu/QyQ9b15IAB// j8vxvHubpI90RMFgYSuc59T+z6icD3oqjUL8IBB1Fiegn86La8NfuygOpyK5gcxjPZQuO pwBUxJ+83DzMkBiEWVUHoxY56kxexfr2iwkCIlPC1yOznwXa0YYUvDYek/LDxj0pNOw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=FFSFgbsA; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.44 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013044.outbound.protection.outlook.com [40.93.201.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7426606A325 for ; Wed, 2 Dec 2026 16:37:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7426606A325 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, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=FFSFgbsA ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tl4GGP7DeZzgUH248PSELp8Wo9mbHANXd7TorTYAT995Od5FYUGPO1D/9R4VyN+aY1TXkfUmBkIeq//WA0SMp6ocT98ONCcrEirM5wAUKitMSUp3gLHtsYgEUJyMt3tMN9Xhdlwf4OSeKMnH+k0XjkfNfprlT6OxYl5WrfmWq0B7V7NlLtoSV/QnjNwV9hR+5SHdK0lQw7RhsHyXlugG5LjWe7PtXHS/Ay2rkc5e+C6TDlYjDyZNznj90Urh4Wr8reW+5KqXxuqTVBNM90+JAmpjtcuWEbJGafNOTLYTWk9s0OvUjyj1rNqoCb4xuwMBvv1G4YntDah8MSzrUBwZvw== 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=f3xuXwlCUGjay2jd/Xe0iuVmjixd6zIoi6QuvwS+Dt0=; b=STkSueUAgyXB4CVWTdYsUnpGfacWu4K8vOd3R1I1yDCCopmi/WOqYy8iYfJFqxFJNQ83+tgIuSMJLx8gZAVOgpbJ9E5j8uOSoxmyqY8oEp/79V6LWYnMVxI3lv13a5gvH8ct0BdZVRr6bmM5pD0BrepByy2Neu2hCZQz2V6XoWcq2sJyLsUKPKjytnelmD4iOalvttQOVK5bWMj5RxlLcFwFHNHbKTgUbsPYh8NF2ElDSuzql/YmlEpC+jt90rDyXNx3DgVdCYAZumPc1MccmGwanStQYarDv8OvYmqtwfcnJXbUoP894K1WJJ2Tl6Ltf61ckYhPudWX6hjCFEpN7Q== 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=f3xuXwlCUGjay2jd/Xe0iuVmjixd6zIoi6QuvwS+Dt0=; b=FFSFgbsAJHRRQU/5nl0WkzR2yPLA6468o2Ar/CFfa5XIVUPXb8ZQS6aSxi4nA8dwa385JIP8YYtFIGfiCZWZyUdsv2Ti+D+CSeDzjJzCVF8Liy9zwC5QUzd0CVIUdpk6NFTiNqN3YSbbJk7ad7oRuLcXiwA1H2QlaEFpIZmuvsnDq+ekkpt7k9z83LcVXyyI/AFJ3xw2/24H3R64mvcTZrQiW+frz1a3MEiUIIDUbtmmKgUFo8s0n1fdsaciznn5leXK7lQajm23AM7MJ2Jc5ZbOyYVlSPM2ORm0WUGk3QAv6w5XFcJviRyVhT36M2g6OadLyHOkbKvh7taKmk4IFQ== Authentication-Results: mx.microsoft.com 1; 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 DS6PR12MB851160.namprd12.prod.outlook.com (2603:10b6:8:416::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Wed, 2 Dec 2026 16:37:36 +0000 Received: from IA0PR12MB8374.namprd12.prod.outlook.com ([fe80::d85f:4c87:ae84:3f16]) by IA0PR12MB8374.namprd12.prod.outlook.com ([fe80::d85f:4c87:ae84:3f16%6]) with mapi id 15.21.0688.010; Wed, 2 Dec 2026 16:37:36 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 02 Dec 2026 11:37:34 -0500 Message-Id: Subject: Re: [RFC PATCH] mm: madvise: don't split a PMD on partial THP MADV_DONTNEED Cc: "Baolin Wang" , "Liam R. Howlett" , "Nico Pache" , "Ryan Roberts" , "Dev Jain" , "Barry Song" , "Lance Yang" , "Usama Arif" , "Kiryl Shutsemau" , "Vlastimil Babka" , "Mike Rapoport" , "Michal Hocko" , "Lorenzo Stoakes" , "Suren Baghdasaryan" , "Shakeel Butt" , "Pedro Falcato" , "Jann Horn" , , To: "Alexandre Ghiti" , "Andrew Morton" , "David Hildenbrand" From: "Zi Yan" X-Mailer: aerc 0.22.0 References: <20261202102818.1317130-1-alex@ghiti.fr> In-Reply-To: <20261202102818.1317130-1-alex@ghiti.fr> X-ClientProxiedBy: YQBPR0101CA0334.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:6b::9) To IA0PR12MB8374.namprd12.prod.outlook.com (2603:10b6:208:40e::7) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PR12MB8374:EE_|DS6PR12MB851160:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f3a2169-3f34-4610-ef46-08df5092929b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|366016|1800799024|11063799006|6133799003|261009223027099003|3023799007|22082099003|18002099003|56012099006|10067099003|261102123227099003|261021121427099003|261021123027099003|261022075727099003|261022105027099003|261028144727099003|261026121527099003|261026140227099003; X-Microsoft-Antispam-Message-Info: 0gEJDdD/4gZio8QVgKPRb1edfYGr2LniOP0hHLW0YCslm9rGORyPUJGrPICS9FV5wXvQwabTNoO6JjF9I/f0Kvm18ZY3wjfJxl12uJ2DZXIIfOroho5Lr9sY/MOdFw8e0XZVpvbfe4pbacneRT6vEvvMWggiXRlAENMS+XANiPK7cNGiq5nNu0o7xytgwFigrKnGdzhy7h38LE+k+RwwWi8hyAAmrhl93BAnHGP2oKafaj52eaPZa2qMEs4T/L3L/4YENwx1Ri/hVbMb63oXzZMfYB+SZ4g91WhOTpgADKspIVQ9X7Ci6wLhcBRKSgqQppijHHizlVO7Njcgpakw1WPXHqE6me8yX1beT0VWAjAzAwhzCqV0IEXd3dIM2kifF0iN3UsnbRj1NiSVO7luQ+VKdMt3RGJZKCRCOPtz7UVaR1PonuulXZOcw9I3xIUpeiLSKgzVQ0feCEpDplLIYYAZs0QAudO2lp0MfkFrNGMzLXUPLkCPRbV7L60iYrQmESUjwcYUEaXtOqR2kmQobgK147Mh3EHCnBKCLqNCz3bsAds4dKgWGzGPq24lt8+imbmYSB/tn1vPK/KUeWHT94TJIh5ontk9B8ZFoO+eQrEHNYPjD87tD58+YIgPksxTsVvyqE4i+73TDyDEKQ8EU+oowNCmT/aC/38EmeXQ1ls= 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)(376014)(7416014)(23010399003)(366016)(1800799024)(11063799006)(6133799003)(261009223027099003)(3023799007)(22082099003)(18002099003)(56012099006)(10067099003)(261102123227099003)(261021121427099003)(261021123027099003)(261022075727099003)(261022105027099003)(261028144727099003)(261026121527099003)(261026140227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TXdwRXBXQ0d4VytxQU9DbWQyak8zbmI1U0FhMGFhdER4L29QeTdwOWR0ZktJ?= =?utf-8?B?TThvK01oUVlWcFZXWE5CVXEwNEhHM1VYWXk1ejFRNURjZWxVdFRXUnFDdURZ?= =?utf-8?B?K2ZOV3lmc21RcWtJSjlSU1ZnbzZHejBOVEZuOWlYbzM1UStleW82UTRPZnJw?= =?utf-8?B?Rko0TnlDcktYcDVWd0xMQ3pCYmFETzJLeWUzMEZtM00ycU10L0MzSXk1VjFE?= =?utf-8?B?VzdBSUFXSDh5WFRvUUdEZHdKMmozMDZmd2dpeFkxODF6ZnZqczJKKz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XBkQm1zaDlrN2pCR1I0U0FTcUg1RXRPb2JVcU5G?= =?utf-8?B?dS9OWTNDR3djaXNzdGxJM2J2R1dOcXZXb3dRVGFtZmZlVGR6RG8rd1FNQmlU?= =?utf-8?B?cC9wT0xXemVxT1ZuOC9WN3NEbXgwb3MxNm83N2dObXA3MjJ4UHQvT3J1TDly?= =?utf-8?B?N1ZoL0JOWE1pSWl2SnpIRWlaTllxem5DMUtXck1TanhtcjFkU0VPYkp3bzgw?= =?utf-8?Q?fI/Qo3ddmd2z3awPaX?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f3a2169-3f34-4610-ef46-08df5092929b X-MS-Exchange-CrossTenant-AuthSource: IA0PR12MB8374.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 16:37:36.6077 (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: 9DKLsci0LBivt9oAMeJEERnXq/PpzmAcgAnsd/8Oim6+2M4kypwKiylTz2qhiiHu X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS6PR12MB851160 On Wed Dec 2, 2026 at 5:28 AM EST, Alexandre Ghiti wrote: > MADV_DONTNEED on a range that covers only part of a PMD-mapped THP splits > the PMD and zaps the PTEs of the range. The THP itself is not freed: it > stays allocated and charged as a whole, now partially mapped, until the > deferred split shrinker splits it under memory pressure. Until then the > process has lost the PMD mapping, and the TLB reach that comes with it, f= or > no memory benefit. Why would you expect the PMD mapping still exists after DONTNEED marks part of a PMD THP? I do not think it is reasonable. Could someone abuse it by always allocating PMD THPs and DONTNEED part of it just to get PMD mappings? > > Besides, a THP is checked for being underused only once: it is queued on > the deferred split list when it is created, and the shrinker drops it fro= m > the list for good once it has found it not underused. A long-lived THP > whose pages are freed later is never looked at again, so its unused memor= y > can't be reclaimed. > > When the underused THP shrinker can reclaim the range later, zero it in > place instead: it reads as zeroes, as MADV_DONTNEED requires, and the PMD > mapping stays. The THP is queued again on the deferred split list, so the > shrinker looks at it again. > > For an exclusive anonymous THP, MADV_DONTNEED on part of it thus no longe= r > leaves it partially mapped: the range reads as zeroes at once, and the > memory is given back when reclaim needs it, once the THP holds more than > max_ptes_none zeroed pages. Below that, the THP is not split even under > memory pressure, where the partially mapped THP used to be split: it keep= s > up to max_ptes_none zeroed pages, the waste khugepaged already allows whe= n > collapsing. > > The range is zapped as before when the zeroed pages could not be freed, > e.g. with max_ptes_none at 511 (the default), or when anyone else may see > the THP, e.g. after fork or through a GUP pin. > > Results on a large production workload (THP=3Dalways, max_ptes_none=3D0, > allocator purging with MADV_DONTNEED), same allocator configuration befor= e > and after this patch: Since MADV_DONTNEED is slower, why is the perf not affected by it? The purge is done in the background? > > THPs and memory change > ------------------------------------ ------ > THPs partially mapped -97% > memory mapped by THPs (AnonHugePages) +29% > underused THP splits +145% > PMD splits +10% > workload anonymous memory +0.2% > > Performance change > ------------------------------------ ------ > p50 latency -1.7% > p99 latency -2.3% > throughput within noise > dTLB misses per instruction -0.4% > IPC +0.2% > > Signed-off-by: Alexandre Ghiti > --- > Open questions: > > - MADV_DONTNEED now zeroes the range synchronously, up to a whole PMD > minus one page (2M on x86, 512M with 64K base pages on arm64). Should > zeroing be capped, falling back to the split above some size? > > - A pin taken while the range is being zeroed goes unnoticed, as neither > GUP-fast nor GUP takes the folio lock: a device write through it (e.g. = an > O_DIRECT read into the range from another thread) can land after > MADV_DONTNEED returns. Only a process doing I/O into memory it is > discarding can see it; pins that exist when the THP is checked fall bac= k > to the zap. Closing the window would take a PMD invalidation and a TLB > flush per call, which this patch avoids, or GUP backing off on a folio > being zeroed. Is the race acceptable? > > - RSS (and so oom_badness()), /proc/pid/pagemap and mincore() keep showin= g > the range as resident until the THP is split, where the zap made it > disappear at once. memcg usage is unchanged: the THP stayed charged unt= il > its split before too. It affects userspace apps checking RSS stats. What is the impact? > > - The cow (THP_RUN_SINGLE_PTE), khugepaged and transhuge-stress selftests > use a partial MADV_DONTNEED to split a PMD, which MADV_DONTNEED never > guaranteed. khugepaged sets max_ptes_none to 511 first, but cow and > transhuge-stress keep the host's value: with a lower max_ptes_none they > still pass, while silently testing a PMD-mapped THP. They should pin > max_ptes_none or split the PMD explicitly (MADV_NOHUGEPAGE, mprotect() = or > debugfs). > > PTE-mapped large folios (mTHP) are left for later. > > include/linux/huge_mm.h | 2 ++ > include/linux/mm.h | 2 ++ > mm/huge_memory.c | 69 +++++++++++++++++++++++++++++++++++++++++ > mm/internal.h | 3 ++ > mm/madvise.c | 2 +- > mm/memory.c | 14 ++++++--- > 6 files changed, 87 insertions(+), 5 deletions(-) > --=20 Best Regards, Yan, Zi