aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorBob Liu <lliubbo@gmail.com>2012-12-11 19:00:39 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 20:22:22 -0500
commitfa475e517adb422cb3492e636195f9b2c0d009c8 (patch)
tree832d357b2c403087ee9980742ecc1ad4e546ccb4 /mm
parent6219049ae1ce32b89236646cccaec2a5fc6c4fd2 (diff)
thp: introduce hugepage_vma_check()
Multiple places do the same check. Signed-off-by: Bob Liu <lliubbo@gmail.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: Ni zhan Chen <nizhan.chen@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/huge_memory.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9ae97242aa8d..26002683a16c 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1894,6 +1894,20 @@ static struct page
1894} 1894}
1895#endif 1895#endif
1896 1896
1897static bool hugepage_vma_check(struct vm_area_struct *vma)
1898{
1899 if ((!(vma->vm_flags & VM_HUGEPAGE) && !khugepaged_always()) ||
1900 (vma->vm_flags & VM_NOHUGEPAGE))
1901 return false;
1902
1903 if (!vma->anon_vma || vma->vm_ops)
1904 return false;
1905 if (is_vma_temporary_stack(vma))
1906 return false;
1907 VM_BUG_ON(vma->vm_flags & VM_NO_THP);
1908 return true;
1909}
1910
1897static void collapse_huge_page(struct mm_struct *mm, 1911static void collapse_huge_page(struct mm_struct *mm,
1898 unsigned long address, 1912 unsigned long address,
1899 struct page **hpage, 1913 struct page **hpage,
@@ -1934,17 +1948,8 @@ static void collapse_huge_page(struct mm_struct *mm,
1934 hend = vma->vm_end & HPAGE_PMD_MASK; 1948 hend = vma->vm_end & HPAGE_PMD_MASK;
1935 if (address < hstart || address + HPAGE_PMD_SIZE > hend) 1949 if (address < hstart || address + HPAGE_PMD_SIZE > hend)
1936 goto out; 1950 goto out;
1937 1951 if (!hugepage_vma_check(vma))
1938 if ((!(vma->vm_flags & VM_HUGEPAGE) && !khugepaged_always()) ||
1939 (vma->vm_flags & VM_NOHUGEPAGE))
1940 goto out;
1941
1942 if (!vma->anon_vma || vma->vm_ops)
1943 goto out;
1944 if (is_vma_temporary_stack(vma))
1945 goto out; 1952 goto out;
1946 VM_BUG_ON(vma->vm_flags & VM_NO_THP);
1947
1948 pmd = mm_find_pmd(mm, address); 1953 pmd = mm_find_pmd(mm, address);
1949 if (!pmd) 1954 if (!pmd)
1950 goto out; 1955 goto out;
@@ -2152,20 +2157,11 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
2152 progress++; 2157 progress++;
2153 break; 2158 break;
2154 } 2159 }
2155 2160 if (!hugepage_vma_check(vma)) {
2156 if ((!(vma->vm_flags & VM_HUGEPAGE) && 2161skip:
2157 !khugepaged_always()) ||
2158 (vma->vm_flags & VM_NOHUGEPAGE)) {
2159 skip:
2160 progress++; 2162 progress++;
2161 continue; 2163 continue;
2162 } 2164 }
2163 if (!vma->anon_vma || vma->vm_ops)
2164 goto skip;
2165 if (is_vma_temporary_stack(vma))
2166 goto skip;
2167 VM_BUG_ON(vma->vm_flags & VM_NO_THP);
2168
2169 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; 2165 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
2170 hend = vma->vm_end & HPAGE_PMD_MASK; 2166 hend = vma->vm_end & HPAGE_PMD_MASK;
2171 if (hstart >= hend) 2167 if (hstart >= hend)