x86/e820: Mark some static functions __init
PATCH 1/3 x86/e820: Mark some static functions __init
They are all called only from other __init functions in e820.c
--- arch/x86/kernel/e820.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/e820.c +6 -6
@@ -802,7 +802,7 @@ unsigned long __init e820_end_of_low_ram_pfn(void)return e820_end_pfn (1UL << (32 -PAGE_SHIFT )); } -static void early_panic (char *msg) +static void __init early_panic (char *msg) {early_printk (msg);panic (msg);
@@ -912,7 +912,7 @@ void __init finish_e820_parsing(void) } } -static const char *e820_type_to_string (int e820_type) +static const char *__init e820_type_to_string (int e820_type) {switch (e820_type) {case E820_RESERVED_KERN :
@@ -926,7 +926,7 @@ static const char *e820_type_to_string(int e820_type) } } -static unsigned long e820_type_to_iomem_type (int e820_type) +static unsigned long __init e820_type_to_iomem_type (int e820_type) {switch (e820_type) {case E820_RESERVED_KERN :
@@ -942,7 +942,7 @@ static unsigned long e820_type_to_iomem_type(int e820_type) } } -static unsigned long e820_type_to_iores_desc (int e820_type) +static unsigned long __init e820_type_to_iores_desc (int e820_type) {switch (e820_type) {case E820_ACPI :
@@ -961,7 +961,7 @@ static unsigned long e820_type_to_iores_desc(int e820_type) } } -static bool do_mark_busy (u32 type,struct resource *res) +static bool __init do_mark_busy (u32 type,struct resource *res) {/* this is the legacy bios/dos rom-shadow + mmio region */ if (res->start < (1ULL <<20 ))
@@ -1027,7 +1027,7 @@ void __init e820_reserve_resources(void) }/* How much should we pad RAM ending depending on where it is? */ -static unsigned long ram_alignment (resource_size_t pos) +static unsigned long __init ram_alignment (resource_size_t pos) {unsigned long mb = pos >>20 ;
Signature · 1 line
2.9.2
PATCH 2/3 x86/e820: Prepare e280 code for switch to dynamic storage
This patch turns e820 and e820_saved into pointers to e820 tables, of the same size as before.
--- arch/x86/include/asm/e820.h | 6 +- arch/x86/kernel/e820.c | 125 +++++++++++++++++++++++--------------- arch/x86/kernel/early-quirks.c | 2 +- arch/x86/kernel/kexec-bzimage64.c | 4 +- arch/x86/kernel/resource.c | 4 +- arch/x86/kernel/setup.c | 8 +-- arch/x86/kernel/tboot.c | 8 +-- arch/x86/mm/init.c | 2 + arch/x86/platform/efi/efi.c | 2 +- arch/x86/xen/setup.c | 2 +- 10 files changed, 98 insertions(+), 65 deletions(-)
arch/x86/include/asm/e820.h +4 -2
@@ -10,8 +10,8 @@#include <uapi/asm/e820.h> #ifndef __ASSEMBLY__/* see comment in arch/x86/kernel/e820.c */ -extern struct e820map e820; -extern struct e820map e820_saved; +extern struct e820map *e820; +extern struct e820map *e820_saved;extern unsigned long pci_mem_start;extern int e820_any_mapped (u64 start,u64 end,unsigned type);
@@ -53,6 +53,8 @@ extern void e820_reserve_resources_late(void);extern void setup_memory_map (void );extern char *default_machine_specific_memory_setup (void ); +extern void e820_reallocate_tables (void ); +/* * Returns true iff the specified range [s,e) is completely contained inside * the ISA region.
arch/x86/kernel/e820.c +77 -48
294 lines not on this page · raw message
arch/x86/kernel/early-quirks.c +1 -1
@@ -555,7 +555,7 @@ intel_graphics_stolen(int num, int slot, int func,/* Mark this space as reserved */ e820_add_region (base, size,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }static void __init intel_graphics_quirks (int num,int slot,int func)
arch/x86/kernel/kexec-bzimage64.c +2 -2
@@ -99,14 +99,14 @@ static int setup_e820_entries(struct boot_params *params) {unsigned int nr_e820_entries; - nr_e820_entries = e820_saved.nr_map; + nr_e820_entries = e820_saved->nr_map;/* TODO: Pass entries more than E820MAX in bootparams setup data */ if (nr_e820_entries >E820MAX ) nr_e820_entries =E820MAX ; params->e820_entries = nr_e820_entries; -memcpy (¶ms->e820_map, &e820_saved.map, +memcpy (¶ms->e820_map, &e820_saved->map, nr_e820_entries *sizeof (struct e820entry ));return 0 ;
arch/x86/kernel/resource.c +2 -2
@@ -27,8 +27,8 @@ static void remove_e820_regions(struct resource *avail)int i;struct e820entry *entry; -for (i =0 ; i < e820.nr_map; i++) { - entry = &e820.map[i]; +for (i =0 ; i < e820->nr_map; i++) { + entry = &e820->map[i];resource_clip (avail, entry->addr, entry->addr + entry->size -1 );
arch/x86/kernel/setup.c +4 -4
@@ -458,8 +458,8 @@ static void __init e820_reserve_setup_data(void)early_memunmap (data,sizeof (*data)); } -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); -memcpy (&e820_saved, &e820,sizeof (struct e820map )); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); +memcpy (e820_saved, e820,sizeof (struct e820map ));printk (KERN_INFO "extended physical RAM map:\n" );e820_print_map ("reserve setup_data" ); }
@@ -763,7 +763,7 @@ static void __init trim_bios_range(void)*/ e820_remove_range (BIOS_BEGIN ,BIOS_END -BIOS_BEGIN ,E820_RAM ,1 ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }/* called before trim_bios_range() to spare extra sanitize */
@@ -1032,7 +1032,7 @@ void __init setup_arch(char **cmdline_p)if (ppro_with_ram_bug ()) {e820_update_range (0x70000000ULL ,0x40000ULL ,E820_RAM ,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map);printk (KERN_INFO "fixed physical RAM map:\n" );e820_print_map ("bad_ppro" ); }
arch/x86/kernel/tboot.c +4 -4
@@ -188,12 +188,12 @@ static int tboot_setup_sleep(void) tboot->num_mac_regions =0 ; -for (i =0 ; i < e820.nr_map; i++) { -if ((e820.map[i].type !=E820_RAM ) - && (e820.map[i].type !=E820_RESERVED_KERN )) +for (i =0 ; i < e820->nr_map; i++) { +if ((e820->map[i].type !=E820_RAM ) + && (e820->map[i].type !=E820_RESERVED_KERN ))continue ; -add_mac_region (e820.map[i].addr, e820.map[i].size); +add_mac_region (e820->map[i].addr, e820->map[i].size); } tboot->acpi_sinfo.kernel_s3_resume_vector =
arch/x86/mm/init.c +2 -0
@@ -701,6 +701,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)void free_initmem (void ) { +/* e820_reallocate_tables(); - disabled for now */ +free_init_pages ("unused kernel" , (unsigned long )(&__init_begin), (unsigned long )(&__init_end));
arch/x86/platform/efi/efi.c +1 -1
@@ -166,7 +166,7 @@ static void __init do_add_efi_memmap(void) }e820_add_region (start, size, e820_type); } -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }int __init efi_memblock_x86_reserve_range (void )
arch/x86/xen/setup.c +1 -1
@@ -861,7 +861,7 @@ char * __init xen_memory_setup(void)e820_add_region (ISA_START_ADDRESS ,ISA_END_ADDRESS -ISA_START_ADDRESS ,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map);/* * Check whether the kernel itself conflicts with the target E820 map.
Signature · 1 line
2.9.2
tip-bot for Denys Vlasenko
merge bot[tip:x86/boot] x86/e820: Prepare e280 code for switch to dynamic storage
x86/e820: Prepare e280 code for switch to dynamic storage
Commit-ID: 475339684ef19e46f4702e2d185a869a5c454688 Gitweb: http://git.kernel.org/tip/475339684ef19e46f4702e2d185a869a5c454688 Author: Denys Vlasenko <[email protected]> AuthorDate: Sat, 17 Sep 2016 23:39:26 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 21 Sep 2016 15:02:12 +0200
x86/e820: Prepare e280 code for switch to dynamic storage
This patch turns e820 and e820_saved into pointers to e820 tables, of the same size as before.
--- arch/x86/include/asm/e820.h | 6 +- arch/x86/kernel/e820.c | 125 +++++++++++++++++++++++--------------- arch/x86/kernel/early-quirks.c | 2 +- arch/x86/kernel/kexec-bzimage64.c | 4 +- arch/x86/kernel/resource.c | 4 +- arch/x86/kernel/setup.c | 8 +-- arch/x86/kernel/tboot.c | 8 +-- arch/x86/mm/init.c | 2 + arch/x86/platform/efi/efi.c | 2 +- arch/x86/xen/setup.c | 2 +- 10 files changed, 98 insertions(+), 65 deletions(-)
arch/x86/include/asm/e820.h +4 -2
@@ -10,8 +10,8 @@#include <uapi/asm/e820.h> #ifndef __ASSEMBLY__/* see comment in arch/x86/kernel/e820.c */ -extern struct e820map e820; -extern struct e820map e820_saved; +extern struct e820map *e820; +extern struct e820map *e820_saved;extern unsigned long pci_mem_start;extern int e820_any_mapped (u64 start,u64 end,unsigned type);
@@ -53,6 +53,8 @@ extern void e820_reserve_resources_late(void);extern void setup_memory_map (void );extern char *default_machine_specific_memory_setup (void ); +extern void e820_reallocate_tables (void ); +/* * Returns true iff the specified range [s,e) is completely contained inside * the ISA region.
arch/x86/kernel/e820.c +77 -48
294 lines not on this page · raw message
arch/x86/kernel/early-quirks.c +1 -1
@@ -555,7 +555,7 @@ intel_graphics_stolen(int num, int slot, int func,/* Mark this space as reserved */ e820_add_region (base, size,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }static void __init intel_graphics_quirks (int num,int slot,int func)
arch/x86/kernel/kexec-bzimage64.c +2 -2
@@ -99,14 +99,14 @@ static int setup_e820_entries(struct boot_params *params) {unsigned int nr_e820_entries; - nr_e820_entries = e820_saved.nr_map; + nr_e820_entries = e820_saved->nr_map;/* TODO: Pass entries more than E820MAX in bootparams setup data */ if (nr_e820_entries >E820MAX ) nr_e820_entries =E820MAX ; params->e820_entries = nr_e820_entries; -memcpy (¶ms->e820_map, &e820_saved.map, +memcpy (¶ms->e820_map, &e820_saved->map, nr_e820_entries *sizeof (struct e820entry ));return 0 ;
arch/x86/kernel/resource.c +2 -2
@@ -27,8 +27,8 @@ static void remove_e820_regions(struct resource *avail)int i;struct e820entry *entry; -for (i =0 ; i < e820.nr_map; i++) { - entry = &e820.map[i]; +for (i =0 ; i < e820->nr_map; i++) { + entry = &e820->map[i];resource_clip (avail, entry->addr, entry->addr + entry->size -1 );
arch/x86/kernel/setup.c +4 -4
@@ -458,8 +458,8 @@ static void __init e820_reserve_setup_data(void)early_memunmap (data,sizeof (*data)); } -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); -memcpy (&e820_saved, &e820,sizeof (struct e820map )); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); +memcpy (e820_saved, e820,sizeof (struct e820map ));printk (KERN_INFO "extended physical RAM map:\n" );e820_print_map ("reserve setup_data" ); }
@@ -763,7 +763,7 @@ static void __init trim_bios_range(void)*/ e820_remove_range (BIOS_BEGIN ,BIOS_END -BIOS_BEGIN ,E820_RAM ,1 ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }/* called before trim_bios_range() to spare extra sanitize */
@@ -1032,7 +1032,7 @@ void __init setup_arch(char **cmdline_p)if (ppro_with_ram_bug ()) {e820_update_range (0x70000000ULL ,0x40000ULL ,E820_RAM ,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map);printk (KERN_INFO "fixed physical RAM map:\n" );e820_print_map ("bad_ppro" ); }
arch/x86/kernel/tboot.c +4 -4
@@ -188,12 +188,12 @@ static int tboot_setup_sleep(void) tboot->num_mac_regions =0 ; -for (i =0 ; i < e820.nr_map; i++) { -if ((e820.map[i].type !=E820_RAM ) - && (e820.map[i].type !=E820_RESERVED_KERN )) +for (i =0 ; i < e820->nr_map; i++) { +if ((e820->map[i].type !=E820_RAM ) + && (e820->map[i].type !=E820_RESERVED_KERN ))continue ; -add_mac_region (e820.map[i].addr, e820.map[i].size); +add_mac_region (e820->map[i].addr, e820->map[i].size); } tboot->acpi_sinfo.kernel_s3_resume_vector =
arch/x86/mm/init.c +2 -0
@@ -701,6 +701,8 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)void free_initmem (void ) { +/* e820_reallocate_tables(); - disabled for now */ +free_init_pages ("unused kernel" , (unsigned long )(&__init_begin), (unsigned long )(&__init_end));
arch/x86/platform/efi/efi.c +1 -1
@@ -166,7 +166,7 @@ static void __init do_add_efi_memmap(void) }e820_add_region (start, size, e820_type); } -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map); }int __init efi_memblock_x86_reserve_range (void )
arch/x86/xen/setup.c +1 -1
@@ -861,7 +861,7 @@ char * __init xen_memory_setup(void)e820_add_region (ISA_START_ADDRESS ,ISA_END_ADDRESS -ISA_START_ADDRESS ,E820_RESERVED ); -sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +sanitize_e820_map (e820->map,ARRAY_SIZE (e820->map), &e820->nr_map);/* * Check whether the kernel itself conflicts with the target E820 map.
PATCH 3/3 x86/e820: Use much less memory for e820/e820_saved, save up to 120k
In reply to Denys VlasenkoThe maximum size of e820 map array for EFI systems is defined as E820_X_MAX (E820MAX + 3 * MAX_NUMNODES).
In x86_64 defconfig, this ends up with E820_X_MAX = 320, e820 and e820_saved are 6404 bytes each.
With larger configs, for example Fedora kernels, E820_X_MAX = 3200, e820 and e820_saved are 64004 bytes each. Most of this space is wasted. Typical machines have some 20-30 e820 areas at most.
After previous patch, e820 and e820_saved are pointers to e280 maps.
Change them to initially point to maps which are __initdata.
At the very end of kernel init, just before __init[data] sections are freed in free_initmem(), allocate smaller blocks, copy maps there, and change pointers.
The late switch makes sure that all functions which can be used to change e820 maps are no longer accessible (they are all __init functions).
Run-tested.
--- arch/x86/kernel/e820.c | 8 ++++---- arch/x86/mm/init.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/e820.c +4 -4
@@ -40,10 +40,10 @@* user can e.g. boot the original kernel with mem=1G while still booting the * next kernel with full memory. */ -static struct e820map initial_e820; -static struct e820map initial_e820_saved; -struct e820map *e820 = &initial_e820; -struct e820map *e820_saved = &initial_e820_saved; +static struct e820map initial_e820__initdata ; +static struct e820map initial_e820_saved__initdata ; +struct e820map *e820__refdata = &initial_e820; +struct e820map *e820_saved__refdata = &initial_e820_saved;/* For PCI or other memory-mapped resources */ unsigned long pci_mem_start =0xaeedbabe ;
arch/x86/mm/init.c +1 -1
@@ -701,7 +701,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)void free_initmem (void ) { -/* e820_reallocate_tables(); - disabled for now */ +e820_reallocate_tables (); free_init_pages("unused kernel", (unsigned long)(&__init_begin),
Signature · 1 line
2.9.2
kbuild test robot
build botRe: [PATCH 3/3] x86/e820: Use much less memory for e820/e820_saved, save up to 120k
url: https://github.com/0day-ci/linux/commits/Denys-Vlasenko/x86-e820-Mark-some-static-functions-__init/20160918-054310 config: i386-randconfig-i1-09171826 (attached as .config) compiler: gcc-4.8…
Hi Denys,
[auto build test WARNING on tip/auto-latest]
[also build test WARNING on v4.8-rc6 next-20160916]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Denys-Vlasenko/x86-e820-Mark-some-static-functions-__init/20160918-054310
config: i386-randconfig-i1-09171826 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 All warnings (new ones prefixed by >>):
>> WARNING: vmlinux.o(.text+0x37714): Section mismatch in reference from the function free_initmem() to the function .init.text:e820_reallocate_tables()
The function free_initmem() references
the function __init e820_reallocate_tables().
This is often because free_initmem lacks a __init annotation or the annotation of e820_reallocate_tables is wrong.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
tip-bot for Denys Vlasenko
merge botx86/e820: Mark some static functions __init
Commit-ID: 8c2103f224216a45c1a4d7aebbc13f3e007cde34 Gitweb: http://git.kernel.org/tip/8c2103f224216a45c1a4d7aebbc13f3e007cde34 Author: Denys Vlasenko <[email protected]> AuthorDate: Sat, 17 Sep 2016 23:39:25 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 21 Sep 2016 15:02:11 +0200
x86/e820: Mark some static functions __init
They are all called only from other __init functions in e820.c
--- arch/x86/kernel/e820.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/e820.c +6 -6
@@ -802,7 +802,7 @@ unsigned long __init e820_end_of_low_ram_pfn(void)return e820_end_pfn (1UL << (32 -PAGE_SHIFT )); } -static void early_panic (char *msg) +static void __init early_panic (char *msg) {early_printk (msg);panic (msg);
@@ -912,7 +912,7 @@ void __init finish_e820_parsing(void) } } -static const char *e820_type_to_string (int e820_type) +static const char *__init e820_type_to_string (int e820_type) {switch (e820_type) {case E820_RESERVED_KERN :
@@ -926,7 +926,7 @@ static const char *e820_type_to_string(int e820_type) } } -static unsigned long e820_type_to_iomem_type (int e820_type) +static unsigned long __init e820_type_to_iomem_type (int e820_type) {switch (e820_type) {case E820_RESERVED_KERN :
@@ -942,7 +942,7 @@ static unsigned long e820_type_to_iomem_type(int e820_type) } } -static unsigned long e820_type_to_iores_desc (int e820_type) +static unsigned long __init e820_type_to_iores_desc (int e820_type) {switch (e820_type) {case E820_ACPI :
@@ -961,7 +961,7 @@ static unsigned long e820_type_to_iores_desc(int e820_type) } } -static bool do_mark_busy (u32 type,struct resource *res) +static bool __init do_mark_busy (u32 type,struct resource *res) {/* this is the legacy bios/dos rom-shadow + mmio region */ if (res->start < (1ULL <<20 ))
@@ -1027,7 +1027,7 @@ void __init e820_reserve_resources(void) }/* How much should we pad RAM ending depending on where it is? */ -static unsigned long ram_alignment (resource_size_t pos) +static unsigned long __init ram_alignment (resource_size_t pos) {unsigned long mb = pos >>20 ;