Skip to contentSkip to conversation

x86/mm/hotplug: fix BUG_ON() after hotremove

PATCH In review Jérôme Glisse 3 participants 4 messages Jun 6, 2017 – Jun 7, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm/hotplug: fix BUG_ON() after hotremove

With commit af2cf278ef4f we no longer free pud so that we do not have synchronize all pgd on hotremove/vfree. But the new 5 level page table code re-added that code f2a6a705 and thus we now trigger a BUG_ON() l128 in sync_global_pgds()

This patch remove free_pud() like in af2cf278ef4f

Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Logan Gunthorpe <[email protected]>
---
 arch/x86/mm/init_64.c | 19 -------------------
 1 file changed, 19 deletions(-)
arch/x86/mm/init_64.c +0 -19
index a8a9972..8cf7e99 100644
@@ -772,24 +772,6 @@ static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
 	spin_unlock(&init_mm.page_table_lock);
 }
 
-static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d)
-{
-	pud_t *pud;
-	int i;
-
-	for (i = 0; i < PTRS_PER_PUD; i++) {
-		pud = pud_start + i;
-		if (!pud_none(*pud))
-			return;
-	}
-
-	/* free a pud talbe */
-	free_pagetable(p4d_page(*p4d), 0);
-	spin_lock(&init_mm.page_table_lock);
-	p4d_clear(p4d);
-	spin_unlock(&init_mm.page_table_lock);
-}
-
 static void __meminit
 remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end,
 		 bool direct)
@@ -991,7 +973,6 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end,
 
 		pud_base = pud_offset(p4d, 0);
 		remove_pud_table(pud_base, addr, next, direct);
-		free_pud_table(pud_base, p4d);
 	}
 
 	if (direct)
Signature · 7 lines
2.9.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Tested-by on v1 1/1
#1 lore raw

Thanks Jerome! This indeed fixes the bug I reported.

Logan

Quoted 47 lines · JA(C)rA'me Glisse

With commit af2cf278ef4f we no longer free pud so that we do not have synchronize all pgd on hotremove/vfree. But the new 5 level page table code re-added that code f2a6a705 and thus we now trigger a BUG_ON() l128 in sync_global_pgds()

This patch remove free_pud() like in af2cf278ef4f

Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Logan Gunthorpe <[email protected]>
---
 arch/x86/mm/init_64.c | 19 -------------------
 1 file changed, 19 deletions(-)
arch/x86/mm/init_64.c +0 -18
index a8a9972..8cf7e99 100644
@@ -772,24 +772,6 @@ static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
 	spin_unlock(&init_mm.page_table_lock);
 }
 
-static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d)
-{
-	pud_t *pud;
-	int i;
-
-	for (i = 0; i < PTRS_PER_PUD; i++) {
-		pud = pud_start + i;
-		if (!pud_none(*pud))
-			return;
-	}
-
-	/* free a pud talbe */
-	free_pagetable(p4d_page(*p4d), 0);
-	spin_lock(&init_mm.page_table_lock);
-	p4d_clear(p4d);
-	spin_unlock(&init_mm.page_table_lock);
-}
-
 static void __meminit
 remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end,
 		 bool direct)

arch/x86/mm/init_64.c remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end, · line 978

Quoted 7 lines
arch/x86/mm/init_64.c +0 -1
@@ -991,7 +973,6 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end,
 
 		pud_base = pud_offset(p4d, 0);
 		remove_pud_table(pud_base, addr, next, direct);
-		free_pud_table(pud_base, p4d);
 	}
 
 	if (direct)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
In reply to Jérôme Glisse
Quoted 6 lines · Jerome Glisse

With commit af2cf278ef4f we no longer free pud so that we do not have synchronize all pgd on hotremove/vfree. But the new 5 level page table code re-added that code f2a6a705 and thus we now trigger a BUG_ON() l128 in sync_global_pgds()

This patch remove free_pud() like in af2cf278ef4f

Good catch. Thanks!

But I think we only need to skip free_pud_table() for 4-level paging. If we don't we would leave 513 page tables around instead of one in 5-level paging case.

I don't think it's acceptable.

And please use patch subject lines along with commit hashes to simplify reading commit message.

Signature · 7 lines
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 10 lines · Kirill A. Shutemov
Quoted 6 lines · Jerome Glisse

With commit af2cf278ef4f we no longer free pud so that we do not have synchronize all pgd on hotremove/vfree. But the new 5 level page table code re-added that code f2a6a705 and thus we now trigger a BUG_ON() l128 in sync_global_pgds()

This patch remove free_pud() like in af2cf278ef4f

Good catch. Thanks!

Quoted 9 lines

But I think we only need to skip free_pud_table() for 4-level paging. If we don't we would leave 513 page tables around instead of one in 5-level paging case.

I don't think it's acceptable.

And please use patch subject lines along with commit hashes to simplify reading commit message.

I sent a v2 that disable free_pud in 4 level page table config. Note that your patchset that allow switching between 4 and 5 at boot time will need to update that code. As this patch is a fix and your boot time switching is an RFC i assume the fix will go in first.

Cheers,
Jerome

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>