From: Kirill A. Shutemov Date: Thu, 29 Nov 2012 03:17:36 +0000 (+1100) Subject: thp: change_huge_pmd(): keep huge zero page write-protected X-Git-Tag: next-20121205~1^2~268 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=276ef5758e80ccaf3242026fe5a2dd0c5c686108;p=karo-tx-linux.git thp: change_huge_pmd(): keep huge zero page write-protected We want to get page fault on write attempt to huge zero page, so let's keep it write-protected. Signed-off-by: Kirill A. Shutemov Cc: Andrea Arcangeli Cc: Andi Kleen Cc: "H. Peter Anvin" Cc: Mel Gorman Cc: David Rientjes Signed-off-by: Andrew Morton --- diff --git a/mm/huge_memory.c b/mm/huge_memory.c index edc1869c532d..12dc04046b9f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1433,6 +1433,8 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, pmd_t entry; entry = pmdp_get_and_clear(mm, addr, pmd); entry = pmd_modify(entry, newprot); + if (is_huge_zero_pmd(entry)) + entry = pmd_wrprotect(entry); set_pmd_at(mm, addr, pmd, entry); spin_unlock(&vma->vm_mm->page_table_lock); ret = 1;