Skip to content

Commit 39d35ed

Browse files
Muchun Songakpm00
authored andcommitted
mm: sparsemem: fix missing higher order allocation splitting
Higher order allocations for vmemmap pages from buddy allocator must be able to be treated as indepdenent small pages as they can be freed individually by the caller. There is no problem for higher order vmemmap pages allocated at boot time since each individual small page will be initialized at boot time. However, it will be an issue for memory hotplug case since those higher order vmemmap pages are allocated from buddy allocator without initializing each individual small page's refcount. The system will panic in put_page_testzero() when CONFIG_DEBUG_VM is enabled if the vmemmap page is freed. Link: https://lkml.kernel.org/r/[email protected] Fixes: d8d55f5 ("mm: sparsemem: use page table lock to protect kernel pmd operations") Signed-off-by: Muchun Song <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: Xiongchun Duan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ed1523a commit 39d35ed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mm/sparse-vmemmap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ static int __split_vmemmap_huge_pmd(pmd_t *pmd, unsigned long start)
7878

7979
spin_lock(&init_mm.page_table_lock);
8080
if (likely(pmd_leaf(*pmd))) {
81+
/*
82+
* Higher order allocations from buddy allocator must be able to
83+
* be treated as indepdenent small pages (as they can be freed
84+
* individually).
85+
*/
86+
if (!PageReserved(page))
87+
split_page(page, get_order(PMD_SIZE));
88+
8189
/* Make pte visible before pmd. See comment in pmd_install(). */
8290
smp_wmb();
8391
pmd_populate_kernel(&init_mm, pmd, pgtable);

0 commit comments

Comments
 (0)