From patchwork Wed Feb 28 08:53:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13575059 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 1DB03C54E41 for ; Wed, 28 Feb 2024 08:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A2586B00A3; Wed, 28 Feb 2024 03:54:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 852266B00A4; Wed, 28 Feb 2024 03:54:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F3546B00A5; Wed, 28 Feb 2024 03:54:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5EF0C6B00A3 for ; Wed, 28 Feb 2024 03:54:19 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E7E3280F51 for ; Wed, 28 Feb 2024 08:54:18 +0000 (UTC) X-FDA: 81840600996.24.FEA6737 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 60D06A0009 for ; Wed, 28 Feb 2024 08:54:17 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GONEDGPF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1709110457; 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=jnT5L9L6w21lKd8yQkJVObKwVcge77cGSeo5m2W2yic=; b=o/6OYQuj24MghiKfkqOiFsN71Do6jxh4+QUmT8m19UWBL343FeTul3blYdUvcRf20ko526 fZmIbIDCdUyzc+RTGVYwnUuxzpHjKBJa5gJdCNVr4DpVIg/8NWJ2z8Db3++VqSzYz6WAY4 4JnI3NCmRt0D7xuKlmKQaLWjC2rtyXY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GONEDGPF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1709110457; a=rsa-sha256; cv=none; b=V/E14kUXTamf3w5NG5SA4JuAaffWN8PPdBArzqllDBMurqA/xg8ibQ02PoCA33y7nj9yjO UbApcSktJi7Su3lEa+ocTWBJO5A2QUfug5nsJesyiqPvR06Qck6du6E+4d1VfsaXtGEozw Gm+UaP2efWl4/TKG5YkCVC15yteVizg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709110456; 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=jnT5L9L6w21lKd8yQkJVObKwVcge77cGSeo5m2W2yic=; b=GONEDGPFNd54d2rEvmDkO/2Z+llFUe8AXEKUoBTS4iI7t0GJ3nEHUvt8Gf2F+tPaP1NRTK rmXk506sc4OtfH8z1aerUzoNP/ocZWgxyL2l3vHceJ3lzIM1RopOAOWK2fFR3hmKxy/5xG h0saPDLLQNVmFfaKa5xRdTcjBzBoCWY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-Fv_6LmWZM7-vrv7YNUZ9hA-1; Wed, 28 Feb 2024 03:54:15 -0500 X-MC-Unique: Fv_6LmWZM7-vrv7YNUZ9hA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 4FC341C0CCB9; Wed, 28 Feb 2024 08:54:14 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7920D200A382; Wed, 28 Feb 2024 08:54:07 +0000 (UTC) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Yang Shi , Muchun Song , Jason Gunthorpe , x86@kernel.org, "Kirill A . Shutemov" , linuxppc-dev@lists.ozlabs.org, Andrew Morton , peterx@redhat.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH 2/5] mm/x86: Replace p4d_large() with p4d_leaf() Date: Wed, 28 Feb 2024 16:53:47 +0800 Message-ID: <20240228085350.520953-3-peterx@redhat.com> In-Reply-To: <20240228085350.520953-1-peterx@redhat.com> References: <20240228085350.520953-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Rspam-User: X-Stat-Signature: t3ey4wtgyxt7ii33gpumwbwcueia5bu6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 60D06A0009 X-HE-Tag: 1709110457-38296 X-HE-Meta: U2FsdGVkX18nFFeADBfqR7WKvkvQ7FeUpyhIseGExUKIjin3VSGq/99od3nor4VslvqZd/BPbkD4q9CE0LorHWJ59uSWd7r+arKwhDOovirH+PnBbYUkicm/CMulp9pCo6JQCkcVYPrOXRApkOhS0thsprvTGn5mZoBsW3kb2jZ+BLy8Gld8tOJjWmVoU8oXWpyp3+kHZyQqz7VnG43vfpITK6bN3UyaqjP6Ln35RGwwKSduKqcZpfqgKfCztLC/fvL/vCxe7qIJ7Er+48RyJ+Xd2rpOzQQrNujHeWmSlFJB0GaW82tlgV+bd92+JZMA/IAV8YQuETgvmmhM8X2IAZ8ZjpDOfDJX3eLq3L3Q5wfuS5g/sBZeipHLnf+/0y115NLI5UjybBrzYzZF47MEmhcuz0Wj75a8hF1RqVcxKzo1g2OSxFfxLxkbnA1foiixw0S76U4D0OzhIg6UhHmd1tVfqNknyoVh6ezn80WAQZ8nKxkCa3xmrICzY39apjY0L4OKDTk+AlK2X6+dkFsUYLe2a3Pn0yPygN1tLFbHqHR/doTMwIQXhLQIdJJ4vnWdTaDK+cquDibw5jloA1v3BN9QPflbE3O9zVykwn9fgixp7Y9XzFN7eBij27vB/XWUhp9F/Ca9Hx1oyQDArckz08TGI5a/74E8oi9QHm8fBM1aJzFo5+xZdFbWzSbxZRk583YqOK72Afepe1geiVe4NuvAzP15qxbkR16EkVIveh42ZhVYzO50CAofwp3TDPapYC88apnHWhiOgDcYxVFuwTnQ2D/9EfTGi54OnxP0DdPYsEjEZspvsTBZHtukSfBhGDw4bxHo8pLOSRjG3N1Ggqc7qPAiuVwlGYuWXVQb+dL7UVoHocIgGOp/T3Sv/cdCTRHrOOz5B/QGjFkA9XPiNHOblQk5N//WrWsoaIQoANV4pTDxR3xNwFUuqOf6ZqOD 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 p4d_large() is always defined as p4d_leaf(). Merge their usages. Chose p4d_leaf() because p4d_leaf() is a global API, while p4d_large() is not. Only x86 has p4d_leaf() defined as of now. So it also means after this patch we removed all p4d_large() usages. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Signed-off-by: Peter Xu --- arch/x86/mm/fault.c | 4 ++-- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/pat/set_memory.c | 4 ++-- arch/x86/mm/pti.c | 2 +- arch/x86/power/hibernate.c | 2 +- arch/x86/xen/mmu_pv.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 679b09cfe241..8b69ce3f4115 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -368,7 +368,7 @@ static void dump_pagetable(unsigned long address) goto bad; pr_cont("P4D %lx ", p4d_val(*p4d)); - if (!p4d_present(*p4d) || p4d_large(*p4d)) + if (!p4d_present(*p4d) || p4d_leaf(*p4d)) goto out; pud = pud_offset(p4d, address); @@ -1039,7 +1039,7 @@ spurious_kernel_fault(unsigned long error_code, unsigned long address) if (!p4d_present(*p4d)) return 0; - if (p4d_large(*p4d)) + if (p4d_leaf(*p4d)) return spurious_kernel_fault_check(error_code, (pte_t *) p4d); pud = pud_offset(p4d, address); diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ebdbcae48011..d691e7992a9a 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1197,7 +1197,7 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end, if (!p4d_present(*p4d)) continue; - BUILD_BUG_ON(p4d_large(*p4d)); + BUILD_BUG_ON(p4d_leaf(*p4d)); pud_base = pud_offset(p4d, 0); remove_pud_table(pud_base, addr, next, altmap, direct); diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index e9b448d1b1b7..5359a9c88099 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -676,7 +676,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long address, return NULL; *level = PG_LEVEL_512G; - if (p4d_large(*p4d) || !p4d_present(*p4d)) + if (p4d_leaf(*p4d) || !p4d_present(*p4d)) return (pte_t *)p4d; pud = pud_offset(p4d, address); @@ -739,7 +739,7 @@ pmd_t *lookup_pmd_address(unsigned long address) return NULL; p4d = p4d_offset(pgd, address); - if (p4d_none(*p4d) || p4d_large(*p4d) || !p4d_present(*p4d)) + if (p4d_none(*p4d) || p4d_leaf(*p4d) || !p4d_present(*p4d)) return NULL; pud = pud_offset(p4d, address); diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 669ba1c345b3..dc0a81f5f60e 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address) if (!p4d) return NULL; - BUILD_BUG_ON(p4d_large(*p4d) != 0); + BUILD_BUG_ON(p4d_leaf(*p4d) != 0); if (p4d_none(*p4d)) { unsigned long new_pud_page = __get_free_page(gfp); if (WARN_ON_ONCE(!new_pud_page)) diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c index 6f955eb1e163..28153789f873 100644 --- a/arch/x86/power/hibernate.c +++ b/arch/x86/power/hibernate.c @@ -165,7 +165,7 @@ int relocate_restore_code(void) pgd = (pgd_t *)__va(read_cr3_pa()) + pgd_index(relocated_restore_code); p4d = p4d_offset(pgd, relocated_restore_code); - if (p4d_large(*p4d)) { + if (p4d_leaf(*p4d)) { set_p4d(p4d, __p4d(p4d_val(*p4d) & ~_PAGE_NX)); goto out; } diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index e21974f2cf2d..12a43a4abebf 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -1104,7 +1104,7 @@ static void __init xen_cleanmfnmap_p4d(p4d_t *p4d, bool unpin) pud_t *pud_tbl; int i; - if (p4d_large(*p4d)) { + if (p4d_leaf(*p4d)) { pa = p4d_val(*p4d) & PHYSICAL_PAGE_MASK; xen_free_ro_pages(pa, P4D_SIZE); return;