Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp212868lqe; Thu, 4 Apr 2024 04:47:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfDfPBcr2QHuntyo3Ymnue+yeKyvj7L9IWpGxlmR28QoN9lQa3hzIxPIpngySKhWRDgcyBrwNrYYILPrNPtgm3fd4d6nd0BL0C4Gw8rg== X-Google-Smtp-Source: AGHT+IH62dwKldt+MI6dVtU7iCtPr/ISZ4FOElB9YLB0QM3kosGPI3MGsyHjGaZCA2f7pqvRXdst X-Received: by 2002:a17:907:77cc:b0:a4e:3956:6ad8 with SMTP id kz12-20020a17090777cc00b00a4e39566ad8mr1389466ejc.44.1712231229566; Thu, 04 Apr 2024 04:47:09 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f25-20020a1709067f9900b00a4742939459si7337118ejr.349.2024.04.04.04.47.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131328-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Hbua/KuA"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-131328-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131328-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1F0431F2BD32 for ; Thu, 4 Apr 2024 11:47:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF45A84A3E; Thu, 4 Apr 2024 11:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Hbua/KuA" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2096.outbound.protection.outlook.com [40.107.243.96]) (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 E91747350E for ; Thu, 4 Apr 2024 11:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.96 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231221; cv=fail; b=jz8wZ6jEUfbRptFG5HrLwj5Q735IHBPDowCHh7VT35xYy6E1kgJd5gKD/jHwrmgpyEL9vTokT+yJT2pyp7lPSTfR0LmlMrKbnxeaF4r1nDbvrGu0K4xR1R+2HDWP3Zr16h0hnUlPecAlVsMKGmQLBoFgVHz87VrbXix0u75tRnk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231221; c=relaxed/simple; bh=XZ9h77NZBBeryhk3Wi2RsXl7df8cxABvkFWrJvGQILc=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=nCu1NTPmaUQ/xFMnxjWLHr1I+cK1LchQxWlfG/FPtMeh4eoI6HjrkXJziFwqibMzm5rYTR04kTlHbp+8t7fSlP55nAY2ikruMpLi5jIxw7KFUVRAIWg/2JA+toFAoAFIC7I2cHnzcbk04qVEC62oeFL+nTOWGBLhjJtRpzLGcIo= 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=Hbua/KuA; arc=fail smtp.client-ip=40.107.243.96 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ODPKaqFV67ojdM6EHR2zBK6avAqhQmHp64G6dZcXRA7EmjhoUeLQRJ6k3PT0n3MeBbLcU7daYUyBGAQe9mhPg0LGgLsFC6fuFACEJJ4nx125qkEQu5KsB/Wy5/WHBH8UIfedcb0ci0IsxWJR7cIuGgYWEf3aDQwh+k11x2khIL2Oknih6AMQO3AtYn8hZ9lRocLuIgjt4cSF321n7gszRVCP/FsrcwwNukq0q9FsP/N1zyTzCgsUCfJM8EVuOoYVkannxXr9V8pjChaS/PAl4cTIvTWgOOYWbr4DvkLdVCiUplzajiioICG/DyZPo9lPrsjNLb58y0RxjyhSpHNXEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=jDVLRVBwfIkXrIF5Slkpfvy2bGm9/+fZdo83oNPsJd8=; b=fkti/VWT4VARHkUlNMBk2Qtpk2m2v6MpaHuFFJ9ICogPBuSLLdT/EYgw/rTciAt46iOQPY0tV4Ge38hz+fD+uXUupseiHvNx5HbFqhfYat0aCyuaVZce3uF1KsX3BEPceT377//0Bq7WK7SgvOBv1qj9xLQ0ljIYIWgTXKAqbcYLyp9gc3aJ39bgWLXQ9vdaR5MhMlAAVaHBX3rJxSGAZ9IdfcOsLm6B3Mg0zcMkDthxKC+pVJQAS4DjFEmAdA8Lfzs+3us6Kda0kFLTise9sUL+AjeiSgjdsepEfHSI/CT4/Oisv+DOpheBCOA8Uzy+839WA8+G+xOH10Dj66NfiQ== 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=jDVLRVBwfIkXrIF5Slkpfvy2bGm9/+fZdo83oNPsJd8=; b=Hbua/KuAviEZqzrX9Db3EqF0Y6XNI6Av50ruGBl1vTJjTcW/q4yEzYPvcLsNMaNWa/MsVghOcKZ1LK5NqiednmTqPlwPNZWhE83sAv6lBHXcUvciGTiFX/iViODzFI+ulhCWAMZ5qF6iku+zgVtoGpEwwDG8CNENjx87QlYZSEluIKJgcbUzz53upkvNkDX2mnCrTxxF7hxqmPUVo/bg/G/SwVePwuzqbH9/2zt9hJr6bhJ20OBmHi+JLe+Ut19WFd75cZ6+vwBNOICnEjJyp6+4UV5y1n5bmmdy4VzyW0LuU9vdk4udtn4p3SrxbusDa7NMr9oQA03TmdhJ1Spl6g== Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by SJ2PR12MB8181.namprd12.prod.outlook.com (2603:10b6:a03:4f6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Thu, 4 Apr 2024 11:46:54 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222%5]) with mapi id 15.20.7409.042; Thu, 4 Apr 2024 11:46:54 +0000 Date: Thu, 4 Apr 2024 08:46:52 -0300 From: Jason Gunthorpe To: Christophe Leroy Cc: Andrew Morton , Peter Xu , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [RFC PATCH 1/8] mm: Provide pagesize to pmd_populate() Message-ID: <20240404114652.GH1723999@nvidia.com> References: <54d78f1b7e7f1c671e40b7c0c637380bcb834326.1711377230.git.christophe.leroy@csgroup.eu> <20240325161919.GD6245@nvidia.com> <6e16e042-0143-4a52-b4b7-09cf0022bc3e@csgroup.eu> <20240326150118.GI6245@nvidia.com> <9703878c-c0b0-48ff-a356-d43e8f7391f3@csgroup.eu> <20240327165754.GM946323@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SN1PR12CA0111.namprd12.prod.outlook.com (2603:10b6:802:21::46) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) 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: DM6PR12MB3849:EE_|SJ2PR12MB8181:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzrcdYRsrt+a6W34Ub9erLYosw44ewQGVz6o+anmHnLVLWpnd7OvyIGyhu+2PAzdm6E5ttVX8q2Y43lmy+q0pcqTdM7wXdQIN44AgkGhY+72hc+1jcklNlj0JAKoYTg6CJncHG6MngYFMj+xG9Ch1rRfB+RsskBdAdti+iEoyvUnYQEBCY9mNpRbp7zeUzZqoc/iX12gr8lN3meSVrcJ/kCFSz4YGzu/XVd+gt9Qb1fr/mHQ/PGe939v6uEacPO/4/7cBkZdzxMx2Fy5bJ50W3HdXg4hgmCqH1WUAnIdRcQ9wc5nIY0NeszmXz8SGgIxP9JVofhkvEEfqLEHYqrZedW49+24WobXXkH6EM7OqfcS/TPq9HlsunzIiLLMAGyMRDD/bh1Kw6+KvLfnnkekEhuX/LpCnGNkU531luWh47XRkeKcgICQoCLvgDsH/e5/2wC7JuGYUMW3+edblgWwODs1NCQ0yNCpjzCy0VpCJ2IUzapijioooH8Ny2yXVGVbNcHlnjyGoxG++cTPj5sOg5/IM8DI33HrrHSW9Ladc9IZRmPdbCiFF92x4X/stJF1GbmQQTFc9i/84uPGEtRXl40DdMISZQ03Yco1cbSafgqAJ49MJnFFgBulSWDzBYvaPxvpiAwzFW7frVyCzXbFFK7zZK+vk9+TbPDgLLHu/3E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(366007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?h8seUJdKwMtAS1IeSuM0VDx1Ky8IF28eKjAYNE0xQLuSCa6dI9HDKbuk0p7x?= =?us-ascii?Q?kacRGlUqz8G6B9IUy/AE1UYSPEAXm89UxCfyfI/E63ffGxOBFDUb5qVdoKVk?= =?us-ascii?Q?BqHYNrU3eEiOQ/YCv2E7UeBKGpWmlZbIZw9UqS2Aol65kA1FH/d0gQ7GRcoW?= =?us-ascii?Q?jq3L6LIClJnwr4+Jtxr7BkgB8xvBPj4ynpk9nXjStzaD1uRpvTRU3pJmYJDO?= =?us-ascii?Q?cqUCIAeNL20FEpDNr8K+nzvIE4ZO0D6WFnC51E5lX7ouNE9L+MUbQIdT11BK?= =?us-ascii?Q?RvXjxdtKF4s77rphsXoTcfXb43pHgD4PknlYVBMZ2zhWI6YIuIzVhTmkbH0f?= =?us-ascii?Q?PaklWN4r2m23eM06RypdI35Dc5VaXFoETJRmgKcfch4A0lGrYGJWaDPc2vxa?= =?us-ascii?Q?zEOxeHpLyGUkD+lSG8qFJjur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?us-ascii?Q?ydT/m5DcJiNT5x3PMVAWY5EmKzCjfVagX3x60kipXSL25jdey8B+D60Dk66A?= =?us-ascii?Q?z78ONkAsDp1TomO2zXmC8CMD1LPKfPnxC4M5BwroirPBwativxRJVjoB30w0?= =?us-ascii?Q?Y7s3r/td+eqH7Py55TxbnTVfCagH1icBhVHd73JOz9VZKwftG7bX4xTSGfX7?= =?us-ascii?Q?GncfPOPScARf+vXgPVlhAKeT4YM7kEKI90ultnkxTT3noM8m4y3F1XTpK7NB?= =?us-ascii?Q?WQ5CuxXPsii9u6NbFaPAr2SmfjDecdSKaQId07Pw?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0d3243b-4ac3-4cce-bd86-08dc549cecc3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 11:46:54.5446 (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: R6caJb69MrWzhHBQAny8WVnrggL9DzUPmCGUEFtgFEBrl/ds/OxNTD2n01/AkwQy X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8181 On Wed, Apr 03, 2024 at 06:24:38PM +0000, Christophe Leroy wrote: > > If it is a software walker there might be value in just aligning to > > the contig pte scheme in all levels and forgetting about the variable > > size page table levels. That quarter page stuff is a PITA to manage > > the memory allocation for on PPC anyhow.. > > Looking one step further, into nohash/32, I see a challenge: on that > platform, a PTE is 64 bits while a PGD/PMD entry is 32 bits. It is > therefore not possible as such to do PMD leaf or cont-PMD leaf. Hmm, maybe not, I have a feeling you can hide this detail in the pmd_offset routine if you pass in the PGD information too. > - Double the size of PGD/PMD entries, but then we loose atomicity when > reading or writing an entry, could this be a problem ? How does the 64 bit PTE work then? We have ignored this bug on x86 32 bit, but there is a general difficult race with 64 bit atomicity on 32 bit CPUs in the page tables. Ideally you'd have 64 bit entries at the PMD level that encode the page size the same as the PTE level. So you hit any level and you know your size. This is less memory efficient (though every other arch tolerates this) in general cases. Can you throw away some bits of PA in the 32 bit entries to signal a size? > - Do as for the 8xx, ie go down to PTEs even for pages greater than 4M. Aside from the memory waste, this is the most logical thing, go down far enough that you can encode the desired page size in the PTE and use the contig PTE scheme. Jason