Skip to content

Commit e181ae0

Browse files
Pavel Tatashintorvalds
authored andcommitted
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 124049d ("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: 124049d ("x86/e820: put !E820_TYPE_RAM regions into memblock.reserved") Signed-off-by: Pavel Tatashin <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2db39a2 commit e181ae0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/page_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6847,6 +6847,7 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
68476847
/* Initialise every node */
68486848
mminit_verify_pageflags_layout();
68496849
setup_nr_node_ids();
6850+
zero_resv_unavail();
68506851
for_each_online_node(nid) {
68516852
pg_data_t *pgdat = NODE_DATA(nid);
68526853
free_area_init_node(nid, NULL,
@@ -6857,7 +6858,6 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
68576858
node_set_state(nid, N_MEMORY);
68586859
check_for_memory(pgdat, nid);
68596860
}
6860-
zero_resv_unavail();
68616861
}
68626862

68636863
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)
70337033

70347034
void __init free_area_init(unsigned long *zones_size)
70357035
{
7036+
zero_resv_unavail();
70367037
free_area_init_node(0, zones_size,
70377038
__pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
7038-
zero_resv_unavail();
70397039
}
70407040

70417041
static int page_alloc_cpu_dead(unsigned int cpu)

0 commit comments

Comments
 (0)