From mboxrd@z Thu Jan 1 00:00:00 1970 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 CA7BBC25B74 for ; Fri, 24 May 2024 08:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 473BB6B0089; Fri, 24 May 2024 04:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D5A96B008A; Fri, 24 May 2024 04:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24E766B008C; Fri, 24 May 2024 04:10:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0512F6B0089 for ; Fri, 24 May 2024 04:10:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A63DD1A09CB for ; Fri, 24 May 2024 08:10:30 +0000 (UTC) X-FDA: 82152567420.11.E4520F5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 1E0A780005 for ; Fri, 24 May 2024 08:10:27 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gTSmyPEV; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716538228; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=khWBjwUxGHm/VCtihK4nXeMBNWsEQ007OLVvQgw75m8=; b=cKvZOo2E+vDvamj+VKZUc478DpJeXRU6iNlDUbDOY+EwCQwUw9Mv5U/QgZy8ZxozibMC6b abU4TShlaY4SolcxCsCoxTW9pqtQ70wbYMqJG9xuRJC0KHkB1iGbghQmH57++ncwdrj3mx gbZFJBq5LdJv2sZrtFNX95v/EpFIQTM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716538228; a=rsa-sha256; cv=none; b=uqx+obbH5uOKXsCBo8e+41yLlTMp8bt4QwS1KpbqiGYfNqxcdPM3AB5wEKKS1paZktpVFB oZOfIMA0eg2eqPUA2juUYyd3TVvIwsB8VeShnbAxo8Yw7PGvKnrL0RnKo7nyo1/Fkmiyej 9B33HeeBmMDEv3NQjqbUN4MyUd8eNuc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gTSmyPEV; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 865DDCE18A1; Fri, 24 May 2024 08:10:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EC38C2BBFC; Fri, 24 May 2024 08:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716538222; bh=KzZifyFunKdMl7mZy15PbBQXyBPtR28fDlzXAEBwRZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gTSmyPEVPbnVYsbqpii0XYle0nGrfAI9KJYQ9QQtMO99GDFwrEnqvqqW0CTH4UlBj tQBgvLjOBwnUJuGZxOGDTsX4L6RMbys6psDv8PUNuOdm/25RCKhlFkIYOfTrfRizEL zrfZAyySbpZgi58QD2ndnKtlklKpcj+BMsW0AxWTTYZlCxENaRkfJYFJS6v1kNMR14 ga0qGrTXnaPwfBus+NEwyvGZfqJydhu3K7zoinPVPT9eMD//g3rIYeb7wY9RoPP5Ms FDn/3P7s7/hz1wCZKv6/dHdxX1x3mYjBNAZq5sA38FYcjenIX4A18VMWI60BLNmiRp OSh2FV9ePUR3g== Date: Fri, 24 May 2024 11:08:28 +0300 From: Mike Rapoport To: Wei Yang Cc: mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com, arnd@arndb.de, anshuman.khandual@arm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [Patch v2] mm/memblock: discard .text/.data if CONFIG_ARCH_KEEP_MEMBLOCK not set Message-ID: References: <20240510020422.8038-1-richard.weiyang@gmail.com> <20240524014656.odw4yuvhgbu4dgf7@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240524014656.odw4yuvhgbu4dgf7@master> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1E0A780005 X-Rspam-User: X-Stat-Signature: tnfyo1kqdouiumed9nodzu8epu3xw4i9 X-HE-Tag: 1716538227-205595 X-HE-Meta: U2FsdGVkX1/rDegun0VgEAAAtC0SmUlgfkWmgq0wcbjIVmZT93zcs77LbxsvUTiD3x8tLxK7JEAFmAsmRDpyL2dzGPyHnFkVV5lPkZefJQU7e69l6XEMLC78j7C3UX/M4Y4Qv7FSVsY7t+vFQ79X4HZ1u/nrVGNhxMJ36oQCSbOurE6lE8ZLm5546KPQ1fNSf59ABFJ0yH0hLjqHjQCIlxt1t19g65JjXmbtJMcSel0k1xlTu7KBwCs9MTnwTDZNCbz1NYzAIWIWKQ6HLoTIbq5Oj+hCZUiGjW3LkoYp66ylycYCZqTpFU3iQtFZRFqP7Cgt9TkHD+EXcLibgEyZngFQhB8geZO9sJdBSsMNA3oqkFnkT0POKIG8XKEDGAI9j53ixTgNxgwXrc5h1jHdqkflti0LsVBdJLwSy02+EP5Pd9reLitOJ8qzrEdBvOKA1cokQL85SmP8izE9zu9bvZGMou60dfVSSrhYjjmst0rwvr2fc10T2l5Ulh3buzT22ePX7Ca/AqqirLJi1jqnu2cBnGN854xzqOzNztE6r40HS8o8OR5IiUzOu0Pfmdc7YdUW1cx1dOaxhhqilOrjz+9b71fruL6HnDicCjKNN0RTKX8U1rrJ3513V9G2Ms0ibmR7GQaQVt0xwRJIh/3BNv87HkYfkVd4fu+MUXkfCHiMMkUmyQsXcc6tcO2ExMYE0RTY7HO3SHq3Ypzri4jtYcbdUI9THMdAvrD1f4X5i2lTQCDZdgcHeN0smVVPCi1CwH9Cc3qo9OdeUzYFEPMbyEw4t+KBDh5xYxXz3P+Tiso4Yku7u+YUtl0lPaA8KkNjAZRsIns9dTVvS9pY1LHbTQXlPV919jT08lJkTxBD4TlSmyfGF+3ZTvLUYmbTlIhzQrhWJXMAY+cqkqk9dNAF+xd6WipNjKp+s88HNwFl8e2SU//zAxag9ogrFJJ6OR9zW0OtdvZyoCpsxolVZvg alTeju81 DAWqCAroJK/wK2h5g8bWjc6JkVepxg2VzIbQgtqO/qfS8HdRSHkvDBnu2JDffqrhLh1av7wvSzOJYnZA6t0Cli5fGibfQp9SzTvW1mWI5jnCrq5J0J+36NBGs9RtxMxs+bwlz8CjdgqqqISOX8RWkKEen/UtSea1O/i9JNY4r9G1GWx0KaRsQyIED7xQZ8UtLveNSPrA+9ZSh9hGeAdUgHgaCzBGmuLfcL1iyHWk2rR585U2rtOM1/GuPz9Ap6Pf0c1Irmz/eH7pi9bnYalJJBq1N6EbdtemseraeCx2GrCc5MCr6IlzZTMPC80BIbOB/kPEG56152ClNqxg= 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: On Fri, May 24, 2024 at 01:46:56AM +0000, Wei Yang wrote: > On Tue, May 21, 2024 at 10:21:52AM +0300, Mike Rapoport wrote: > >Hi, > > > >On Fri, May 10, 2024 at 02:04:22AM +0000, Wei Yang wrote: > >> When CONFIG_ARCH_KEEP_MEMBLOCK not set, we expect to discard related > >> code and data. But it doesn't until CONFIG_MEMORY_HOTPLUG not set > >> neither. > >> > >> This patch puts memblock's .text/.data into its own section, so that it > >> only depends on CONFIG_ARCH_KEEP_MEMBLOCK to discard related code and > >> data. > >> > >> After this, from the log message in mem_init_print_info(), init size > >> increase from 2420K to 2432K on arch x86. > >> > >> Signed-off-by: Wei Yang > >> > >> --- > >> v2: fix orphan section for powerpc > >> --- > >> arch/powerpc/kernel/vmlinux.lds.S | 1 + > >> include/asm-generic/vmlinux.lds.h | 14 +++++++++++++- > >> include/linux/memblock.h | 8 ++++---- > >> 3 files changed, 18 insertions(+), 5 deletions(-) > >> > >> +#define __init_memblock __section(".mbinit.text") __cold notrace \ > >> + __latent_entropy > >> +#define __initdata_memblock __section(".mbinit.data") > >> + > > > >The new .mbinit.* sections should be added to scripts/mod/modpost.c > >alongside .meminit.* sections and then I expect modpost to report a bunch > >of section mismatches because many memblock functions are called on memory > >hotplug even on architectures that don't select ARCH_KEEP_MEMBLOCK. > > > > I tried to add some code in modpost.c, "make all" looks good. > > May I ask how can I trigger the "mismatch" warning? > > BTW, if ARCH_KEEP_MEMBLOCK unset, we would discard memblock meta-data. If > hotplug would call memblock function, it would be dangerous? > > The additional code I used is like below. > > --- > scripts/mod/modpost.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 937294ff164f..c837e2882904 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -777,14 +777,14 @@ static void check_section(const char *modname, struct elf_info *elf, > > #define ALL_INIT_DATA_SECTIONS \ > ".init.setup", ".init.rodata", ".meminit.rodata", \ > - ".init.data", ".meminit.data" > + ".init.data", ".meminit.data", "mbinit.data" should be ".mbinit.data" > > #define ALL_PCI_INIT_SECTIONS \ > ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ > ".pci_fixup_enable", ".pci_fixup_resume", \ > ".pci_fixup_resume_early", ".pci_fixup_suspend" > > -#define ALL_XXXINIT_SECTIONS ".meminit.*" > +#define ALL_XXXINIT_SECTIONS ".meminit.*", "mbinit.*" and ".mbinit.*" But regardless of typos, when ARCH_KEEP_MEMBLOCK=n the .mbinit is equivalent to .init and it should not be referenced from .meminit, so I don't think adding it here is correct. If I simply alias __init_memblock to __init then with CONFIG_MEMORY_HOTPLUG=y I get WARNING: modpost: vmlinux: section mismatch in reference: early_pfn_to_nid+0x42 (section: .meminit.text) -> memblock_search_pfn_nid (section: .init.text) WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x142 (section: .meminit.text) -> mirrored_kernelcore (section: .init.data) WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x1e1 (section: .meminit.text) -> memblock (section: .init.data) WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x1e8 (section: .meminit.text) -> memblock (section: .init.data) WARNING: modpost: vmlinux: section mismatch in reference: sparse_buffer_alloc+0x3b (section: .meminit.text) -> memblock_free (section: .init.text) > #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS > #define ALL_EXIT_SECTIONS ".exit.*" > @@ -799,7 +799,7 @@ static void check_section(const char *modname, struct elf_info *elf, > > #define INIT_SECTIONS ".init.*" > > -#define ALL_TEXT_SECTIONS ".init.text", ".meminit.text", ".exit.text", \ > +#define ALL_TEXT_SECTIONS ".init.text", ".meminit.text", ".mbinit.text", ".exit.text", \ > TEXT_SECTIONS, OTHER_TEXT_SECTIONS > > enum mismatch { > > -- > Wei Yang > Help you, Help me > -- Sincerely yours, Mike.