From patchwork Wed Mar 6 10:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583881 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 448B5C54E41 for ; Wed, 6 Mar 2024 10:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C83E56B00A6; Wed, 6 Mar 2024 05:43:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C33CE6B00A7; Wed, 6 Mar 2024 05:43:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD43E6B00A8; Wed, 6 Mar 2024 05:43:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 973906B00A6 for ; Wed, 6 Mar 2024 05:43:18 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 790EFA0BC2 for ; Wed, 6 Mar 2024 10:43:18 +0000 (UTC) X-FDA: 81866277276.06.4B2FF0D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id BD1F14000A for ; Wed, 6 Mar 2024 10:43:16 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPuFoIgI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721796; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Kmh1r8OzIBeRtjZdwvZUDbG8Rg7aEeeC8h0p+1IZUgI=; b=NCtPFQ/49yEU478U+LZ+D67yUMRBmsY/BsnLdUA7hiivYaj+ZqOq8mJyJA4lBHjL0lCqsO euTTMIM24N4sEj9SV83s776BwvZsypCeaaW1CRHXVJy2PzSgzshV39ULsA5ABI6pxu1LqT F6pvKiiEmETfcH4BAUphHbsSgjVed5U= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPuFoIgI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721796; a=rsa-sha256; cv=none; b=gljr8qrfjuBoAtbSvgJWxHMw4NP6qnMLha7kpLf42pnrmrrP5Q55q6iiQTYB4yUJRMkl+u uFIzi0lfn94b07fMnh+XwP17gpY6JY+wvX0SeKgX0ynZEMkMkaBIuQ928s1yEbTOAbVSEH cV10ySKYYZWH1lIDWDE9zVe6HjlOBr4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kmh1r8OzIBeRtjZdwvZUDbG8Rg7aEeeC8h0p+1IZUgI=; b=PPuFoIgIiKciUD+TSkStwFywxOLWqi9gs/5XWHMggSk0LMOg8VhvWqVe6RZWeiJRzQ3yin bZCoCdewUkBuJEmLRimwe+TL+R3p4gG0Jk7PYB5WWRV4sytZ84OSUjcrWWAzGla7X8bWgz 2oGN7RQuEWkii+yw49V1UDeKWq5LTr0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-28RiKZlpPQu-76jARwQEkw-1; Wed, 06 Mar 2024 05:43:10 -0500 X-MC-Unique: 28RiKZlpPQu-76jARwQEkw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13B1C8007A7; Wed, 6 Mar 2024 10:43:10 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294B5111DD03; Wed, 6 Mar 2024 10:43:01 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , Muchun Song , Jason Gunthorpe , peterx@redhat.com, Matthew Wilcox , Mike Rapoport , Christophe Leroy , x86@kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" Subject: [PATCH RFC 09/13] mm/powerpc: Redefine pXd_huge() with pXd_leaf() Date: Wed, 6 Mar 2024 18:41:43 +0800 Message-ID: <20240306104147.193052-10-peterx@redhat.com> In-Reply-To: <20240306104147.193052-1-peterx@redhat.com> References: <20240306104147.193052-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspam-User: X-Stat-Signature: k4tw43gku7eee1ddehfmmsccg53w7wp1 X-Rspamd-Server: rspam07 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JCSzF3/SXIfru7dUu9nnt2b9DlgIw81Vt+8Y/W4lc2421xhd2MWpfoZvb8NsIkRskzYVAZjax23+6rcsckheaDPsj5duEXj7WbgJ7NCwx3uvEsEs/n++LFMT630obXn2kv05o2ajNLbdOlW+g22Su1jYZZnoBnHE0UwTKsIxHouaGqmSMEXxktLEH7gEbhx+MAmjTxd9zPBYNsDXtYziqP7l0dHg67hHYJXG+kP89KXjH7J7E8akTzDXIXu7cK7wAOxMjXJOG24Vl9R+56UPJy3eE7KV/6IvKN5QmFLwZL4gmsvx1UBdSiGJ80obi6P/69Yzq67z/Bt8djyrBHWMT0C+3+oEaomx9iJdvi6323p8KEWq67Q7qSj2QcGHRBRIhWFipA1JS3MkMnphk2AJGCp13kJIlT6b3tM+a+nAdI0 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: From: Peter Xu PowerPC book3s 4K mostly has the same definition on both, except pXd_huge() constantly returns 0 for hash MMUs. AFAICT that is fine to be removed, because pXd_huge() reflects a hugetlb entry, while it's own hugetlb pgtable lookup function (__find_linux_pte() shared by all powerpc code) already use pXd_leaf() irrelevant of the MMU type. It means pXd_leaf() should work all fine with hash MMU pgtables or something could already went wrong. The goal should be that we will have one API pXd_leaf() to detect all kinds of huge mappings. AFAICT we need to use the pXd_leaf() impl (rather than pXd_huge() ones) to make sure ie. THPs on hash MMU will also return true. This helps to simplify a follow up patch to drop pXd_huge() treewide. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: "Naveen N. Rao" Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Peter Xu Signed-off-by: Peter Xu --- arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h index 48f21820afe2..92545981bb49 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h @@ -8,22 +8,12 @@ #ifdef CONFIG_HUGETLB_PAGE static inline int pmd_huge(pmd_t pmd) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pmd_leaf(pmd); } static inline int pud_huge(pud_t pud) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pud_leaf(pud); } /*