2005-04-17 06:20:36 +08:00
|
|
|
#ifndef _ASM_GENERIC_SECTIONS_H_
|
|
|
|
#define _ASM_GENERIC_SECTIONS_H_
|
|
|
|
|
|
|
|
/* References to section boundaries */
|
|
|
|
|
2014-10-10 06:30:30 +08:00
|
|
|
#include <linux/compiler.h>
|
2016-01-16 08:58:18 +08:00
|
|
|
#include <linux/types.h>
|
2014-10-10 06:30:30 +08:00
|
|
|
|
vmlinux.lds: add comments for global variables and clean up useless declarations
The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501 Now it has also been
expanded to reduce common code used by memory initializion.
Patch 1-7:
1) add comments for global variables exported by vmlinux.lds
2) normalize global variables exported by vmlinux.lds
Patch 8:
Introduce helper functions mem_init_print_info() and
get_num_physpages()
Patch 9:
Avoid using global variable num_physpages at runtime
Patch 10:
Don't update num_physpages in memory_hotplug.c
Patch 11-40:
Modify arch mm initialization code to:
1) Simplify mem_init() by using mem_init_print_info()
2) Prepare for killing global variable num_physpages
Patch 41:
Kill the global variable num_physpages
With all patches applied, mem_init(), free_initmem(), free_initrd_mem()
could be as simple as below. This patch series has reduced about 1.2K
lines of code in total.
#ifndef CONFIG_DISCONTIGMEM
void __init
mem_init(void)
{
max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
mem_init_print_info(NULL);
}
#endif /* CONFIG_DISCONTIGMEM */
void
free_initmem(void)
{
free_initmem_default(-1);
}
#ifdef CONFIG_BLK_DEV_INITRD
void
free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area(start, end, -1, "initrd");
}
#endif
Due to hardware resource limitations, I have only tested this on x86_64.
And the messages reported on an x86_64 system are:
Log message before applying patches:
Memory: 7745676k/8910848k available (6934k kernel code, 836024k absent, 329148k reserved, 6343k data, 1012k init)
Log message after applying patches:
Memory: 7744624K/8074824K available (6969K kernel code, 1011K data, 2828K rodata, 1016K init, 9640K bss, 330200K reserved)
Great thanks to Vineet Gupta for testing on ARC.
This patch:
Document global variables exported from vmlinux.lds.
1) Add comments about usage guidelines for global variables exported
from vmlinux.lds.S.
2) Remove unused __initdata_begin[] and __initdata_end[].
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-04 06:03:33 +08:00
|
|
|
/*
|
|
|
|
* Usage guidelines:
|
|
|
|
* _text, _data: architecture specific, don't use them in arch-independent code
|
|
|
|
* [_stext, _etext]: contains .text.* sections, may also contain .rodata.*
|
|
|
|
* and/or .init.* sections
|
|
|
|
* [_sdata, _edata]: contains .data.* sections, may also contain .rodata.*
|
|
|
|
* and/or .init.* sections.
|
|
|
|
* [__start_rodata, __end_rodata]: contains .rodata.* sections
|
2017-04-01 06:11:58 +08:00
|
|
|
* [__start_ro_after_init, __end_ro_after_init]:
|
|
|
|
* contains .data..ro_after_init section
|
vmlinux.lds: add comments for global variables and clean up useless declarations
The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501 Now it has also been
expanded to reduce common code used by memory initializion.
Patch 1-7:
1) add comments for global variables exported by vmlinux.lds
2) normalize global variables exported by vmlinux.lds
Patch 8:
Introduce helper functions mem_init_print_info() and
get_num_physpages()
Patch 9:
Avoid using global variable num_physpages at runtime
Patch 10:
Don't update num_physpages in memory_hotplug.c
Patch 11-40:
Modify arch mm initialization code to:
1) Simplify mem_init() by using mem_init_print_info()
2) Prepare for killing global variable num_physpages
Patch 41:
Kill the global variable num_physpages
With all patches applied, mem_init(), free_initmem(), free_initrd_mem()
could be as simple as below. This patch series has reduced about 1.2K
lines of code in total.
#ifndef CONFIG_DISCONTIGMEM
void __init
mem_init(void)
{
max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
mem_init_print_info(NULL);
}
#endif /* CONFIG_DISCONTIGMEM */
void
free_initmem(void)
{
free_initmem_default(-1);
}
#ifdef CONFIG_BLK_DEV_INITRD
void
free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area(start, end, -1, "initrd");
}
#endif
Due to hardware resource limitations, I have only tested this on x86_64.
And the messages reported on an x86_64 system are:
Log message before applying patches:
Memory: 7745676k/8910848k available (6934k kernel code, 836024k absent, 329148k reserved, 6343k data, 1012k init)
Log message after applying patches:
Memory: 7744624K/8074824K available (6969K kernel code, 1011K data, 2828K rodata, 1016K init, 9640K bss, 330200K reserved)
Great thanks to Vineet Gupta for testing on ARC.
This patch:
Document global variables exported from vmlinux.lds.
1) Add comments about usage guidelines for global variables exported
from vmlinux.lds.S.
2) Remove unused __initdata_begin[] and __initdata_end[].
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-04 06:03:33 +08:00
|
|
|
* [__init_begin, __init_end]: contains .init.* sections, but .init.text.*
|
|
|
|
* may be out of this range on some architectures.
|
|
|
|
* [_sinittext, _einittext]: contains .init.text.* sections
|
|
|
|
* [__bss_start, __bss_stop]: contains BSS sections
|
|
|
|
*
|
|
|
|
* Following global variables are optional and may be unavailable on some
|
|
|
|
* architectures and/or kernel configurations.
|
|
|
|
* _text, _data
|
|
|
|
* __kprobes_text_start, __kprobes_text_end
|
|
|
|
* __entry_text_start, __entry_text_end
|
|
|
|
* __ctors_start, __ctors_end
|
2017-08-03 10:38:21 +08:00
|
|
|
* __irqentry_text_start, __irqentry_text_end
|
|
|
|
* __softirqentry_text_start, __softirqentry_text_end
|
vmlinux.lds: add comments for global variables and clean up useless declarations
The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501 Now it has also been
expanded to reduce common code used by memory initializion.
Patch 1-7:
1) add comments for global variables exported by vmlinux.lds
2) normalize global variables exported by vmlinux.lds
Patch 8:
Introduce helper functions mem_init_print_info() and
get_num_physpages()
Patch 9:
Avoid using global variable num_physpages at runtime
Patch 10:
Don't update num_physpages in memory_hotplug.c
Patch 11-40:
Modify arch mm initialization code to:
1) Simplify mem_init() by using mem_init_print_info()
2) Prepare for killing global variable num_physpages
Patch 41:
Kill the global variable num_physpages
With all patches applied, mem_init(), free_initmem(), free_initrd_mem()
could be as simple as below. This patch series has reduced about 1.2K
lines of code in total.
#ifndef CONFIG_DISCONTIGMEM
void __init
mem_init(void)
{
max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
mem_init_print_info(NULL);
}
#endif /* CONFIG_DISCONTIGMEM */
void
free_initmem(void)
{
free_initmem_default(-1);
}
#ifdef CONFIG_BLK_DEV_INITRD
void
free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area(start, end, -1, "initrd");
}
#endif
Due to hardware resource limitations, I have only tested this on x86_64.
And the messages reported on an x86_64 system are:
Log message before applying patches:
Memory: 7745676k/8910848k available (6934k kernel code, 836024k absent, 329148k reserved, 6343k data, 1012k init)
Log message after applying patches:
Memory: 7744624K/8074824K available (6969K kernel code, 1011K data, 2828K rodata, 1016K init, 9640K bss, 330200K reserved)
Great thanks to Vineet Gupta for testing on ARC.
This patch:
Document global variables exported from vmlinux.lds.
1) Add comments about usage guidelines for global variables exported
from vmlinux.lds.S.
2) Remove unused __initdata_begin[] and __initdata_end[].
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-04 06:03:33 +08:00
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
extern char _text[], _stext[], _etext[];
|
|
|
|
extern char _data[], _sdata[], _edata[];
|
|
|
|
extern char __bss_start[], __bss_stop[];
|
|
|
|
extern char __init_begin[], __init_end[];
|
|
|
|
extern char _sinittext[], _einittext[];
|
2017-04-01 06:11:58 +08:00
|
|
|
extern char __start_ro_after_init[], __end_ro_after_init[];
|
2005-04-17 06:20:36 +08:00
|
|
|
extern char _end[];
|
2009-01-13 19:41:35 +08:00
|
|
|
extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
|
2005-09-07 06:19:26 +08:00
|
|
|
extern char __kprobes_text_start[], __kprobes_text_end[];
|
2011-03-08 02:10:39 +08:00
|
|
|
extern char __entry_text_start[], __entry_text_end[];
|
2006-07-01 19:36:30 +08:00
|
|
|
extern char __start_rodata[], __end_rodata[];
|
2017-08-03 10:38:21 +08:00
|
|
|
extern char __irqentry_text_start[], __irqentry_text_end[];
|
|
|
|
extern char __softirqentry_text_start[], __softirqentry_text_end[];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-06-18 07:28:03 +08:00
|
|
|
/* Start and end of .ctors section - used for constructor calls. */
|
|
|
|
extern char __ctors_start[], __ctors_end[];
|
|
|
|
|
2014-10-10 06:30:30 +08:00
|
|
|
extern __visible const void __nosave_begin, __nosave_end;
|
|
|
|
|
2008-09-04 09:43:36 +08:00
|
|
|
/* function descriptor handling (if any). Override
|
|
|
|
* in asm/sections.h */
|
|
|
|
#ifndef dereference_function_descriptor
|
|
|
|
#define dereference_function_descriptor(p) (p)
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 07:44:14 +08:00
|
|
|
/* random extra sections (if any). Override
|
|
|
|
* in asm/sections.h */
|
|
|
|
#ifndef arch_is_kernel_text
|
|
|
|
static inline int arch_is_kernel_text(unsigned long addr)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef arch_is_kernel_data
|
|
|
|
static inline int arch_is_kernel_data(unsigned long addr)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-16 08:58:18 +08:00
|
|
|
/**
|
|
|
|
* memory_contains - checks if an object is contained within a memory region
|
|
|
|
* @begin: virtual address of the beginning of the memory region
|
|
|
|
* @end: virtual address of the end of the memory region
|
|
|
|
* @virt: virtual address of the memory object
|
|
|
|
* @size: size of the memory object
|
|
|
|
*
|
|
|
|
* Returns: true if the object specified by @virt and @size is entirely
|
|
|
|
* contained within the memory region defined by @begin and @end, false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
static inline bool memory_contains(void *begin, void *end, void *virt,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
return virt >= begin && virt + size <= end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* memory_intersects - checks if the region occupied by an object intersects
|
|
|
|
* with another memory region
|
|
|
|
* @begin: virtual address of the beginning of the memory regien
|
|
|
|
* @end: virtual address of the end of the memory region
|
|
|
|
* @virt: virtual address of the memory object
|
|
|
|
* @size: size of the memory object
|
|
|
|
*
|
|
|
|
* Returns: true if an object's memory region, specified by @virt and @size,
|
|
|
|
* intersects with the region specified by @begin and @end, false otherwise.
|
|
|
|
*/
|
|
|
|
static inline bool memory_intersects(void *begin, void *end, void *virt,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
void *vend = virt + size;
|
|
|
|
|
|
|
|
return (virt >= begin && virt < end) || (vend >= begin && vend < end);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* init_section_contains - checks if an object is contained within the init
|
|
|
|
* section
|
|
|
|
* @virt: virtual address of the memory object
|
|
|
|
* @size: size of the memory object
|
|
|
|
*
|
|
|
|
* Returns: true if the object specified by @virt and @size is entirely
|
|
|
|
* contained within the init section, false otherwise.
|
|
|
|
*/
|
|
|
|
static inline bool init_section_contains(void *virt, size_t size)
|
|
|
|
{
|
|
|
|
return memory_contains(__init_begin, __init_end, virt, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* init_section_intersects - checks if the region occupied by an object
|
|
|
|
* intersects with the init section
|
|
|
|
* @virt: virtual address of the memory object
|
|
|
|
* @size: size of the memory object
|
|
|
|
*
|
|
|
|
* Returns: true if an object's memory region, specified by @virt and @size,
|
|
|
|
* intersects with the init section, false otherwise.
|
|
|
|
*/
|
|
|
|
static inline bool init_section_intersects(void *virt, size_t size)
|
|
|
|
{
|
|
|
|
return memory_intersects(__init_begin, __init_end, virt, size);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _ASM_GENERIC_SECTIONS_H_ */
|