From patchwork Fri Oct 11 09:33:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bibo Mao X-Patchwork-Id: 13832284 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 0F82ECFD30C for ; Fri, 11 Oct 2024 09:33:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E7676B00AB; Fri, 11 Oct 2024 05:33:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 597866B00AD; Fri, 11 Oct 2024 05:33:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AD126B00AE; Fri, 11 Oct 2024 05:33:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2E12D6B00AB for ; Fri, 11 Oct 2024 05:33:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5E1D41A0FBE for ; Fri, 11 Oct 2024 09:33:19 +0000 (UTC) X-FDA: 82660808370.22.BE24F7C Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by imf05.hostedemail.com (Postfix) with ESMTP id 1B1CC10001A for ; Fri, 11 Oct 2024 09:33:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.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=1728639092; a=rsa-sha256; cv=none; b=UQGbjkIi6IbeIPV8RB4uQ4iryCDLKRFhPqZ5GHFH7oVfDJSwyczyxeT/UwKzhETzxXGoUC bjJbn/hbqQaB9SC3WG3Wph/SiFyV3tWznZdXC5WFMtggSjUR4mqQvIOAzArSOB2OQsDplK x3MJEvEHy49/7U2QqE10ZSzZ5S3/4UQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.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=1728639092; 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=MV0mExEMqeShhBINf+q9yEBzo1MDm85GoJhRrKQ0pFY=; b=Udeuxg0SAk2anT/ALxf3C0GU0C4C0u+eBqmcSyL5GyNec6BpcF13reALfyEfQhmT+6QqK3 3rkK5J0z/2gPeclMRabkRPmMPbTXDIzLzzDAu73+g/BL00I2pIyck3T7x47867K/hckem1 VozONy3JldeW2Grg75NZqVRXPilu7G0= Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8CxZYng8AhnrWQTAA--.28323S3; Fri, 11 Oct 2024 17:33:20 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowMBxXuTf8AhnWK8jAA--.48225S2; Fri, 11 Oct 2024 17:33:19 +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] mm: Define general function pXd_init() Date: Fri, 11 Oct 2024 17:33:18 +0800 Message-Id: <20241011093318.519432-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: qMiowMBxXuTf8AhnWK8jAA--.48225S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1B1CC10001A X-Stat-Signature: hi8xfkyx5ufh5dh18bskhg11za78rxq5 X-Rspam-User: X-HE-Tag: 1728639199-779973 X-HE-Meta: U2FsdGVkX18yBI/E+2pDbqSGLHBr1OHWpUhmzrWLMx/+8uIdEDyGFusmWP2Nlgw4T4vkHx0vguWmY+bRNfxTBRMM2vKn+tPb/vYSbaj4oXxhI5v94+PXSKHXpYuYbkDTZSuUQNtyTv+3uT13EYiafK6u/PsRDZ5/F1b2+3KE1oIPtvygeQsoLf4HTrvUONH6zbMUi/PdwASSgFAbH0gkpktEMBJITN3cPyBX0tG0oPFV1FNLGSXUy6leyfaMbqDsXv4cCxkxkz6XMXiP0NXklD1r4F2K9/OfLkG0aSFJlJVZA3gKvEQzeRaSBY3w+LczSWpeUE2e1n63u9lsa/Q3/kyIWO9xOZVhlCtjxHGq6jLoT7DwQiDyX6e6ziGDjibcCkBuz7uBkCXBAs5K6z6VBo8H5VqciQCEhtEFV/Q4Y1L+HKRwp8btJ+ptQvX7ijUvuY/C0Ykm/IlYAa6oSV0KbnBvuWISc/PeiiFEpvl6mIm9DgZdtGWylmCrTh6k+oNAqNvuRoG1eORQKW4K7oly5BVa7X5d/JWSc4ROA+HPMYBrinEAGhH+iHF8c/jcX7hNbnYct/E9Owi7cIr3keAy2NTkZrZUy7YxmBEsJkPinPnzi7E0mP23yjCQSnglTzO76Mki+HE2Edr7QSJLt4ZCcaVPmsumWHIVOqzcUvSMKwmpVNDrPfABM10Sp0rxwcr9FgHSEseDhiSnJ2FFPDJWo/dD3J5uy5AHNU6VZus3khBUoPUyCabkyvpY8M1qErTHmcTA5hVjHnprTr/SbUQD6z6M1XZeUbOQ5q+R9RzYFPAdKmOvBMgO65s9aLqDX4w8FSmY67QlTrpH1UDZLhjiSTBIcJ0uJ+8wvHa1ZNYiqi8BHryJuC+3T0pu9u0l/yH/uyZ/s2qYvu3JeGG3RRtk4Oi81y7Q9awtYYaiK0dbSMwJINM5Pu7D/fVZbcj6DS51E21DfMlDVaPGQtNCGXZ 9wRqKhUw VB88I+ys9C/AV3EwGyolTUk89OosuwNshophmsgPpbn9K1uN2aAYZbMxHMAu7I2kXwCgis5yTY+m8PakOw849kSKgjZJIupZV31f3bM9F+VWK5vLXUq4MfKbQR3Oy9zw9vPYbdAg7XmaYiR4ktjpqRvYxsAAKtdj2wFeK 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 pmd_init() and pud_init() are duplicated defined in file kasan.c and sparse-vmemmap.c as weak function. Now move them to generic header file pgtable.h, architecture can redefine them. Signed-off-by: Bibo Mao --- arch/loongarch/include/asm/pgtable.h | 2 ++ arch/mips/include/asm/pgtable-64.h | 2 ++ include/linux/mm.h | 2 -- include/linux/pgtable.h | 14 ++++++++++++++ mm/kasan/init.c | 8 -------- mm/sparse-vmemmap.c | 8 -------- 6 files changed, 18 insertions(+), 18 deletions(-) base-commit: 87d6aab2389e5ce0197d8257d5f8ee965a67c4cd diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index 9965f52ef65b..8bd653a6fa70 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -267,7 +267,9 @@ 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); /* 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 ecf63d2b0582..651bdc1bef48 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3818,8 +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 pmd_init(void *addr); -void pud_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..bec5356ee644 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -90,6 +90,20 @@ static inline unsigned long pud_index(unsigned long address) #define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) #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 89895f38f722..6b2dac62e63a 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -139,10 +139,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) { @@ -181,10 +177,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 edcc7a6b0f6f..a0c884947861 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -196,10 +196,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); @@ -213,10 +209,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);