From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95EC9C3600C for ; Thu, 3 Apr 2025 20:46:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7CEF280004; Thu, 3 Apr 2025 16:46:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2B4C280001; Thu, 3 Apr 2025 16:46:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCC2B280004; Thu, 3 Apr 2025 16:46:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8F774280001 for ; Thu, 3 Apr 2025 16:46:22 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5DCA6573B0 for ; Thu, 3 Apr 2025 20:46:23 +0000 (UTC) X-FDA: 83293915446.28.5081335 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 9838C100017 for ; Thu, 3 Apr 2025 20:46:21 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743713181; a=rsa-sha256; cv=none; b=fMMqdZJpw9dMxLhPIObzQXcPrKZPaHNGScbW9/a98E5nsj/bLo1uzQoE8JfY8/XTTD5PWj fT4mjrHG8OAD922fQzaPxQSkvtqE1BRb/sMzN8dlTlyP5IcqQUHEVvNm8ZYI1LUhNMgy/7 twqiNDsBj/8FD0X90LDhz1BKY6ggN48= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743713181; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8p7Aws/P9dvI5z+9lQ4DbG5szIWXC+/dyd/6YwbBb4=; b=43tWvhbHy2OPfQiTTPQJaR/2Bfko9jzzAMtGwwRuFdmQpq00rYnhAYgbXYW+gm3IZdrA+g wWCgROLFzbgfln4g2BEruNFx2AjVibfwpLycWdNg7kB4A9GI7rqRVUEwPG/bE42xp5sx1j frfI+pcxg4vy2jTEwqgjlHg4YmIMTf8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4FF325C59B2; Thu, 3 Apr 2025 20:44:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A795EC4CEE3; Thu, 3 Apr 2025 20:46:16 +0000 (UTC) Date: Thu, 3 Apr 2025 21:46:13 +0100 From: Catalin Marinas To: Ryan Roberts Cc: Will Deacon , Pasha Tatashin , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , David Hildenbrand , "Matthew Wilcox (Oracle)" , Mark Rutland , Anshuman Khandual , Alexandre Ghiti , Kevin Brodsky , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/11] arm64: hugetlb: Cleanup huge_pte size discovery mechanisms Message-ID: References: <20250304150444.3788920-1-ryan.roberts@arm.com> <20250304150444.3788920-2-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250304150444.3788920-2-ryan.roberts@arm.com> X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9838C100017 X-Stat-Signature: 5p17uo4f5zksy59dnhcegjth1ok6o9by X-HE-Tag: 1743713181-743571 X-HE-Meta: U2FsdGVkX19a9Q80RLaeaL8TYJ3trIDng9yR4p+cRLx9DxJnlKzv5Tcc061QiMZZN9uw7hQQPt46MRdfWHln30MD6w2+5oFx5gi01nzWDw+XfSO6TIcVMzZ4ymjf8b7Rw4d3VlgMqoBTJOX0VyaEYoHXgP1nIxr546fHzEf8xF0c5ObCHK51JRaRNjBd1d90PBG6qLXol4WmRiftPMCItqwj40luDGea0dTBU5X7sOhOFbhPBnbqnhDpjwcqWnCQU023E7tLoAKe+EhieERy5aT9J4E30nmsqkpkRy7LEHVUfQb/97bbtgxuTJegU7vyrkt0oVLYNNhtee6471fpfleYmod/T3U9jbOgXIZjPXmbWJ+SUjnkYanRAsas6PE4/ERctZbGlyeUuXpt82UWpXnPcZ7LMEbD/blt8QSxE3IS4CLNkh6YFITIjLt3DAPFvozqvyNmuBulDzpjcG3yzFMxBshwWp/b5FijkcXuYto/5Zpal3W/TRIOFMpDgZUOLtNemVVed5jwbMuqNjS/C4LdYllbnV6eYtmVS74s67ieTDyj4uOACOe7P8U/zMyMH6Tlt+oMOZntOq9ncLuJDU3/QQ5oAIPv0Pzc/JNgGzCvnyxbIccDTBgUP8u/ZCDZHqjiX262/+hPWXx3o+yD+NJal782qrzyPHO9A3rkNy5A0sKzFNjYQQjwbYIp/obb494yDtbmIHBJ7QeHHt//Ie+wpf+BjFbobeu1pnYFCOQDST8W1uvlAD1iuHjSVYJ59gVkrOrPAn7+PMgcQawSGsTplfIr4gNgU89aA0f6aciUL6OHYhziFLEmY/c2JQ1dOMLs66slbr+W9xzOgBj5y8xon5iidROwKmUDJwOpg6TMuZapxbceRX2X3BUmjOikAGPxHaHMqLHRU23X+4IPrPBQFXRRiNuLY/w+s7CsW5H4caZVF0eEtBj+nZ8dh798k5bzZQshqAlIlDYic8Y ejPs/du4 k1fOnRbt8OcEQjOQQXVuo8Rdhr2GemA1o0o1hHoiqwj8BbrJCcJjmCXBK8YSk9ofdrAvntYEc6yw/A8pNNZ/iFbI9S097NfdFHp/ZUjVjSihHfDyQWdgvznIDFXQGhTn9CCBM/HUhtNNtvB9R8XIDCQqR4l8wm0PCgON/ulyByr0sZy0+TAhZTl7SpzhCzKxzqLAezW0eOOWcPKJHyOFQ28qnfzWFpAmW2CKtemUL0NFnkCT92vtxDFLKOZeLXS9wxzpIK+17+gpU9Dlqoi/FIhjO7oKnh5FhyR+uQW5YXPYSeVLmSvaSONv7VXqOXkCtqFQrHy4XF1lTRzdG+KHFAP8OTNupDNow+W/el9v7Wq0/JlcpUAJ1wJA8nbPCYQsXdNNOJT1t2liYr8DZzT1+ChGKZ/dXFXdamcnlHaYZSLI/ql16aQC4WTQ0S4eZahBpShEyjdA3M9tGx+I= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Mar 04, 2025 at 03:04:31PM +0000, Ryan Roberts wrote: > Not all huge_pte helper APIs explicitly provide the size of the > huge_pte. So the helpers have to depend on various methods to determine > the size of the huge_pte. Some of these methods are dubious. > > Let's clean up the code to use preferred methods and retire the dubious > ones. The options in order of preference: > > - If size is provided as parameter, use it together with > num_contig_ptes(). This is explicit and works for both present and > non-present ptes. > > - If vma is provided as a parameter, retrieve size via > huge_page_size(hstate_vma(vma)) and use it together with > num_contig_ptes(). This is explicit and works for both present and > non-present ptes. > > - If the pte is present and contiguous, use find_num_contig() to walk > the pgtable to find the level and infer the number of ptes from > level. Only works for *present* ptes. > > - If the pte is present and not contiguous and you can infer from this > that only 1 pte needs to be operated on. This is ok if you don't care > about the absolute size, and just want to know the number of ptes. > > - NEVER rely on resolving the PFN of a present pte to a folio and > getting the folio's size. This is fragile at best, because there is > nothing to stop the core-mm from allocating a folio twice as big as > the huge_pte then mapping it across 2 consecutive huge_ptes. Or just > partially mapping it. > > Where we require that the pte is present, add warnings if not-present. > > Signed-off-by: Ryan Roberts Reviewed-by: Catalin Marinas