From patchwork Mon Dec 23 09:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13918642 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 40B94E7718B for ; Mon, 23 Dec 2024 09:43:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB0076B008C; Mon, 23 Dec 2024 04:43:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5F606B0092; Mon, 23 Dec 2024 04:43:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD91E6B0093; Mon, 23 Dec 2024 04:43:32 -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 8DB4A6B008C for ; Mon, 23 Dec 2024 04:43:32 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0C867C1577 for ; Mon, 23 Dec 2024 09:43:32 +0000 (UTC) X-FDA: 82925735130.24.E89B71E Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf11.hostedemail.com (Postfix) with ESMTP id 84E3040017 for ; Mon, 23 Dec 2024 09:42:55 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=PO6+u1LE; spf=pass (imf11.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734946974; a=rsa-sha256; cv=none; b=O16l7vYVeT2IW7t6yEAaZQX08AO/Ay4o7GeOUSc62FloKTwCkWZORm3/juBTDTv/XlESvc kpW/bkEqwaliDCdXInNMtSkVYyagksJkx4IOu5Mu1HRznuhhoQbEM7JlUlMADIoybMX3iu bvAQB2YQJXbSj3CXm/m4lTWyNxuUAQE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=PO6+u1LE; spf=pass (imf11.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734946974; 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=B/tJ15+vmer/NbqXoUznjybhQp/MgC6GOdT/GuQUXpM=; b=xXUUTssef09jGiFE0wVitdOKcQuzLHs9L8euA0FVwKR+bMxdidHAroHiU0oQcB8ImvdEsC c6R0WzQFjWZqwy4Gds8nlbQJ2MNI52ggooLSqWB6AtD4Iu3Q6KYbVpLab9/al3Io8wRBLN QR5El9h2gDkVD67jY2nexyUWQHz6n9g= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-725c86bbae7so3476783b3a.3 for ; Mon, 23 Dec 2024 01:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734947009; x=1735551809; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B/tJ15+vmer/NbqXoUznjybhQp/MgC6GOdT/GuQUXpM=; b=PO6+u1LECPhz/UXO0OjVXHaT8dbK/81S8ZJyR1ptrMY3u5hoIAgA9awTSvS5EsH3c1 BgAwIGWSXHSnCKbzm34hko3v3JNSMtVKeNdq6BjAwihc0OSrzKY3V/6biUVxKZL9/vSg BNkSqFRUkdOgvLOwL1GaKvO+k26svz1YDN9FSCCeZ3UyyfFWqpTBRFiXjX4m2+nehPEb a5o5F8vcUHekp8kazqzp80k+eFrxBIXhp4+6qXne6SHblZi77+78eXeEZJuC26Tqwuls tRTSX0JZuOChv7GIUsSVMrlzLGkkcMYav+o91yxr5v7TclDaxElS9hK0V5GV5PtpdFv+ e2Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734947009; x=1735551809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B/tJ15+vmer/NbqXoUznjybhQp/MgC6GOdT/GuQUXpM=; b=KUq8ESvKeiDZpOQQebubjENFHAF88U4p9rWnjUh8/gnAeYCSde/hd4maZ/Fe1yDZDE ILn0rNo1HadGIMgFDG+pb5fCjZCB2Zl1G6wxF1prvF9jJxIcELRinI76IFcQUKZ/52jF jwbc0rVo+0UGiT2pgolK+zkmBo/fiUjzN2Va18CMTAwv0uaTOndERKNN1iUwkdbUTinO Ajwf0QDs9G59E1r0oCgubxs81KWxNJ1EpQ79aeTZvxRa6yrwmS01a5/TQ1rTgokR854h saVD5YuRjblTNkEpHwhIlN5oKVpZGFqn/Kh64L0mo/jV6MruD3YGKPyKalZgb1akfJc3 fqDQ== X-Gm-Message-State: AOJu0YxNraIPV3PLO14Qx19fDY0ZJW+t9ytSuUB82S02jnpsNMg3mZC4 egIGWldPKorGY3J638u+SVDXD3hJNj9XNm8cZAnWuDBI+1sEt1LxvnLkX1tV2SA= X-Gm-Gg: ASbGncsW8zhaEjp86oABOD9TOy+dmfFhzDmfpSQQxa+w5GzCjTJOFsnE6QxByc+6h6e KKIq7XIC9Nu8liolIGliROnEVZ/IRQ938boLokR3nvC1jGL5loEDP4HtmRQSSvge7nKvY3zzZ88 zAQ2MbuHOxdFPp2Sd0bWMWPMvKoiyDoeSOaF418kyCtRofRRJV9rys+1goHq+6Grb9JsKedns1d 8CaKAlfsXKOUqmWhpzTtLhB1ji77L1LJE5rN77wJhqH48IKfRAp2Jw4zsve7ZRg+IS8aPRHGrfx 0pHJ0jOgKlO9awbgvnEiEQ== X-Google-Smtp-Source: AGHT+IGn0WgNlH4n6jFU+xV15Lu8l6dnMV2FFWuW4zvXTMVJTCCaTT+ZxewqFKpQcJgKvmYU0RJrVw== X-Received: by 2002:a05:6a00:35ca:b0:724:f86e:e3d9 with SMTP id d2e1a72fcca58-72abdecbdb4mr16058641b3a.14.1734947008718; Mon, 23 Dec 2024 01:43:28 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8486c6sm7468309b3a.85.2024.12.23.01.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 01:43:28 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, tglx@linutronix.de, david@redhat.com, jannh@google.com, hughd@google.com, yuzhao@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, lorenzo.stoakes@oracle.com, akpm@linux-foundation.org, rientjes@google.com, vishal.moola@gmail.com, arnd@arndb.de, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, dave.hansen@linux.intel.com, rppt@kernel.org, ryan.roberts@arm.com Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng Subject: [PATCH v3 02/17] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one Date: Mon, 23 Dec 2024 17:40:48 +0800 Message-Id: <84ddf857508b98a195a790bc6ff6ab8849b44633.1734945104.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 84E3040017 X-Stat-Signature: 5cmfu4znopzqc66kzjcqzhexut68henx X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734946975-926064 X-HE-Meta: U2FsdGVkX19vBN4jTl56mEQxmHUDG/wfrWw86h8of/CU1rhhJ15JTugM8Rk8dvkug1zeTRaPMcfwZh49o+gzXMM9xAh0Hb3Y1XpYIXQhDR3TgZRLO64oHjvGS/OpfCFgikHiFwSjfcHBpXEQ5zg2FD7VExXhvgRPT6Xy1qlwMybQAVfll//tnJOJ1JEVOZPZp56ajxjFD3zZJgQ/4T+puImlQaz6MZpUSj9N0zWNELxjoJqE6LUqLAvOp23m7Jj8YTkTTYmd3OtYvC2yPKTVLXRF+m8pA8VLgNIbD3HtnYPWGzqRTO/SY1xJ21EI4B+sC3gwlIT6SnJQ/d5QUCHAJqIZcMur8hKBuJYXLFC0cx1Woi5nyZvMBbqf3DBCzih1XlP+dm4d8Hs0GHYyHlfkMR0so6/eq1ZYlAsuUAHui55N+4hUVWoOW4VI9cVd3DaMp9w4WcdjyzwaiPS2CFS6IJTp6Dfc8E+YXSuyFUnqr7spsVuuzWb8yuIAsdSo52odriTwWnwN5J8tn4ae8zpbCrp3dHxb9sq7qtvSoLKKR5ESlbcOI77t7/ts8WZDyjvgbsAVRlAjP4N/a+jX5FxAv8Fg/m3iTpw7azmJMa9JNh8WAwt1Shdsmavpb8+coi4NAaAyBZRwL+d+xVeVqeCBblmwE2ZCA6tuk9gLCfQgxdF6VHFgzN598zN/aMJ9isM34YKdD0HhO1M92E2tqSlZbQNePBeN1MtsEgewDNzJ9iVKkW1LFPxaRTazrh8hVXi2csiYXji0MbflwYKv/WHaIsbZYPiZzs9p+rIvvvJguuEb3+00ld6NmCey0yhZpW0cqRFQuD1FRdazF/Wutcm7G44onByJOvbtPdZTOdFI7xoa/UXWXOVMJXHcCK8ENvpwjCljoxkDAexiW//GY8EsaByiRpaGoFQ+HQEdsA/aXSdIR6BJjB8TZVTUkz8kV0+xc4caq7s+XMtCuFn+HNk I7WROHec BJXGuzeNq/xHcxj/lplGpJ7mfn3/zAhB1LQHSdIyIZ8Zgx5X+wxMesXbzOyD/+N1dDjGiCSPKmseuLaOI3lxc8kkizoPktE0xfb/fO8+/bdxVK+ilN/RvURKcxBz+FKkNrK5LcbTxmy4X7vnUWG5VjMsIYEPaXssxjeu/IW12W+0QBPxUU2awOCnivT5adz7j97T2iTEiLCNkArnOlziIcginjC6MsDXKBXivupYaPw8yfZitqS7EaUOsYNpeQGTmBeWTEqzZUK1yVjCimpGXrXS2TU27j120kHFS8RdsoMlCZkq2DWClnUcDILR/P1FYft1Id/MHk6d/ecqH9C6ulCoA0UT+4YbeF0CsaNuGExaFMSaHgvZ3ipHdhnSNgIuGVybmP3lZbX11RqY2CjA+Hci49ZGR/ZAz6/YNxsbwhU2SFUO5soiUPL5PV3h9DPj1fXhmVPD7+rv9V4Z06RKQ2PfgAobLBev5rzLfyI9AEcy8y7Zk9HTx5EtZ0a6d9VS5rfit 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: Kevin Brodsky {pmd,pud,p4d}_alloc_one() is never called if the corresponding page table level is folded, as {pmd,pud,p4d}_alloc() already does the required check. We can therefore remove the runtime page table level checks in {pud,p4d}_alloc_one. The PUD helper becomes equivalent to the generic version, so we remove it altogether. This is consistent with the way arm64 and x86 handle this situation (runtime check in p4d_free() only). Signed-off-by: Kevin Brodsky Acked-by: Dave Hansen Signed-off-by: Qi Zheng --- arch/riscv/include/asm/pgalloc.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index f52264304f772..8ad0bbe838a24 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -12,7 +12,6 @@ #include #ifdef CONFIG_MMU -#define __HAVE_ARCH_PUD_ALLOC_ONE #define __HAVE_ARCH_PUD_FREE #include @@ -88,15 +87,6 @@ static inline void pgd_populate_safe(struct mm_struct *mm, pgd_t *pgd, } } -#define pud_alloc_one pud_alloc_one -static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) -{ - if (pgtable_l4_enabled) - return __pud_alloc_one(mm, addr); - - return NULL; -} - #define pud_free pud_free static inline void pud_free(struct mm_struct *mm, pud_t *pud) { @@ -118,15 +108,11 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, #define p4d_alloc_one p4d_alloc_one static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) { - if (pgtable_l5_enabled) { - gfp_t gfp = GFP_PGTABLE_USER; - - if (mm == &init_mm) - gfp = GFP_PGTABLE_KERNEL; - return (p4d_t *)get_zeroed_page(gfp); - } + gfp_t gfp = GFP_PGTABLE_USER; - return NULL; + if (mm == &init_mm) + gfp = GFP_PGTABLE_KERNEL; + return (p4d_t *)get_zeroed_page(gfp); } static inline void __p4d_free(struct mm_struct *mm, p4d_t *p4d)