Skip to content

Commit a4f1de1

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: fix kernel BUG at huge_memory.c:1474!
Andrea's autonuma-benchmark numa01 hits kernel BUG at huge_memory.c:1474! in change_huge_pmd called from change_protection from change_prot_numa from task_numa_work. That BUG, introduced in the huge zero page commit cad7f61 ("thp: change_huge_pmd(): make sure we don't try to make a page writable") was trying to verify that newprot never adds write permission to an anonymous huge page; but Automatic NUMA Balancing's 4b10e7d ("mm: mempolicy: Implement change_prot_numa() in terms of change_protection()") adds a new prot_numa path into change_huge_pmd(), which makes no use of the newprot provided, and may retain the write bit in the pmd. Just move the BUG_ON(pmd_write(entry)) up into the !prot_numa block. Signed-off-by: Hugh Dickins <hughd@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2dfea38 commit a4f1de1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/huge_memory.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,10 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
14601460
if (__pmd_trans_huge_lock(pmd, vma) == 1) {
14611461
pmd_t entry;
14621462
entry = pmdp_get_and_clear(mm, addr, pmd);
1463-
if (!prot_numa)
1463+
if (!prot_numa) {
14641464
entry = pmd_modify(entry, newprot);
1465-
else {
1465+
BUG_ON(pmd_write(entry));
1466+
} else {
14661467
struct page *page = pmd_page(*pmd);
14671468

14681469
/* only check non-shared pages */
@@ -1471,7 +1472,6 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
14711472
entry = pmd_mknuma(entry);
14721473
}
14731474
}
1474-
BUG_ON(pmd_write(entry));
14751475
set_pmd_at(mm, addr, pmd, entry);
14761476
spin_unlock(&vma->vm_mm->page_table_lock);
14771477
ret = 1;

0 commit comments

Comments
 (0)