From patchwork Thu Feb 29 08:42:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13576872 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 3CF8CC48BF6 for ; Thu, 29 Feb 2024 08:43:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEAC76B009C; Thu, 29 Feb 2024 03:43:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B72D26B00AB; Thu, 29 Feb 2024 03:43:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ECA86B00AC; Thu, 29 Feb 2024 03:43:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8B1FB6B009C for ; Thu, 29 Feb 2024 03:43:34 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5E288812C1 for ; Thu, 29 Feb 2024 08:43:34 +0000 (UTC) X-FDA: 81844202748.23.14D4CB1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id CC72E1C001B for ; Thu, 29 Feb 2024 08:43:32 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NZPJGuEX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1709196212; 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=CSBYyOvSdvhDEAe0E3KqD1mexj9bMr2/FpacR1B992cY9t0u/Z7NgnKZm8R1EzJUb1Fj1y rnreNIAlsUnRNeIlU5DwQ5kfw40LcG96RudrVbqt8L5uozhFC217o1IOaU5nIeEnJSEz3w jfglUYbX8tjyGb+QSBkDO3PVmJp2vbw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NZPJGuEX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709196212; a=rsa-sha256; cv=none; b=8UhBn98XMwOzQWs41+Sjc3kmaQadWXNv0DPp3R0g6QGZKbgL3ZRlDfLM6yrRAiWbsMeclZ vG9q/CrMrO5REg5Xx7w7Y7EnhEb8z2kjumcmOZcUUgLTB0m83GBKGQFirGjwzvZA8keh23 tYWC1b5P0zImB/67GkLFQhrypnaiLFM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709196212; 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=NZPJGuEXurCacJoP4cwEFIJogOkfnD5AadtmJxLd4N3fpAq3a/xF7JaojagkSj1uDYoIId uAGoj62yE+jPSlYbqEHNPDCANQ0wVm1eSQz/VRJbu0UY/ZodvAut9nvT4/JoOLDSQmfzDw WAGH8sY1LD4cy6ag1uOF0amM05dEdfs= 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-7-XVRBeMQtPOS0aNn2-IbSjA-1; Thu, 29 Feb 2024 03:43:30 -0500 X-MC-Unique: XVRBeMQtPOS0aNn2-IbSjA-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 4FD4485A58A; Thu, 29 Feb 2024 08:43:29 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D063428D; Thu, 29 Feb 2024 08:43:22 +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, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH v2 3/7] mm/x86: Replace p4d_large() with p4d_leaf() Date: Thu, 29 Feb 2024 16:42:54 +0800 Message-ID: <20240229084258.599774-4-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-Rspam-User: X-Stat-Signature: 4ab5hw53deuz4ttucapcgfbyzcgt3isk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CC72E1C001B X-HE-Tag: 1709196212-433912 X-HE-Meta: U2FsdGVkX1+kWh1atAvo0hVZkk6mpWM3L+emulMpkyHabhCkR2rwLI7v/XYKyNt+gK153H15gw4AZQNks/jjo87lPcy74PZjF7EWXYObrcl4YDghilU7nw5aDcWNEVvfy7A7R+VGosfvMciiIkCUETd029xcerZpRNmVoBPVGB6SddUn3wr0SqgWjIMIBr44+aq3YheoDSiCAlKtbl7XWQTtqKV9l2TBD4xdAO3aLfz2PxDbNauJjlQGzSeLmcTJCiAujitp8ZQRMU6gSQh4TzWstqt/tIwaT9GB8fTzfyFhN7487XX+ST8Q02xsUDNgoLAXWvTSrbnT32iNd2KvRAVIZFjsbuxDd4vhkbJaoBQfP2j1vZlCn4zfBIo8iDc8hkipGySGtvCfYd9Q6FjH7EexN4z6NbfkD95wtxBhCuslURwUetXLnqMYDK3PVS0dUEPjSnB5xmVT1MG5T+UOZTtPENHn+9o6Es6y0RTwAlSjRCviossTkwdEYv9OKmF7aIst3VYzSW7ht1nEXKpwNd4apSFTQEuW/F7j01ApeFqgYEJuLcGYDOuydJ/6ahBDBV8x4EKg8ygtIvE7+pHk6c31PswSRMm32WOMxFHVLLRj4lmpCnjpVtCgJymnyATmZomE3HxX7AeoeHUV650AYotTmV191lqUzDTYFG3kFb2VJ2mnDlRRKdxbxlfvE7MuXahncPgRRxc/SY5l+nlr6lvPlzf1J3n7r3ldgPFH1bRpxbwcJM4vx1Cfz/rsffm2JopU2tFwsWAbyk3YJSEck/fJ3dWlOJ1uPwnbEcknTeJTy/VBHrpHVyn8XpfCf2IRCTXMCj7jiiDgBS0vnuPVRVIlDg6w+naTCC/YZFGTYCXsahivK5DhmFsehf7UXf/oY6Qxx3NKy7MKJFrtzCXqOgxNqR2wPOnuJcefOkeyTVd3mpG1mMiMqsVscWHzY04V 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 Reviewed-by: Jason Gunthorpe --- 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;