Commit e181ae0c authored by Pavel Tatashin's avatar Pavel Tatashin Committed by Linus Torvalds

mm: zero unavailable pages before memmap init

We must zero struct pages for memory that is not backed by physical
memory, or kernel does not have access to.

Recently, there was a change which zeroed all memmap for all holes in
e820.  Unfortunately, it introduced a bug that is discussed here:

  https://www.spinics.net/lists/linux-mm/msg156764.html

Linus, also saw this bug on his machine, and confirmed that reverting
commit 124049de ("x86/e820: put !E820_TYPE_RAM regions into
memblock.reserved") fixes the issue.

The problem is that we incorrectly zero some struct pages after they
were setup.

The fix is to zero unavailable struct pages prior to initializing of
struct pages.

A more detailed fix should come later that would avoid double zeroing
cases: one in __init_single_page(), the other one in
zero_resv_unavail().

Fixes: 124049de ("x86/e820: put !E820_TYPE_RAM regions into memblock.reserved")
Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2db39a2f
...@@ -6847,6 +6847,7 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn) ...@@ -6847,6 +6847,7 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
/* Initialise every node */ /* Initialise every node */
mminit_verify_pageflags_layout(); mminit_verify_pageflags_layout();
setup_nr_node_ids(); setup_nr_node_ids();
zero_resv_unavail();
for_each_online_node(nid) { for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid); pg_data_t *pgdat = NODE_DATA(nid);
free_area_init_node(nid, NULL, free_area_init_node(nid, NULL,
...@@ -6857,7 +6858,6 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn) ...@@ -6857,7 +6858,6 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
node_set_state(nid, N_MEMORY); node_set_state(nid, N_MEMORY);
check_for_memory(pgdat, nid); check_for_memory(pgdat, nid);
} }
zero_resv_unavail();
} }
static int __init cmdline_parse_core(char *p, unsigned long *core, static int __init cmdline_parse_core(char *p, unsigned long *core,
...@@ -7033,9 +7033,9 @@ void __init set_dma_reserve(unsigned long new_dma_reserve) ...@@ -7033,9 +7033,9 @@ void __init set_dma_reserve(unsigned long new_dma_reserve)
void __init free_area_init(unsigned long *zones_size) void __init free_area_init(unsigned long *zones_size)
{ {
zero_resv_unavail();
free_area_init_node(0, zones_size, free_area_init_node(0, zones_size,
__pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL); __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
zero_resv_unavail();
} }
static int page_alloc_cpu_dead(unsigned int cpu) static int page_alloc_cpu_dead(unsigned int cpu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment