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: 13930193 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 AFBC8E77188 for ; Wed, 8 Jan 2025 06:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49E386B0093; Wed, 8 Jan 2025 01:59:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 474856B0095; Wed, 8 Jan 2025 01:59:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33D006B0096; Wed, 8 Jan 2025 01:59:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 16BFE6B0093 for ; Wed, 8 Jan 2025 01:59:50 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87B931603F4 for ; Wed, 8 Jan 2025 06:59:49 +0000 (UTC) X-FDA: 82983384498.02.D54932B Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf10.hostedemail.com (Postfix) with ESMTP id B11B4C0006 for ; Wed, 8 Jan 2025 06:59:47 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Td1UYSaq; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.174 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=1736319587; 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=WgpljFzcR37DW+k0izImY02NXJU+2N4CamZhPf6BMmU=; b=Em8BnpumJ3D5lxU7VbUKWr/plDiSvoqS02ig4J7u2IVjlENaxDxJvL9vInChkq5lKF+djW QaPO/knbPbM+1sbrXHMqrFmvXS1FKyCXwwm8MCkMWxD/u1g/J8HLl4tCruG81m+SqxbbKA UCqBCzoOYiW4wqh3hv7goNA87drxIiU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Td1UYSaq; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.174 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=1736319587; a=rsa-sha256; cv=none; b=hMD+8+Eb7owHyvpuluceuB8YMEOuQ3xAXdjlg3PgQKOf4jSEORUfeSlBeIzhN62KHg6fDw 4/2M1XX1qgPbItCDBy59U3kZn1yjW6D/8bY1GT1E6DRoo/70hRb5HHvG/mxOVqiRR5sil8 TCZdpfrBD0Nu5LlboqJg19bEGz08fy8= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-216395e151bso7101965ad.0 for ; Tue, 07 Jan 2025 22:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736319586; x=1736924386; 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=WgpljFzcR37DW+k0izImY02NXJU+2N4CamZhPf6BMmU=; b=Td1UYSaqbS6rbCNKSTnjEtXnRKlDzYjcD6VoxvGnwN9wcYmbcJNPWrkDe9/3/TsU9J VJmDPjeXJkzu4iglVky8qz5VJnktdh/e3Ti9J8rW1rNN1hR7gvMVDhM/UkPdhSxkEDAV ByXW0RfkSB15XEuTJ9rGNTEVKRBoRN5DsmK1aP3/Lrt6XdHSxDZC478pmF/PA6YNxotH xdX2UJkoJWmBV5iyajMxrT0OEeU2C3CHkfZKAiqse9r4mTyIcQw+TjGfN5IVhm1VrHrA eqPPs4kgkYJBeHq1XQv+5zGdHNk5vib3KnxGJx/0T4FxfferTPaBT65UROlLGVuH+2sV xRpQ== 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=jT87tfsHiuwa7mO7o5M8+4SIUR8wYB6HoqUtQFmzVNSp2DBD56NPKCo1lIqmmQ7YIJ yPTVxb3DdTo5g+qWAg4MTV0X3xqkQbK5vyk7P/4lSF8CVWL2o5h9DtlaADWsxSJwKj4S aVR33dPNL00SGmiuN7xf/0+8XmMp9jNjBiqlm/ipkb3UcbEGmu6VQYgkUb1LcSnfv+Vf KmhN8q+QerY+et4HumCul99zI3tfm8UX4rpADdOv6WapA21+Sz8UzE3Nl00tKsvTqb2N euKm7NVbFOMJjjuG2/T38EDs2pGdm40/MFTn+Jxh75RUZoJS70bDxF0WfaaZ/YkiI3RP 2Dsg== X-Gm-Message-State: AOJu0Yz/QuMaSl4Ag2tF/VjIY7aG0l7c729BK3fEAcr1+jwnhszpQFWd TwmvboLyxH8CBls+RW437ILZzEZ/IXSYNA+VQKhn+xwk/x7fquCkyh06y0bi4Go= X-Gm-Gg: ASbGncu7O3W7G4uoUEPt4wpOrOxHWIPbkYHl0f3v7tPlBY55fKYyETa9aklGZ5PqJUm QWd8tJgjd6ssMQjNBCz+oP6qSleLo/mIBaIchGyLTkjvSYqbq8LNNFElZh/d1CZhgEqBsyBXog7 LgGtc5xIcFThuuVmDBZy3jLpy8Kt/YEvXPn1+67FgqADwPc4QXyorOb7w25PrY/X45U5dtMeXuG h2HPaAEJNWqy73//RXSbqqYzaaz6zIAWsqFmM4QaGb6VEP/Zf5NSbOjyglxhB38Ft/mumcJBZE4 vqhOKtCUzJE7uxyyxYd9m3vsS70= 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-Rspamd-Queue-Id: B11B4C0006 X-Stat-Signature: t98jirqnt8k1t8odtah6sg8s7nrgipjr X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736319587-692136 X-HE-Meta: U2FsdGVkX19huti7etzDaRyWXH+A50a310+MqnGRiKRM6u5IE88bcU1JAS/XHz1fPrTqxFqypQ5Sx2UYYp0O5ojFIYEwkeTuv7HN2OdCrnGcgaJnG33WBjZxWIZP6OiTGPPQ0k6fXjFQ8mK7EOkuWc/sZlbMzNSCPjaJWukRgo9s0AauQI5f5Ca2+6M9Duo/eptKqow/sPfoE5JRFZZ3/rrjsMlfVv8CDiSX4KTDMdIzUV4TY14c2EZn3Bg0hzOqgaA8UZudHKNtsR1MoOp6DqTzhPMZk3Vh7FRDCdVPxHThO/sUDOg8eiWRP/SnaQrnM4il0LCW6PtCNtybUL8v13dNAHIMZ8+NvenzZ0zMcbNWhypsp95YacWZDalamMk2+E7VCIUpoY6m9ksnhwIWEmuZyI0Br/Vx1pDFW9ZA/+tn0m4ERaCBsY77tqJlwaME+9pUvU8NyVEQZBh9LIlE1xh3B6jEpDG+snzmeMvQp3OjpPr8m7WCgfIhNMpxVE6D2lPZLjkJm769a7Wy03eYfC5JcOdkX9h+goTu0hLPcp7ECo2ik06drxyGIl/UGsYepgUbQPSJCvGmOigJPNuQ2VMoPakJswpZOZ+9xnXAku1rWT8oQfkFPsUSh+n59vD9i6Tj09lpFlIoAbbDZxwE0h3+3Fi0tQW4wlSF4FAFFwWC8PT65rQ5G/LpZTLbD5aySrXNJGe+FKS+XC/U6H8Pks7Zd3wNQOcUrBVGYiW2JpZvRJCxfzwsaPz75VP4sC77f2MuK4AMCIiOkWHhtyR4KHypCbtLkzjZy5y1Wa9LVmLSzP6TQ5rcKQlV3IVHeigwSP36cYz/YUpzOeIBn9xEz+VdSYQMzjFnufHXqB3tBEVNgnnYyIisRrjtvonoElPNJ/x2KBIpRdIIAEt/IQGQAjmuGscdBbrtkqKrjaZdTjH1tCFwkt5ayDsIDsXaqWxz10mRTPAz71HB1f36jkM +wj8lTkG C9uF3Eat5V5zmoEHd62Pm+dQ9bWmjF8eO6u2exLfW/RJpXd1wTs7CvNH/t0LLwhEsBbWwRVYQMuuxueRFme3p6S7T1H9GRn0EwFaSVe0H72ivpRlSwmk6W3dX7Vq0AHZ93HP/5BboNTUIxdrngV7IzhS5RJaIQWukkYo2IGK9iqYqBKj7YhmdMIsBpKDrKakMtZImoby4qnouM1PVtWJ2hqRcLa6BacvOKWAXlzuqTisAmKybkmmZsnW2B82RuQT0J5SvTS+YHYiK1YPXWcS0rlXuyFu2evcUfnDbwwL0Yxy9fiO8U4/mlLh6B72hZbySiDQSubBT+oOHeBNPCnXu6bJXP3r9/WB1/+I8DJMy1qsYFxSRClOy1CxUpAO6N/FdHcU7iVJUe1sJ9mmCufpX3ccMmeCqlZYLZu6Q9/3NuFQofzqh1D443ICo6JYYrHIzi0Jox99YGiOS4nvh1lpAGEFnJ8I8ouziWFmWUrVAycZW8/zR/Fo0P3abPj0AiiDnUu/4/903FDi09BcWaMLKayNQIhQUh0Z5ASCOle4HhoDr3PClvOLR2fwCMNVWJQl90yU7 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 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)