Skip to contentSkip to conversation

Patch "mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check" has been added to the 4.5-stable tree

PATCH [email protected] 1 participant 1 message May 2, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check

to the 4.5-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mm-huge_memory-replace-vm_no_thp-vm_bug_on-with-actual-vma-check.patch
and it can be found in the queue-4.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 3486b85a29c1741db99d0c522211c82d2b7a56d0 Mon Sep 17 00:00:00 2001

From: Konstantin Khlebnikov <[email protected]>
Date: Thu, 28 Apr 2016 16:18:32 -0700
Subject: mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check

From: Konstantin Khlebnikov <[email protected]>

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.

---
 mm/huge_memory.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
mm/huge_memory.c +2 -4
@@ -1919,10 +1919,9 @@ int khugepaged_enter_vma_merge(struct vm
 		 * 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)
@@ -2310,8 +2309,7 @@ static bool hugepage_vma_check(struct vm
 		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,

Patches currently in stable-queue which might be from [email protected] are

queue-4.5/numa-fix-proc-pid-numa_maps-for-thp.patch queue-4.5/mm-huge_memory-replace-vm_no_thp-vm_bug_on-with-actual-vma-check.patch