From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A70B33054FB for ; Thu, 5 Feb 2026 18:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770314706; cv=none; b=YXxMzlfblnl/Ck0fQujA+XS/hQ+tlBbj1UiSksXEHzyUTNYT2B8q8y5c3noLkDmg6POXpSJPuCUOZI+q7BMa+9IVfcEI82JVEW3Rc2Chs3CY2p5mdH2nP89yswHbS9x/p4tgzpHY1/p7GZ+J/AkOOrO2WcTGX0DUCZvScdtieW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770314706; c=relaxed/simple; bh=i53us0wtTVWLjt4kG1sxFJfLdPctVB+1aB2+z8vsDx0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n6XyPfz19liFFh+adjA4Ddry2kPVMwPdXvtJV4U/drrgnLhpUnb2TCLjfSY20iQb0fjl1hdsp5ULSIHj+D5e3sy5U1HzumerRz7oHmCPBwFZWcHmRjAkQn5QjnsMxy0Pm0WDqEUf6xt0d8cr0/xbZBmQAmS026dvhmdGojW2mfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JRpf354+; arc=none smtp.client-ip=74.125.82.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JRpf354+" Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1249b9f5703so1987601c88.0 for ; Thu, 05 Feb 2026 10:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770314706; x=1770919506; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ytoSDeYyAfCO9B2aKhAb1H1lLRk7qH++Px7RKlZ8JF0=; b=JRpf354+cO5kSocmEeenr84rECQDTWrgVtnHaiJWK0qk2q63a8YEMwInz5Um0+JZTP 7qEkz5YuTR/VyCNL3yVp2QaGxKEZkMYAd332S0/Tc+kMYc0z7h8IDIwzj6NZ0xv7w6NZ naHJuwb5iVYKJjD8mARgHO2/j/y07F0PEjP+yCL4QX4sKyuJdXPgScIgSKic+O+/Thhh vDXUL2MlXLpaOG/NoogybglhknlexIDzNmBuAz8myhJ5EMDLxBvvZDpeznIQU9cB3UG7 TIHW0dfnMCIyEoh7+ikd0YdrWg4tHpHI53pKhmOOUaG0oMBuY0t/MNPE7lx0JXRLiK78 QCqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770314706; x=1770919506; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ytoSDeYyAfCO9B2aKhAb1H1lLRk7qH++Px7RKlZ8JF0=; b=l5+teFgdUdLQQ72efhS2ton/CNjjainvEfl60EtsSa1fbDPm7Gx343BDlaFkYsHNF7 zZzfCJR+WGOnsCfBFFK0QhURvWQl45eJ8xp4T2Vd4yypCMo4INjai5h7OxKdde05gL6e tsKgSoMoFMPvH/etWIf2YS95InVpd4q2mibdB7oqnVteB35JPZ4/uEAbRwZIwWoLkGz4 R46xcXIR/BWOMTD4rKABmuX3mM7IQl6fA8ILnuWCxWa3mErxxbZj4/m+NKu//06VspPA T+EjR6iBTJ5qDDuoAh7qVZPez1k2AKshPItv54/gA14snA95uZWRaN35yFCMwiEzmpAN dbMg== X-Forwarded-Encrypted: i=1; AJvYcCWwFA2vIqwjtk55Ed5jrxONxJY2HrZWz3bTEt3lbhxUNRJgwiFOKpYGlxXGX2qgHWkIxEy4ML0uIdjYg1A=@vger.kernel.org X-Gm-Message-State: AOJu0YxUL8w/QLAez4iAHTWO9L1xeZs90YsTOWQXEuPXPWTzLFTQz+7r hXHpcvRdj/n2OKSK1PitiKg30QhkLW5MT6RSOO8NRVcstN8GTBS8+GcC X-Gm-Gg: AZuq6aLnOkoHHiyVyXr9+vHhoIib/DNz2tH2sFMhMMkR0k8xaduk2YIHajBrFxUPXUm YiD1Fe3hlH9BySX5lgCGsnPkwa6GzLJxkADeBe6Cg33vO8O7ALBYkXZmaDUdZOEHlX345gFxStU kpYQ8DNSpLA+1LIGh7FIYxg/We5aKR49e4aJ+ERGXA2rgLYgzUPRTndEnn2PxW/1OTidGKFSSTJ yrnDEbHAs2Y9FZj1TRl3Fm2dDQjNvfTYy/IzvsbL9bwh9APO8+GLhDDadHBP/5jAvQ1r+ScaJN7 le+gN6J58TmjpzHlmqqrF3VSHXjpUU7JAIXbQHwqdc4XViW0rF2bY60UY0e41TtxgMaSETxjDMY Qtd3JtM4TmlSX63Oei1R3dPRYN8Na0+NnzptzoIAU6AsOjsTEP5fpzlsssy4tzQEFHUO40f5dSb gddyTTyxl/92DEl5HlR07CK8xvWZrN+A2iXVVOZeBy93CPMBhKirYYpsjFlOfDgw2v8A== X-Received: by 2002:a05:7022:61b:b0:11a:c387:1357 with SMTP id a92af1059eb24-12703f51563mr51355c88.16.1770314705552; Thu, 05 Feb 2026 10:05:05 -0800 (PST) Received: from ?IPV6:2a03:83e0:1151:15:1cc5:26fe:6b00:bcef? ([2620:10d:c090:500::3:b30e]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-126f5030df4sm4783574c88.9.2026.02.05.10.05.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Feb 2026 10:05:04 -0800 (PST) Message-ID: Date: Thu, 5 Feb 2026 10:05:03 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 01/12] mm: add PUD THP ptdesc and rmap support Content-Language: en-GB To: "David Hildenbrand (Arm)" , Matthew Wilcox Cc: Zi Yan , Kiryl Shutsemau , lorenzo.stoakes@oracle.com, Andrew Morton , linux-mm@kvack.org, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, npache@redhat.com, Liam.Howlett@oracle.com, ryan.roberts@arm.com, vbabka@suse.cz, lance.yang@linux.dev, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20260202005451.774496-1-usamaarif642@gmail.com> <20260202005451.774496-2-usamaarif642@gmail.com> <63D23D5F-AF35-4199-B52E-DFFC16DFDF91@nvidia.com> <05d5918f-b61b-4091-b8c6-20eebfffc3c4@gmail.com> <945064a3-b6ae-4257-afd7-5229cf8267a9@gmail.com> From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/02/2026 09:40, David Hildenbrand (Arm) wrote: > On 2/5/26 06:13, Usama Arif wrote: >> >> >> On 04/02/2026 20:21, Matthew Wilcox wrote: >>> On Thu, Feb 05, 2026 at 04:17:19AM +0000, Matthew Wilcox wrote: >>>> Why are you even talking about "the next series"?  The approach is >>>> wrong.  You need to put this POC aside and solve the problems that >>>> you've bypassed to create this POC. >> >> >> Ah is the issue the code duplication that Lorenzo has raised (ofcourse >> completely agree that there is quite a bit), the lru.next patch I did >> which hopefully [1] makes better, or investigating if it might be >> interferring with DAX/VFIO that Lorenzo pointed out (will ofcourse >> investigate before sending the next revision)? The mapcount work >> (I think David is working on this?) that is needed to allow splitting >> PUDs to PMD is completely a separate issue and can be tackled in parallel >> to this. > > I would enjoy seeing an investigation where we see what might have to be done to avoid preallocating page tables for anonymous memory THPs, and instead, try allocating them on demand when remapping. If allocation fails, it's just another -ENOMEM or -EAGAIN. > > That would not only reduce the page table overhead when using THPs, it would also avoid the preallocation of two levels like you need here. > > Maybe it's doable, maybe not. > > Last time I looked into it I was like "there must be a better way to achieve that" :) > > Spinlocks might require preallocating etc. Thanks for this! I am going to try and implement this now and stress test this as well for 2M THPs. I have access to some production workloads that use a lot of THPs as well and I can put counters to see how often this even happens in prod workloads. i.e. how often page table allocation even fails in 2M THPs if its done on demand instead of preallocating this. > > (as raised elsewhere, staring with shmem support avoid the page table problem) >