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: 208265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp256364dyb; Thu, 29 Feb 2024 00:44:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfqkriR8BFD187sy3qS1dw1a7X5ogRub7DE7X5fm5BUgZnCpOZfGmAebUV8US9WDoeJbtHKYCUr2jw4/YAfMcE6Bki2Q== X-Google-Smtp-Source: AGHT+IE3YicJVejrLJF/dBWxvTWEicr6H690dRuMBFAeaZvaw1+ONonCJ6hF94cqxeUuNQdFSobI X-Received: by 2002:a17:903:2452:b0:1dc:b323:6f97 with SMTP id l18-20020a170903245200b001dcb3236f97mr1948024pls.27.1709196289368; Thu, 29 Feb 2024 00:44:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709196289; cv=pass; d=google.com; s=arc-20160816; b=DHwWiikPMV1yEXi4lHeCcOApMMm/54YZ6EkTK+9pV7ixgm8hrjXvEqJs0h7pxgMb/S Ww9QB0mvwkdh1/GfCWwIhuzWDFKRfU2+w39/tXLAjl+SxVIDS9ZEqjSNrxiqqUKokWxo DWi7sIrbAVdrY3eOOi8p5itzBpZYgg2iQ66P4sAGUuxyGEyDN3IDe99tbB+yEboSkDjp Ye4fHboiSi0VPU24WoZUsrLxmyFA4c9b6TmVN0lYhRC3+lBPhMlRJzwgNlNqGJgy+p3k Ygyqay6ny6Giww4k3PbBTG9Q51rpE12ySrcDNKfgBNU9g3qOsYsnhSgwjGKLoUkYwRL0 HTaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jnT5L9L6w21lKd8yQkJVObKwVcge77cGSeo5m2W2yic=; fh=El1CTPe6+vOT2yW37eQjyw83iSlqgqhE0Gpp/i8jhxo=; b=gTSM/lM4bO3Xi25q1PsxgMqwtaJhDTcX1ZigG9Cf6u2LZL70ADaF5WzOC+GIAwc3r0 TyEmEN0HZSq705XGCHY2Bl7KEPPWs6BS5Rq6zd/wB0uUbG9qmJppY1hWZP/b1fPLZASV 11qYQHJQ/g1aD6uNm7sl4MjUTGlkFl6pt/uzTcd9lDw7z/CJ4TNLfVr+uRfT5/RkCQ3+ MO3s6HxUH0w4Qv28rXJdaFRf3TiBPhMzJp0v8epeEwphPkjkv+toZjCbXJrBFiEO5nqH zPgPn4mCDukaHFgakz43lRGw+mYRHmOnGcL5iXe6VL2jG4s2XD+ppKlG4yWaQP0hhuEu BdNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A5hUWNJT; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-86330-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86330-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 15-20020a63124f000000b005dcae4c1ff8si914002pgs.131.2024.02.29.00.44.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 00:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86330-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A5hUWNJT; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-86330-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86330-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 342E1281E42 for ; Thu, 29 Feb 2024 08:44:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75F7B5478B; Thu, 29 Feb 2024 08:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A5hUWNJT" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E806D53807 for ; Thu, 29 Feb 2024 08:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709196216; cv=none; b=p0sR6CYf4BC+VkB/GZf+sEiCQ6u9hUy/kZwxqx+x3iRExxuq7GXSSmPbjx1rSx4vFpcB8TUQ3a+mqTD/4fSnDh40wEga1ZGupo7GEUuv3klkrq28+JOcv99WlXc/+slm84E5Kz9cA1ce+1Xv+Qf5xpc4uDflQeIglDEsNsExLVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709196216; c=relaxed/simple; bh=O05i6JF7XUFfS5IvQ0UbpArVDfLhD1s0LTIF086EXAs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KhM5p4GGLJVqZ+43tVOrtyommPJbjvRmeLNwWx21huTYDmZJiPyYmRwXnKWc4cszmZzpLFoiFfk+maEijvn/UBw4w9nR2AcSHXIaZMuoiUlgPkoE1TlD6DMhqnU/4+wPHABesNQ1SvvQLpjtOKuZcZFaUDkYUgbn23yrHjq9u3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A5hUWNJT; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709196214; 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=A5hUWNJTLtSAnqGur5kZXWT0SRKBTqbkbmcQuPGwf9q8I37NeJPzEwEZvLabVe0m721Hlo HKeyY0ncR1arv5NlJlgo1fej+7asdennqhGY4r3twmBq71qHG5jTzxgsRzh/VZbSfNaMck ou9Fz5W4rJpFGKJ5hM8Hv8lybWPyWEw= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792222208148629409 X-GMAIL-MSGID: 1792222208148629409 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;