From patchwork Thu Feb 29 08:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13576870 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 EEB41C54E41 for ; Thu, 29 Feb 2024 08:43:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8417F6B00A9; Thu, 29 Feb 2024 03:43:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C8806B00AA; Thu, 29 Feb 2024 03:43:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B83A6B00AB; Thu, 29 Feb 2024 03:43:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5ADB76B00A9 for ; Thu, 29 Feb 2024 03:43:22 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 27BFEA1B01 for ; Thu, 29 Feb 2024 08:43:22 +0000 (UTC) X-FDA: 81844202244.02.24A2762 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 97443140012 for ; Thu, 29 Feb 2024 08:43:19 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pe+aF9Pz; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709196199; 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=ZJJ0eqDZ1S0vUv+Nro3fA2Y1PjBXchWPHo5qT9tenrk=; b=Z5NM32t3uunM6vrv9FIHYnLgwx6iMoRHTADagJx+Sub0Jy3HWdQUfItpf3HT6fIjX3g2c2 grryNLkCyAzInIZPBeOAmx7bSRPKG3Kknn/7lksldhzMVcQhCU2dAAG3+ODExVZX2reR+A AtLroIIPwzRKBrgDlkLtfxaw/FmsXC8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709196199; a=rsa-sha256; cv=none; b=uwGPG/ZtoiDo8/1BFmq6rA8kr7aSP2p4tzwXAHcCIL4kw0ArMsoJc5ta1i/TkfxqhiftFu GaH7fIRIra7TT1wwRyzsb/zwkzySwLoA6/FDZ+afl33A+3ijaH4QTLxt8F9z7Qqvog+gOL nfJIxGzxQsQ9NtGjbPTWcBd0D1tZHH4= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pe+aF9Pz; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709196198; 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=ZJJ0eqDZ1S0vUv+Nro3fA2Y1PjBXchWPHo5qT9tenrk=; b=Pe+aF9PzLjzvPBZVCfgihK8dTnGamMHT4s7guZAMAfLQB9CkTUA61Aix9QMlxgM0l7+bxV QypPuDGsoqDW7MWbWLCMz8hsKZx5W3GAbT4FxNovgy25SqQx2EVCKrX+r8emS+fIz1eD2m eVVnVKN1KiIBcZlHdsrh0IXm7zMRKoA= 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-160-nrzUiLqfPF6NDPYG9jg0YA-1; Thu, 29 Feb 2024 03:43:15 -0500 X-MC-Unique: nrzUiLqfPF6NDPYG9jg0YA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 7393383BA86; Thu, 29 Feb 2024 08:43:14 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7863E28D; Thu, 29 Feb 2024 08:43:07 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Yang Shi , "Kirill A . Shutemov" , Jason Gunthorpe , peterx@redhat.com, Muchun Song , Andrew Morton , x86@kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" Subject: [PATCH v2 1/7] mm/ppc: Define pXd_large() with pXd_leaf() Date: Thu, 29 Feb 2024 16:42:52 +0800 Message-ID: <20240229084258.599774-2-peterx@redhat.com> In-Reply-To: <20240229084258.599774-1-peterx@redhat.com> References: <20240229084258.599774-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: 97443140012 X-Rspam-User: X-Stat-Signature: errtzq4h4gfcspkoyrt3ssto8knbbf1r X-Rspamd-Server: rspam03 X-HE-Tag: 1709196199-433272 X-HE-Meta: U2FsdGVkX1/V+k5J1c10x2sDHigcRlaEl+pqqAjV7Vt2ZzeIuRyMHhhiguFo66onZFxLf5FB/E682ntVMuO7yntQFur6aQiDfWOClxI8p6PPF64rW06UcTJLyIlne6I3ZqWNz/P1HP11JNVl+ByXfLYBiA28fATTVCS67AvlUl3bjz1Zdp/15k9N7fo4UE/WQ2iR9e5YyIMCxcjBwx03ygx5GoYzuxw0DPvqOHWvA3TCod5l1rF3uFv8qThP9FoRiFhaGSUQnUmU0zJXwNscd04WEJdxE2mrsBi2dAlv/cUPP8h2ywZjsagAkLLkop3UA9d+pXEqrCVOWrc8rCb59TPfVtdXiNd9510u4sU1lNbEZwXqDFoj8zGswc1O71fMWFREKRGxiYMHX6lTTKioUaEJP6nN/lhsWAUWKMKn3ZVsSg9puoRnsXj6fTFLRPDMVfTVMhkAhIegbp1wNxqAdx7aPw4AnnXnDjGvnkthzK1kN205MlPqf1oJSDg6kMmbeKAsP7qSPZStUuaKaIT3aVtLWBgTAFCaxGB2uX+YkuTPrdjaUAjplmiet7vT6DYgedGBCL1i05Iuv0KyzSqtGAH24cbwqOqrIZ4IMVDhXmgCL3XUvKwkVkW/8enEnTG4ftxFh0Pz5s91e9o5/eH0XIbfwFHOKIVwBMKl/rzMkzHIBLe9IYF15d89GdN3HBzdEZmv0UHp5jamSxrxXU5aPu3s0ybMNNL+C/VItf/9pwF3w8M+5CKgNhMemmXYWADNWraSHrbVyNqvv3Ev9XpBJ/2LP1QEVGllMXs4pBc/4EIjD4pjW049ShFDUgkFHBSdb96JKE+W75nWZmDewO+noSTtjrfM9Uwzns8IEcKhx+wC3hDn3eb2PSAiEOUfEmd/zGTvx9yYbOdrFKuWuhy5Ogdlp2kWfT+BRkZ07sH+t2NL8BOd5pQTRUWGBNqM+Lbn 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 The two definitions are the same. The only difference is that pXd_large() is only defined with THP selected, and only on book3s 64bits. Instead of implementing it twice, make pXd_large() a macro to pXd_leaf(). Define it unconditionally just like pXd_leaf(). This helps to prepare merging the two APIs. 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 Reviewed-by: Jason Gunthorpe --- arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++-------------- arch/powerpc/include/asm/pgtable.h | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 927d585652bc..d1318e8582ac 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned long addr, pud_t *pudp, return pud_val(*pudp); } -/* - * returns true for pmd migration entries, THP, devmap, hugetlb - * But compile time dependent on THP config - */ -static inline int pmd_large(pmd_t pmd) -{ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - -static inline int pud_large(pud_t pud) -{ - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); -} - /* * For radix we should always find H_PAGE_HASHPTE zero. Hence * the below will work for radix too @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va */ #define pmd_is_leaf pmd_is_leaf #define pmd_leaf pmd_is_leaf +#define pmd_large pmd_leaf static inline bool pmd_is_leaf(pmd_t pmd) { return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd) #define pud_is_leaf pud_is_leaf #define pud_leaf pud_is_leaf +#define pud_large pud_leaf static inline bool pud_is_leaf(pud_t pud) { return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 7a1ba8889aea..5928b3c1458d 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -101,7 +101,7 @@ void poking_init(void); extern unsigned long ioremap_bot; extern const pgprot_t protection_map[16]; -#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#ifndef pmd_large #define pmd_large(pmd) 0 #endif