[4.2.y-ckt stable] Patch "mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check" has been added to the 4.2.y-ckt tree

Kamal Mostafa kamal at canonical.com
Mon May 9 19:43:52 UTC 2016


This is a note to let you know that I have just added a patch titled

    mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check

to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree 
which can be found at:

    https://git.launchpad.net/~canonical-kernel/linux/+git/linux-stable-ckt/log/?h=linux-4.2.y-queue

This patch is scheduled to be released in version 4.2.8-ckt10.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

>From 82425856cc479d77c39dcb2428207706d2dca29d Mon Sep 17 00:00:00 2001
From: Konstantin Khlebnikov <koct9i at gmail.com>
Date: Thu, 28 Apr 2016 16:18:32 -0700
Subject: mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check

commit 3486b85a29c1741db99d0c522211c82d2b7a56d0 upstream.

Khugepaged detects own VMAs by checking vm_file and vm_ops but this way
it cannot distinguish private /dev/zero mappings from other special
mappings like /dev/hpet which has no vm_ops and popultes PTEs in mmap.

This fixes false-positive VM_BUG_ON and prevents installing THP where
they are not expected.

Link: http://lkml.kernel.org/r/CACT4Y+ZmuZMV5CjSFOeXviwQdABAgT7T+StKfTqan9YDtgEi5g@mail.gmail.com
Fixes: 78f11a255749 ("mm: thp: fix /dev/zero MAP_PRIVATE and vm_flags cleanups")
Signed-off-by: Konstantin Khlebnikov <koct9i at gmail.com>
Reported-by: Dmitry Vyukov <dvyukov at google.com>
Acked-by: Vlastimil Babka <vbabka at suse.cz>
Acked-by: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Cc: Dmitry Vyukov <dvyukov at google.com>
Cc: Andrea Arcangeli <aarcange at redhat.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 mm/huge_memory.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index da0ac6a..749b929 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2061,10 +2061,9 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
 		 * page fault if needed.
 		 */
 		return 0;
-	if (vma->vm_ops)
+	if (vma->vm_ops || (vm_flags & VM_NO_THP))
 		/* khugepaged not yet working on file or special mappings */
 		return 0;
-	VM_BUG_ON_VMA(vm_flags & VM_NO_THP, vma);
 	hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
 	hend = vma->vm_end & HPAGE_PMD_MASK;
 	if (hstart < hend)
@@ -2421,8 +2420,7 @@ static bool hugepage_vma_check(struct vm_area_struct *vma)
 		return false;
 	if (is_vma_temporary_stack(vma))
 		return false;
-	VM_BUG_ON_VMA(vma->vm_flags & VM_NO_THP, vma);
-	return true;
+	return !(vma->vm_flags & VM_NO_THP);
 }

 static void collapse_huge_page(struct mm_struct *mm,
--
2.7.4





More information about the kernel-team mailing list