From patchwork Wed Jan 8 06:57:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13930236 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F8E4E7719A for ; Wed, 8 Jan 2025 07:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bvdZObhDRrietSF17dn5kovUvty9Hm58eyyNspJ/rOA=; b=afuVdENHV4j47T 3GMq7QaRxBwrki04B6ypg1uS6FfAH8reGS6ERVR8f995bcJNPzqMAuVJEj4YbYqC1L3RnkxhugZ2W g57+QCvFvHsLck3zAVsliRJJpXc1N0LKZdeSQwrR+p7T708aGxPFhPGuBEMcYNC9TMN4fUv+tBWyR uaHHgye8x++4QXf7igoogZDnIs+XJNbS8rE8cm//llAo0T9CyglJhh+Sa25k5RP+uCcVBevDuu7Rb h1i+jHpdIY6KSVypYvjSORlhgQjW0agVQ/JnA5g3P+LkO+Om0UWwpE9foR+dsZ3Fv22eNHZmACBWC zz8HuoEGJznPu93+y2EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVQ5m-00000007Lur-2bOP; Wed, 08 Jan 2025 07:03:02 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVQ2d-00000007KCe-0Gfa for linux-riscv@lists.infradead.org; Wed, 08 Jan 2025 06:59:48 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2167141dfa1so9476705ad.1 for ; Tue, 07 Jan 2025 22:59:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736319586; x=1736924386; darn=lists.infradead.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=WgpljFzcR37DW+k0izImY02NXJU+2N4CamZhPf6BMmU=; b=B58FyfQZGYZOmITEUN+oNjzWx14zqXglokbQNkjFG3gAmn3i95AxYh2JfGMMh+5uqC NBeiw1Dmj54U2hpYZbvlB6Ymj2A2uRM4Hnk0kQzm6x/nh1WEvqBAIZGLPY3hUsY0PMpN 1/U+m/VbQ+uspzYGCpdX30NtL17ExXEYpLfJuU8tCv71EnKmQiuUVedMWfKDf1mBjHP+ kYQdon2UgMiMo6Kudlc39s3ywUsTCVYAwnAmhZT1hWNL40gnUaofuy0gNZCbox7/m5TZ kZuUrZtfoRvN0XnHVGxB6bDFGlurAOQpUBdON7snYWXG37d5SKFoOKLqh5EWdTWgRRjg H2kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736319586; x=1736924386; 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=WgpljFzcR37DW+k0izImY02NXJU+2N4CamZhPf6BMmU=; b=dG1L5szd5cGZr9GhrU1AvMwZkZlEquYh7PMx/+I5/Jq0f4WD1pu3BSet8S45+2HfXP tZjsXq5c6/aCwY1ld0Mn8TjbBQRzcEukdYTQLo6shkV9gb8C1z88BJV6z+yNj0IsBkGl gGBry6s3FeBabqL14sV3SVo3Jw9TnA/n8v0qiPGshHdAdViZCIQ3wsEEcZV/TG2WGvNq Ao0QrRraHN3l0FuuttuXUEa2uKK3I0O89CfD16mwv0UswZOX+0d8IuFQEox23Q3iuAv4 z/YyUQn2P0ev+wPuyd1h1cOP22vFzjtIcfOrE2l7hPnf7EpfRcxSJqi1iEFRWqAeRxD0 /lMw== X-Forwarded-Encrypted: i=1; AJvYcCW4I8Fi+dgEiIqs4gm4F4o2ce78kjrCrXIo6D7mDzGuA9UXYzFCsCiwVfquK9GNmH746HACkUmnKbTswA==@lists.infradead.org X-Gm-Message-State: AOJu0YwCcd5qoDzHMwfhRcNovlBWF+/3yWzHoHm/fM0unLH7+NUNiaJm IOjR+Vkr+WOkhGhlYNtq5JioJLCSyyF65Kq3mKn6GZ4YC5gUH/bT6dZRxpHr/ug= X-Gm-Gg: ASbGncvyijIY8tG+8gJxzjpKyt7HDz0ibtyohWP+BBgpk9NKTxgo8pbBnUqjkGVRVMY eT23NL4L6BcF8P+O+xPWxB4s95sVLbNN8WnTJ+V8bwyRe3W5OKPVck8uS6F2ps8XLwZO7yAzF2Q tyH0Q9YC9xUWwCdx0QeEC2Xii+Tq9K2GTq53XEi39T4DmY2U5/87PwwCc7Hax72nvOCLFPw9YQn wVdP11z7CUDhQEFs0VmLlZlAW6LKjt68/vf/iYKaPbiVnqLyXXme+nEsWZE4kfGc0XJmhKaxHIp QKzaq9P9zYQLMC39cT1QIJVFI5s= X-Google-Smtp-Source: AGHT+IEXmx6aGyXUatDDUSC3BIwwvJRBe2xxgGmNdG6bwRG2a4u7PgHO01+qr8GDOf9tBGHx3RRkKg== X-Received: by 2002:a17:902:fc4d:b0:216:5db1:5dc1 with SMTP id d9443c01a7336-21a83bb9991mr32206305ad.1.1736319586298; Tue, 07 Jan 2025 22:59:46 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dca023a3sm320067275ad.250.2025.01.07.22.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 22:59:45 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, alex@ghiti.fr, andreas@gaisler.com, palmer@dabbelt.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 , Alexandre Ghiti Subject: [PATCH v5 02/17] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one Date: Wed, 8 Jan 2025 14:57:18 +0800 Message-Id: <93a1c6bddc0ded9f1a9f15658c1e4af5c93d1194.1736317725.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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_225947_103067_527236E1 X-CRM114-Status: GOOD ( 11.02 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 Signed-off-by: Qi Zheng Acked-by: Dave Hansen Reviewed-by: Alexandre Ghiti --- 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)