linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check
@ 2016-04-02 15:37 Konstantin Khlebnikov
  2016-04-02 22:05 ` Kirill A. Shutemov
  2016-04-04 12:36 ` Vlastimil Babka
  0 siblings, 2 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2016-04-02 15:37 UTC (permalink / raw)
  To: linux-mm, Andrew Morton
  Cc: Dmitry Vyukov, Andrea Arcangeli, linux-kernel, stable

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.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
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")
Cc: stable <stable@vger.kernel.org>
---
 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 86f9f8b82f8e..93de199ba0f1 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1960,10 +1960,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)
@@ -2352,8 +2351,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,

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check
  2016-04-02 15:37 [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check Konstantin Khlebnikov
@ 2016-04-02 22:05 ` Kirill A. Shutemov
  2016-04-04 12:36 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2016-04-02 22:05 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: linux-mm, Andrew Morton, Dmitry Vyukov, Andrea Arcangeli,
	linux-kernel, stable

On Sat, Apr 02, 2016 at 06:37:44PM +0300, Konstantin Khlebnikov wrote:
> 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.
> 
> Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> 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")
> Cc: stable <stable@vger.kernel.org>

Looks good to me.

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check
  2016-04-02 15:37 [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check Konstantin Khlebnikov
  2016-04-02 22:05 ` Kirill A. Shutemov
@ 2016-04-04 12:36 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2016-04-04 12:36 UTC (permalink / raw)
  To: Konstantin Khlebnikov, linux-mm, Andrew Morton
  Cc: Dmitry Vyukov, Andrea Arcangeli, linux-kernel, stable

On 04/02/2016 05:37 PM, Konstantin Khlebnikov wrote:
> 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.
>
> Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> 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")
> Cc: stable <stable@vger.kernel.org>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-04 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-02 15:37 [PATCH] mm/huge_memory: replace VM_NO_THP VM_BUG_ON with actual VMA check Konstantin Khlebnikov
2016-04-02 22:05 ` Kirill A. Shutemov
2016-04-04 12:36 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).