x86/e820: mark some static functions __init
Subsystems (5)
PATCH 1/2 x86/e820: mark some static functions __init
They are all called only from other __init functions.
--- 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/2 x86/e820: Use much less memory for e820/e820_saved, save up to 120k
The 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.
This patch turns e820 and e820_saved to pointers which initially point to __initdata tables, of the same size as before.
At the very end of setup_arch(), when we are done fiddling with these maps, allocate smaller alloc_bootmem blocks, copy maps there, and change pointers.
Run-tested.
--- arch/x86/include/asm/e820.h | 6 +- arch/x86/kernel/e820.c | 123 +++++++++++++++++++++++--------------- 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 | 10 ++-- arch/x86/kernel/tboot.c | 8 +-- arch/x86/platform/efi/efi.c | 2 +- arch/x86/xen/setup.c | 2 +- 9 files changed, 96 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 +75 -48
292 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 +6 -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" ); }
@@ -1262,6 +1262,8 @@ void __init setup_arch(char **cmdline_p)if (efi_enabled (EFI_BOOT ))efi_apply_memmap_quirks ();#endif + +e820_reallocate_tables (); }#ifdef CONFIG_X86_32
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/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
kbuild test robot
build botRe: [PATCH 2/2] 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/20160909-035802 config: x86_64-randconfig-i0-201636 (attached as .config) compiler: gcc-4.9…
Hi Denys,
[auto build test WARNING on tip/auto-latest]
[also build test WARNING on v4.8-rc5 next-20160908]
[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/20160909-035802
config: x86_64-randconfig-i0-201636 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.3-14) 4.9.3 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All warnings (new ones prefixed by >>):
>> WARNING: vmlinux.o(.data+0x1b398): Section mismatch in reference from the variable e820_saved to the variable .init.data:initial_e820_saved
The variable e820_saved references
the variable __initdata initial_e820_saved
If the reference is valid then annotate the
variable with or __refdata (see linux/init.h) or name the variable:
--
>> WARNING: vmlinux.o(.data+0x1b3a0): Section mismatch in reference from the variable e820 to the variable .init.data:initial_e820
The variable e820 references
the variable __initdata initial_e820
If the reference is valid then annotate the
variable with or __refdata (see linux/init.h) or name the variable:
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation