[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1465767282.649122272@decadent.org.uk>
Date: Sun, 12 Jun 2016 22:34:42 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, "Minchan Kim" <minchan.kim@...il.com>,
"Bob Liu" <lliubbo@...il.com>,
"Linus Torvalds" <torvalds@...ux-foundation.org>,
"Ni zhan Chen" <nizhan.chen@...il.com>,
"Michal Hocko" <mhocko@...e.cz>,
"Andrea Arcangeli" <aarcange@...hat.com>
Subject: [PATCH 3.2 32/46] thp: introduce hugepage_vma_check()
3.2.81-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bob Liu <lliubbo@...il.com>
commit fa475e517adb422cb3492e636195f9b2c0d009c8 upstream.
Multiple places do the same check.
Signed-off-by: Bob Liu <lliubbo@...il.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>
Cc: Michal Hocko <mhocko@...e.cz>
Cc: Minchan Kim <minchan.kim@...il.com>
Cc: Ni zhan Chen <nizhan.chen@...il.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
[bwh: Backported to 3.2:
- Also move the is_linear_pfn_mapping() test
- Adjust context]
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
mm/huge_memory.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1817,6 +1817,24 @@ static void __collapse_huge_page_copy(pt
}
}
+static bool hugepage_vma_check(struct vm_area_struct *vma)
+{
+ if ((!(vma->vm_flags & VM_HUGEPAGE) && !khugepaged_always()) ||
+ (vma->vm_flags & VM_NOHUGEPAGE))
+ return false;
+
+ if (!vma->anon_vma || vma->vm_ops)
+ return false;
+ if (is_vma_temporary_stack(vma))
+ return false;
+ /*
+ * If is_pfn_mapping() is true is_learn_pfn_mapping() must be
+ * true too, verify it here.
+ */
+ VM_BUG_ON(is_linear_pfn_mapping(vma) || vma->vm_flags & VM_NO_THP);
+ return true;
+}
+
static void collapse_huge_page(struct mm_struct *mm,
unsigned long address,
struct page **hpage,
@@ -1889,21 +1907,8 @@ static void collapse_huge_page(struct mm
hend = vma->vm_end & HPAGE_PMD_MASK;
if (address < hstart || address + HPAGE_PMD_SIZE > hend)
goto out;
-
- if ((!(vma->vm_flags & VM_HUGEPAGE) && !khugepaged_always()) ||
- (vma->vm_flags & VM_NOHUGEPAGE))
+ if (!hugepage_vma_check(vma))
goto out;
-
- if (!vma->anon_vma || vma->vm_ops)
- goto out;
- if (is_vma_temporary_stack(vma))
- goto out;
- /*
- * If is_pfn_mapping() is true is_learn_pfn_mapping() must be
- * true too, verify it here.
- */
- VM_BUG_ON(is_linear_pfn_mapping(vma) || vma->vm_flags & VM_NO_THP);
-
pgd = pgd_offset(mm, address);
if (!pgd_present(*pgd))
goto out;
@@ -2133,25 +2138,11 @@ static unsigned int khugepaged_scan_mm_s
progress++;
break;
}
-
- if ((!(vma->vm_flags & VM_HUGEPAGE) &&
- !khugepaged_always()) ||
- (vma->vm_flags & VM_NOHUGEPAGE)) {
- skip:
+ if (!hugepage_vma_check(vma)) {
+skip:
progress++;
continue;
}
- if (!vma->anon_vma || vma->vm_ops)
- goto skip;
- if (is_vma_temporary_stack(vma))
- goto skip;
- /*
- * If is_pfn_mapping() is true is_learn_pfn_mapping()
- * must be true too, verify it here.
- */
- VM_BUG_ON(is_linear_pfn_mapping(vma) ||
- vma->vm_flags & VM_NO_THP);
-
hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
hend = vma->vm_end & HPAGE_PMD_MASK;
if (hstart >= hend)
Powered by blists - more mailing lists