From patchwork Wed Oct 30 06:39:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bibo Mao X-Patchwork-Id: 13855974 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 8D08DD74978 for ; Wed, 30 Oct 2024 06:39:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B89AF8D0001; Wed, 30 Oct 2024 02:39:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3A226B00C6; Wed, 30 Oct 2024 02:39:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D9BD8D0001; Wed, 30 Oct 2024 02:39:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7D6EE6B00C5 for ; Wed, 30 Oct 2024 02:39:26 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0A3601C65AA for ; Wed, 30 Oct 2024 06:39:26 +0000 (UTC) X-FDA: 82729316082.27.5B723A2 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by imf17.hostedemail.com (Postfix) with ESMTP id D9C474001A for ; Wed, 30 Oct 2024 06:39:02 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of maobibo@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=maobibo@loongson.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730270308; a=rsa-sha256; cv=none; b=VR8D0zeTmKEJoPRS6okQe63jzI5rluPgHInnHh41yBQBqGn1TbGoHsM9abVNrkGyZGqjfF NMCjQ8gEbRii2YMgkWYSzZPL28+lsS2XnkQzlyPikEzQUmd4IsF4XIkJERzOUksHqwgFuI 2nH+O8nhg72F/VwW9pBroKnP9L51UKA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of maobibo@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=maobibo@loongson.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730270308; 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:references; bh=vE++g1NdPLvsinZB5h+MGN6JeZyEcO5ckqJFwr/C+eo=; b=aTDPeCsn2KkxcPgXpJFuJuhh0YhzLkqai8gwZE/evOmGYP8M2jdew5rKj2Ivsuqlcx8bR6 142AHoZUF4VNHpHhnj9DJJ5nXjPfqv5GgWMmm7b+5czj5s5oCD596UAELkVJf9clKzzPWE jHKpA9/Fh2DPpEYh4QFeZb2N+bclX4k= Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8Dx2uGQ1CFnAKkdAA--.62351S3; Wed, 30 Oct 2024 14:39:12 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowMDxPEeP1CFntLooAA--.23618S2; Wed, 30 Oct 2024 14:39:12 +0800 (CST) From: Bibo Mao To: Huacai Chen , Thomas Bogendoerfer , Andrew Morton , Andrey Ryabinin Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , WANG Xuerui Subject: [PATCH v2] mm: define general function pXd_init() Date: Wed, 30 Oct 2024 14:39:05 +0800 Message-Id: <20241030063905.2434824-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: qMiowMDxPEeP1CFntLooAA--.23618S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Rspam-User: X-Rspamd-Queue-Id: D9C474001A X-Rspamd-Server: rspam01 X-Stat-Signature: pyczukfo61ji6td6r4poq37najb556y8 X-HE-Tag: 1730270342-348266 X-HE-Meta: U2FsdGVkX1/cWt9el7bnSey+Wl3kRgmYe8q4oe7w3I1MKtYLqrt5dPQQPfigWOXSLMUaVLg8gCTX6cVS5Glylt/JWKdlqAQxnCKXqh50O9Y4SQWQn9TZiee8OYpm/tgXvSbiOrMYj7Eq8+Y2k+XAop/EMIdlVJnrFF8tgwXcQIrXbIbk9SnBBIDY2EoVgFDme4kM/HEkTLsvxeS47ShgZvU7wMAyCDZT+wG/kTpfsw8j4DM/Byk4P1rDZ3NfaxMaP1VL+HLJEB18zzZKk68XaC7zYis2OOhNCj39b8/RmHH+ntypI/uNKZz1XT5RTVE1kqmene6F71vkWTbtUOewHOKI2vxNXXVp4c8T+nB21Qg1lTm2/JBg1ndOnKlZQhLq16n4HWinvw82+34s6cf4PP+IKNJ/vxqpai5Zjo7b2S4vSqzUvsXrUCz64mzgCTdUGWdgCi4dN+yUadOzzcP47zV2Zji0oOUKAee2GZijGVmjqkS+8HyyFCr2RxWWZ4BFcDId1dudFwk3JwsTeO98v/hChDPYhCA2MbrpJYtOMb2y66B5b7Hdp4U30adej59WEK+EEF103oc1JBWFRSFp0/flfG/uhsyKa524rHJYuIkm5M7um9puUSmcvxkVOAaOj5cGvMSJWtCbAroVkK9plQ4oVOeKfc5RVYUpF8yj7r/B0rsGkU8X1Qd11rw4tPfgApDfYxLxaaIneapMvy4T3va/cfxhvGXYoQC/qmtACmesza1hr1RjwSFOJrQquZcjLBzntD+vJsXxVoAwy6GtSBsbT87fIAAVLE151YRtvJQVFrRUpzh1USxUPtUKy/I5BFX1a1JJ352zWpLYjWx5FdI3zoTTYb2Zi7n9OTfY/MXoO8FNWNgHcLL9ae/O53Xz+5ZI9dNHnvcIYzhrj7z4I0+eYiR5eynXUip0OuoI/lTZVPvifPXQmutmACRIjrOoUaD23Z2MSoOxgrSLX8R BwKUkzdA yZKIy9rEJmiF78wmAesolFXnoezSaAvYPM9XTz7WDyRH7Trth/jCIUnxOQB81bSmxdxQhUV//wV872nAK8alCwkc+kIRjpNG1V5amhFtdYdhjJsvEhXn6e7aYpkYrzOfzTPjDZXPMRqI0YKuU5z1qoUVKTA3poEobSU53 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: Function pud_init(), pmd_init() and kernel_pte_init() are duplicated defined in file kasan.c and sparse-vmemmap.c as weak functions. Move them to generic header file pgtable.h, architecture can redefine them. Signed-off-by: Bibo Mao Reviewed-by: Huacai Chen --- v1 ... v2: 1. Add general function definition about kernel_pte_init(). --- arch/loongarch/include/asm/pgtable.h | 3 +++ arch/mips/include/asm/pgtable-64.h | 2 ++ include/linux/mm.h | 3 --- include/linux/pgtable.h | 21 +++++++++++++++++++++ mm/kasan/init.c | 12 ------------ mm/sparse-vmemmap.c | 12 ------------ 6 files changed, 26 insertions(+), 27 deletions(-) base-commit: 81983758430957d9a5cb3333fe324fd70cf63e7e diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index 20714b73f14c..df5889d995f9 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -267,8 +267,11 @@ extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pm * Initialize a new pgd / pud / pmd table with invalid pointers. */ extern void pgd_init(void *addr); +#define pud_init pud_init extern void pud_init(void *addr); +#define pmd_init pmd_init extern void pmd_init(void *addr); +#define kernel_pte_init kernel_pte_init extern void kernel_pte_init(void *addr); /* diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h index 401c1d9e4409..45c8572a0462 100644 --- a/arch/mips/include/asm/pgtable-64.h +++ b/arch/mips/include/asm/pgtable-64.h @@ -316,7 +316,9 @@ static inline pmd_t *pud_pgtable(pud_t pud) * Initialize a new pgd / pud / pmd table with invalid pointers. */ extern void pgd_init(void *addr); +#define pud_init pud_init extern void pud_init(void *addr); +#define pmd_init pmd_init extern void pmd_init(void *addr); /* diff --git a/include/linux/mm.h b/include/linux/mm.h index 61fff5d34ed5..651bdc1bef48 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3818,9 +3818,6 @@ void *sparse_buffer_alloc(unsigned long size); struct page * __populate_section_memmap(unsigned long pfn, unsigned long nr_pages, int nid, struct vmem_altmap *altmap, struct dev_pagemap *pgmap); -void pud_init(void *addr); -void pmd_init(void *addr); -void kernel_pte_init(void *addr); pgd_t *vmemmap_pgd_populate(unsigned long addr, int node); p4d_t *vmemmap_p4d_populate(pgd_t *pgd, unsigned long addr, int node); pud_t *vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node); diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index e8b2ac6bd2ae..adee214c21f8 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -90,6 +90,27 @@ static inline unsigned long pud_index(unsigned long address) #define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) #endif +#ifndef kernel_pte_init +static inline void kernel_pte_init(void *addr) +{ +} +#define kernel_pte_init kernel_pte_init +#endif + +#ifndef pmd_init +static inline void pmd_init(void *addr) +{ +} +#define pmd_init pmd_init +#endif + +#ifndef pud_init +static inline void pud_init(void *addr) +{ +} +#define pud_init pud_init +#endif + #ifndef pte_offset_kernel static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address) { diff --git a/mm/kasan/init.c b/mm/kasan/init.c index ac607c306292..ced6b29fcf76 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -106,10 +106,6 @@ static void __ref zero_pte_populate(pmd_t *pmd, unsigned long addr, } } -void __weak __meminit kernel_pte_init(void *addr) -{ -} - static int __ref zero_pmd_populate(pud_t *pud, unsigned long addr, unsigned long end) { @@ -145,10 +141,6 @@ static int __ref zero_pmd_populate(pud_t *pud, unsigned long addr, return 0; } -void __weak __meminit pmd_init(void *addr) -{ -} - static int __ref zero_pud_populate(p4d_t *p4d, unsigned long addr, unsigned long end) { @@ -187,10 +179,6 @@ static int __ref zero_pud_populate(p4d_t *p4d, unsigned long addr, return 0; } -void __weak __meminit pud_init(void *addr) -{ -} - static int __ref zero_p4d_populate(pgd_t *pgd, unsigned long addr, unsigned long end) { diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index c0388b2e959d..cec67c5f37d8 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -184,10 +184,6 @@ static void * __meminit vmemmap_alloc_block_zero(unsigned long size, int node) return p; } -void __weak __meminit kernel_pte_init(void *addr) -{ -} - pmd_t * __meminit vmemmap_pmd_populate(pud_t *pud, unsigned long addr, int node) { pmd_t *pmd = pmd_offset(pud, addr); @@ -201,10 +197,6 @@ pmd_t * __meminit vmemmap_pmd_populate(pud_t *pud, unsigned long addr, int node) return pmd; } -void __weak __meminit pmd_init(void *addr) -{ -} - pud_t * __meminit vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node) { pud_t *pud = pud_offset(p4d, addr); @@ -218,10 +210,6 @@ pud_t * __meminit vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node) return pud; } -void __weak __meminit pud_init(void *addr) -{ -} - p4d_t * __meminit vmemmap_p4d_populate(pgd_t *pgd, unsigned long addr, int node) { p4d_t *p4d = p4d_offset(pgd, addr);