Solve section mismatch for free_area_init_core.
Solve section mismatch for free_area_init_core:
WARNING: vmlinux.o(.meminit.text+0x649):
Section mismatch in reference from the
function free_area_init_core() to the function .init.text:setup_usemap() The function __meminit free_area_init_core() references
a function __init setup_usemap().
If free_area_init_core is only used by setup_usemap then annotate free_area_init_core with a matching annotation.
The warning is covers this stack of functions in mm/page_alloc.c:
alloc_bootmem_node must be marked __init. alloc_bootmem_node is used by setup_usemap, if !SPARSEMEM. (usemap_size is only used by setup_usemap, if !SPARSEMEM.) setup_usemap is only used by free_area_init_core. free_area_init_core is only used by free_area_init_node.
free_area_init_node is used by:arch/alpha/mm/numa.c: __init paging_init() arch/arm/mm/init.c: __init bootmem_init_node() arch/avr32/mm/init.c: __init paging_init() arch/cris/arch-v10/mm/init.c: __init paging_init() arch/cris/arch-v32/mm/init.c: __init paging_init() arch/m32r/mm/discontig.c: __init zone_sizes_init() arch/m32r/mm/init.c: __init zone_sizes_init() arch/m68k/mm/motorola.c: __init paging_init() arch/m68k/mm/sun3mmu.c: __init paging_init() arch/mips/sgi-ip27/ip27-memory.c: __init paging_init() arch/parisc/mm/init.c: __init paging_init() arch/sparc/mm/srmmu.c: __init srmmu_paging_init() arch/sparc/mm/sun4c.c: __init sun4c_paging_init() arch/sparc64/mm/init.c: __init paging_init() mm/page_alloc.c: __init free_area_init_nodes() mm/page_alloc.c: __init free_area_init()
andmm/memory_hotplug.c: hotadd_new_pgdat()
hotadd_new_pgdat can not be an __init function, but:
It is compiled for MEMORY_HOTPLUG configurations only MEMORY_HOTPLUG depends on SPARSEMEM || X86_64_ACPI_NUMA X86_64_ACPI_NUMA depends on X86_64 ARCH_FLATMEM_ENABLE depends on X86_32 ARCH_DISCONTIGMEM_ENABLE depends on X86_32
So X86_64_ACPI_NUMA implies SPARSEMEM, right?
So we can mark the stack of functions __init for !SPARSEMEM, but we must mark them __meminit for SPARSEMEM configurations. This is ok, because then the calls to alloc_bootmem_node are also avoided.
Compile-tested on:
silly minimal config
defconfig x86_32
defconfig x86_64
defconfig x86_64 -HIBERNATION +MEMORY_HOTPLUG
Comments?
mm/internal.h +13 -0
@@ -47,4 +47,17 @@ static inline unsigned long page_order(struct page *page)VM_BUG_ON (!PageBuddy (page)); return page_private(page); } + +/* +* FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node, +* so all functions starting at paging_init should be marked __init +* in those cases. SPARSEMEM, however, allows for memory hotplug, +* and alloc_bootmem_node is not used. +*/ +#ifdef CONFIG_SPARSEMEM +#define __paginginit __meminit +#else +#define __paginginit __init +#endif +#endif
mm/page_alloc.c +2 -2
@@ -3321,7 +3321,7 @@ static inline int pageblock_default_order(unsigned int order)* - mark all memory queues empty * - clear the memory bitmaps */ -static void __meminit free_area_init_core (struct pglist_data *pgdat, +static void __paginginit free_area_init_core(struct pglist_data *pgdat,unsigned long *zones_size,unsigned long *zholes_size) {enum zone_type j;
@@ -3445,7 +3445,7 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)#endif /* CONFIG_FLAT_NODE_MEM_MAP */ } -void __meminit free_area_init_node (int nid,struct pglist_data *pgdat, +void __paginginit free_area_init_node(int nid, struct pglist_data *pgdat,unsigned long *zones_size,unsigned long node_start_pfn,unsigned long *zholes_size) {
Sam Ravnborg
Reviewed-byHi Andrew.
I have (triggered by Geert) spend some time reviewing this patch and I see no better way to fix it.
So it gets my:
Original mail is here:
http://lkml.org/lkml/2008/2/3/129
Can you take it in -mm so we get some testing coverage.
Thanks,
Sam
Quoted 112 lines · Alexander van Heukelum
Solve section mismatch for
free_area_init_core:WARNING:
vmlinux.o(.meminit.text+0x649):
Section mismatch in reference from the
functionfree_area_init_core()to the function .init.text:setup_usemap() The function__meminitfree_area_init_core()references
a function__initsetup_usemap().
Iffree_area_init_coreis only used bysetup_usemapthen annotatefree_area_init_corewith a matching annotation.The warning is covers this stack of functions in
mm/page_alloc.c:
alloc_bootmem_nodemust be marked__init.alloc_bootmem_nodeis used bysetup_usemap, if !SPARSEMEM. (usemap_sizeis only used bysetup_usemap, if !SPARSEMEM.)setup_usemapis only used byfree_area_init_core.free_area_init_coreis only used byfree_area_init_node.
free_area_init_nodeis used by:arch/alpha/mm/numa.c:__initpaging_init()arch/arm/mm/init.c:__initbootmem_init_node()arch/avr32/mm/init.c:__initpaging_init()arch/cris/arch-v10/mm/init.c:__initpaging_init()arch/cris/arch-v32/mm/init.c:__initpaging_init()arch/m32r/mm/discontig.c:__initzone_sizes_init()arch/m32r/mm/init.c:__initzone_sizes_init()arch/m68k/mm/motorola.c:__initpaging_init()arch/m68k/mm/sun3mmu.c:__initpaging_init()arch/mips/sgi-ip27/ip27-memory.c:__initpaging_init()arch/parisc/mm/init.c:__initpaging_init()arch/sparc/mm/srmmu.c:__initsrmmu_paging_init()arch/sparc/mm/sun4c.c:__initsun4c_paging_init()arch/sparc64/mm/init.c:__initpaging_init()mm/page_alloc.c:__initfree_area_init_nodes()mm/page_alloc.c:__initfree_area_init()
andmm/memory_hotplug.c:hotadd_new_pgdat()
hotadd_new_pgdatcan not be an__initfunction, but:It is compiled for
MEMORY_HOTPLUGconfigurations onlyMEMORY_HOTPLUGdepends on SPARSEMEM ||X86_64_ACPI_NUMAX86_64_ACPI_NUMAdepends onX86_64ARCH_FLATMEM_ENABLEdepends onX86_32ARCH_DISCONTIGMEM_ENABLEdepends onX86_32
SoX86_64_ACPI_NUMAimplies SPARSEMEM, right?So we can mark the stack of functions
__initfor !SPARSEMEM, but we must mark them__meminitfor SPARSEMEM configurations. This is ok, because then the calls toalloc_bootmem_nodeare also avoided.Compile-tested on:
silly minimal config
defconfigx86_32
defconfigx86_64
defconfigx86_64-HIBERNATION +MEMORY_HOTPLUGComments?
Signed-off-by Alexander van Heukelum <[email protected]>mm/internal.h +13
-0@@ -47,4 +47,17 @@ static inline unsigned long page_order(struct page *page)VM_BUG_ON (!PageBuddy (page)); return page_private(page); } + +/* +* FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node, +* so all functions starting at paging_init should be marked __init +* in those cases. SPARSEMEM, however, allows for memory hotplug, +* and alloc_bootmem_node is not used. +*/ +#ifdef CONFIG_SPARSEMEM +#define __paginginit __meminit +#else +#define __paginginit __init +#endif +#endif mm/page_alloc.c +2
-3@@ -3321,7 +3321,7 @@ static inline int pageblock_default_order(unsigned int order)* - mark all memory queues empty * - clear the memory bitmaps */ -static void __meminit free_area_init_core (struct pglist_data *pgdat, +static void __paginginit free_area_init_core(struct pglist_data *pgdat,unsigned long *zones_size,unsigned long *zholes_size) {enum zone_type j;@@ -3445,7 +3445,7 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)#endif /* CONFIG_FLAT_NODE_MEM_MAP */ } -void __meminit free_area_init_node (int nid,struct pglist_data *pgdat, +void __paginginit free_area_init_node(int nid, struct pglist_data *pgdat,unsigned long *zones_size,unsigned long node_start_pfn,unsigned long *zholes_size) { --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Geert Uytterhoeven
Acked-byQuoted 6 lines · Sam Ravnborg
I have (triggered by Geert) spend some time reviewing this patch and I see no better way to fix it.
So it gets my:
Reviewed-by Sam Ravnborg <[email protected]>
Quoted 111 lines
Original mail is here:
http://lkml.org/lkml/2008/2/3/129Can you take it in -mm so we get some testing coverage.
Thanks,
SamQuoted 102 lines · Alexander van Heukelum
Solve section mismatch for
free_area_init_core:WARNING:
vmlinux.o(.meminit.text+0x649):
Section mismatch in reference from the
functionfree_area_init_core()to the function .init.text:setup_usemap() The function__meminitfree_area_init_core()references
a function__initsetup_usemap().
Iffree_area_init_coreis only used bysetup_usemapthen annotatefree_area_init_corewith a matching annotation.The warning is covers this stack of functions in
mm/page_alloc.c:
alloc_bootmem_nodemust be marked__init.alloc_bootmem_nodeis used bysetup_usemap, if !SPARSEMEM. (usemap_sizeis only used bysetup_usemap, if !SPARSEMEM.)setup_usemapis only used byfree_area_init_core.free_area_init_coreis only used byfree_area_init_node.
free_area_init_nodeis used by:arch/alpha/mm/numa.c:__initpaging_init()arch/arm/mm/init.c:__initbootmem_init_node()arch/avr32/mm/init.c:__initpaging_init()arch/cris/arch-v10/mm/init.c:__initpaging_init()arch/cris/arch-v32/mm/init.c:__initpaging_init()arch/m32r/mm/discontig.c:__initzone_sizes_init()arch/m32r/mm/init.c:__initzone_sizes_init()arch/m68k/mm/motorola.c:__initpaging_init()arch/m68k/mm/sun3mmu.c:__initpaging_init()arch/mips/sgi-ip27/ip27-memory.c:__initpaging_init()arch/parisc/mm/init.c:__initpaging_init()arch/sparc/mm/srmmu.c:__initsrmmu_paging_init()arch/sparc/mm/sun4c.c:__initsun4c_paging_init()arch/sparc64/mm/init.c:__initpaging_init()mm/page_alloc.c:__initfree_area_init_nodes()mm/page_alloc.c:__initfree_area_init()
andmm/memory_hotplug.c:hotadd_new_pgdat()
hotadd_new_pgdatcan not be an__initfunction, but:It is compiled for
MEMORY_HOTPLUGconfigurations onlyMEMORY_HOTPLUGdepends on SPARSEMEM ||X86_64_ACPI_NUMAX86_64_ACPI_NUMAdepends onX86_64ARCH_FLATMEM_ENABLEdepends onX86_32ARCH_DISCONTIGMEM_ENABLEdepends onX86_32
SoX86_64_ACPI_NUMAimplies SPARSEMEM, right?So we can mark the stack of functions
__initfor !SPARSEMEM, but we must mark them__meminitfor SPARSEMEM configurations. This is ok, because then the calls toalloc_bootmem_nodeare also avoided.Compile-tested on:
silly minimal config
defconfigx86_32
defconfigx86_64
defconfigx86_64-HIBERNATION +MEMORY_HOTPLUGComments?
Signed-off-by Alexander van Heukelum <[email protected]>mm/internal.h +13
-0@@ -47,4 +47,17 @@ static inline unsigned long page_order(struct page *page)VM_BUG_ON (!PageBuddy (page)); return page_private(page); } + +/* +* FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node, +* so all functions starting at paging_init should be marked __init +* in those cases. SPARSEMEM, however, allows for memory hotplug, +* and alloc_bootmem_node is not used. +*/ +#ifdef CONFIG_SPARSEMEM +#define __paginginit __meminit +#else +#define __paginginit __init +#endif +#endif mm/page_alloc.c +1
-1@@ -3321,7 +3321,7 @@ static inline int pageblock_default_order(unsigned int order)* - mark all memory queues empty * - clear the memory bitmaps */ -static void __meminit free_area_init_core (struct pglist_data *pgdat, +static void __paginginit free_area_init_core(struct pglist_data *pgdat,unsigned long *zones_size,unsigned long *zholes_size) {enum zone_type j;@@ -3445,7 +3445,7 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)#endif /* CONFIG_FLAT_NODE_MEM_MAP */ }
Quoted 16 lines
Quoted 10 lines
mm/page_alloc.c +1
-2-void __meminit free_area_init_node (int nid,struct pglist_data *pgdat, +void __paginginit free_area_init_node(int nid, struct pglist_data *pgdat,unsigned long *zones_size,unsigned long node_start_pfn,unsigned long *zholes_size) { --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Lump xxxinit together with init if possible (was Re: Solve section mismatch for free_area_init_core.)
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Sam Ravnborg
I have (triggered by Geert) spend some time reviewing this patch and I see no better way to fix it.
So it gets my:
Reviewed-by Sam Ravnborg <[email protected]>
Thanks!
I more than less expected people to scream "ugly, ugly!". Maybe you could consider the following patch, instead?
In non-HOTPLUG configurations, devinit and init sections in vmlinux are lumped together during the final link. There is no good reason to warn about section mismatches between them in this case, because all code is discarded at the same time. This patch moves the lumping- together to the compile stage, which makes the unnecessary warnings go away. Same for MEMORY_HOTPLUG/meminit and HOTPLUG_CPU/cpuinit.
On the condition that someone with knowledge in this area confirms that this approach is right and not for some reason undesirable:
include/asm-generic/vmlinux.lds.h | 98 ++++++++---------------------------- include/linux/init.h | 27 ++++++++++ 2 files changed, 49 insertions(+), 76 deletions(-)
include/asm-generic/vmlinux.lds.h +22 -76
@@ -9,46 +9,17 @@/* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8) -/* The actual configuration determine if the init/exit sections -* are handled as text/data or they can be discarded (which -* often happens at runtime) -*/ -#ifdef CONFIG_HOTPLUG -#define DEV_KEEP (sec) *(.dev##sec) -#define DEV_DISCARD (sec) -#else -#define DEV_KEEP (sec) -#define DEV_DISCARD (sec) *(.dev##sec) -#endif - -#ifdef CONFIG_HOTPLUG_CPU -#define CPU_KEEP (sec) *(.cpu##sec) -#define CPU_DISCARD (sec) -#else -#define CPU_KEEP (sec) -#define CPU_DISCARD (sec) *(.cpu##sec) -#endif - -#if defined(CONFIG_MEMORY_HOTPLUG ) -#define MEM_KEEP (sec) *(.mem##sec) -#define MEM_DISCARD (sec) -#else -#define MEM_KEEP (sec) -#define MEM_DISCARD (sec) *(.mem##sec) -#endif - -/* .data section */ #define DATA_DATA \ *(.data) \ *(.data.init.refok) \ *(.ref.data) \ - DEV_KEEP(init.data) \ - DEV_KEEP(exit.data) \ - CPU_KEEP(init.data) \ - CPU_KEEP(exit.data) \ - MEM_KEEP(init.data) \ - MEM_KEEP(exit.data) \ + *(.devinit.data) \ + *(.devexit.data) \ + *(.cpuinit.data) \ + *(.cpuexit.data) \ + *(.meminit.data) \ + *(.memexit.data) \ . = ALIGN(8); \ VMLINUX_SYMBOL(__start___markers) = .; \ *(__markers) \
@@ -171,12 +142,12 @@/* __*init sections */ \ __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ *(.ref.rodata) \ - DEV_KEEP(init.rodata) \ - DEV_KEEP(exit.rodata) \ - CPU_KEEP(init.rodata) \ - CPU_KEEP(exit.rodata) \ - MEM_KEEP(init.rodata) \ - MEM_KEEP(exit.rodata) \ + *(.devinit.rodata) \ + *(.devexit.rodata) \ + *(.cpuinit.rodata) \ + *(.cpuexit.rodata) \ + *(.meminit.rodata) \ + *(.memexit.rodata) \ } \ \/* Built-in module parameters. */ \
@@ -208,12 +179,12 @@ *(.ref.text) \ *(.text.init.refok) \ *(.exit.text.refok) \ - DEV_KEEP(init.text) \ - DEV_KEEP(exit.text) \ - CPU_KEEP(init.text) \ - CPU_KEEP(exit.text) \ - MEM_KEEP(init.text) \ -MEM_KEEP (exit.text) + *(.devinit.text) \ + *(.devexit.text) \ + *(.cpuinit.text) \ + *(.cpuexit.text) \ + *(.meminit.text) \ + *(.memexit.text)/* sched.text is aling to function alignment to secure we have same
@@ -242,35 +213,10 @@#define HEAD_TEXT *(.head.text)/* init and exit section handling */ -#define INIT_DATA \ - *(.init.data) \ - DEV_DISCARD(init.data) \ - DEV_DISCARD(init.rodata) \ - CPU_DISCARD(init.data) \ - CPU_DISCARD(init.rodata) \ - MEM_DISCARD(init.data) \ - MEM_DISCARD(init.rodata) - -#define INIT_TEXT \ - *(.init.text) \ - DEV_DISCARD(init.text) \ - CPU_DISCARD(init.text) \ - MEM_DISCARD(init.text) - -#define EXIT_DATA \ - *(.exit.data) \ - DEV_DISCARD(exit.data) \ - DEV_DISCARD(exit.rodata) \ - CPU_DISCARD(exit.data) \ - CPU_DISCARD(exit.rodata) \ - MEM_DISCARD(exit.data) \ - MEM_DISCARD(exit.rodata) - -#define EXIT_TEXT \ - *(.exit.text) \ - DEV_DISCARD(exit.text) \ - CPU_DISCARD(exit.text) \ - MEM_DISCARD(exit.text) +#define INIT_DATA *(.init.data) +#define INIT_TEXT *(.init.text) +#define EXIT_DATA *(.exit.data) +#define EXIT_TEXT *(.exit.text)/* DWARF debug sections. Symbols in the DWARF debugging sections are relative to
include/linux/init.h +27 -0
@@ -83,28 +83,55 @@#define __exit __section(.exit.text) __exitused __cold/* Used for HOTPLUG */ +#if defined(MODULE ) || defined(CONFIG_HOTPLUG )#define __devinit __section(.devinit.text) __cold#define __devinitdata __section(.devinit.data)#define __devinitconst __section(.devinit.rodata)#define __devexit __section(.devexit.text) __exitused __cold#define __devexitdata __section(.devexit.data)#define __devexitconst __section(.devexit.rodata) +#else +#define __devinit __section(.init.text) __cold +#define __devinitdata __section(.init.data) +#define __devinitconst __section(.init.rodata) +#define __devexit __section(.exit.text) __exitused __cold +#define __devexitdata __section(.exit.data) +#define __devexitconst __section(.exit.rodata) +#endif /* Used for HOTPLUG_CPU */ +#if defined(MODULE ) || defined(CONFIG_HOTPLUG_CPU )#define __cpuinit __section(.cpuinit.text) __cold#define __cpuinitdata __section(.cpuinit.data)#define __cpuinitconst __section(.cpuinit.rodata)#define __cpuexit __section(.cpuexit.text) __exitused __cold#define __cpuexitdata __section(.cpuexit.data)#define __cpuexitconst __section(.cpuexit.rodata) +#else +#define __cpuinit __section(.init.text) __cold +#define __cpuinitdata __section(.init.data) +#define __cpuinitconst __section(.init.rodata) +#define __cpuexit __section(.exit.text) __exitused __cold +#define __cpuexitdata __section(.exit.data) +#define __cpuexitconst __section(.exit.rodata) +#endif /* Used for MEMORY_HOTPLUG */ +#if defined(MODULE ) || defined(CONFIG_MEMORY_HOTPLUG )#define __meminit __section(.meminit.text) __cold#define __meminitdata __section(.meminit.data)#define __meminitconst __section(.meminit.rodata)#define __memexit __section(.memexit.text) __exitused __cold#define __memexitdata __section(.memexit.data)#define __memexitconst __section(.memexit.rodata) +#else +#define __meminit __section(.init.text) __cold +#define __meminitdata __section(.init.data) +#define __meminitconst __section(.init.rodata) +#define __memexit __section(.exit.text) __exitused __cold +#define __memexitdata __section(.exit.data) +#define __memexitconst __section(.exit.rodata) +#endif /* For assembly routines */ #define __HEAD .section ".head.text","ax"
Re: Lump xxxinit together with init if possible (was Re: Solve section mismatch for free_area_init_core.)
Hi Alexander.
Quoted 1 line
I more than less expected people to scream "ugly, ugly!".
That was my first thought and the reason why it stayed in my inbox for so long.
But I could not find a better way to do it. We could do it in different ways but not better.
Quoted 9 lines
Maybe you could consider the following patch, instead?
In non-HOTPLUG configurations, devinit and init sections in vmlinux are lumped together during the final link. There is no good reason to warn about section mismatches between them in this case, because all code is discarded at the same time. This patch moves the lumping- together to the compile stage, which makes the unnecessary warnings go away. Same for MEMORY_HOTPLUG/meminit and HOTPLUG_CPU/cpuinit.From the commit where the seperate section were introduced:
Introducing separate sections for __dev* (HOTPLUG), __cpu* (HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG) allows us to do a much more reliable Section mismatch check in modpost. We are no longer dependent on the actual configuration of for example HOTPLUG.
I think that explains it.
Sam
Re: Lump xxxinit together with init if possible (was Re: Solve section mismatch for free_area_init_core.)
Quoted 18 lines · Sam Ravnborg
Hi Alexander.
Quoted 1 line
I more than less expected people to scream "ugly, ugly!".
That was my first thought and the reason why it stayed in my inbox for so long.
But I could not find a better way to do it. We could do it in different ways but not better.Quoted 7 lines
Maybe you could consider the following patch, instead?
In non-HOTPLUG configurations, devinit and init sections in vmlinux are lumped together during the final link. There is no good reason to warn about section mismatches between them in this case, because all code is discarded at the same time. This patch moves the lumping- together to the compile stage, which makes the unnecessary warnings go away. Same for MEMORY_HOTPLUG/meminit and HOTPLUG_CPU/cpuinit.From the commit where the seperate section were introduced:
Quoted 7 lines
Introducing separate sections for __dev* (HOTPLUG), __cpu* (
HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG) allows us to do a much more reliable Section mismatch check in modpost. We are no longer dependent on the actual configuration of for example HOTPLUG.I think that explains it.
I should have looked at that commit first. Indeed, it does explain why it is better to keep the sections separate. Thanks.
Signature · 5 lines
Alexander van Heukelum [email protected] -- http://www.fastmail.fm - Choose from over 50 domains or use your own