aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorDave Hansen <dave@linux.vnet.ibm.com>2011-03-22 19:32:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:04 -0400
commit033193275b3ffcfe7f3fde7b569f3d207f6cd6a0 (patch)
treefc65fa02248f855f0f63e087f35a507b6abb5617 /mm/memcontrol.c
parent278df9f451dc71dcd002246be48358a473504ad0 (diff)
pagewalk: only split huge pages when necessary
Right now, if a mm_walk has either ->pte_entry or ->pmd_entry set, it will unconditionally split any transparent huge pages it runs in to. In practice, that means that anyone doing a cat /proc/$pid/smaps will unconditionally break down every huge page in the process and depend on khugepaged to re-collapse it later. This is fairly suboptimal. This patch changes that behavior. It teaches each ->pmd_entry handler (there are five) that they must break down the THPs themselves. Also, the _generic_ code will never break down a THP unless a ->pte_entry handler is actually set. This means that the ->pmd_entry handlers can now choose to deal with THPs without breaking them down. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Acked-by: David Rientjes <rientjes@google.com> Reviewed-by: Eric B Munson <emunson@mgebm.net> Tested-by: Eric B Munson <emunson@mgebm.net> Cc: Michael J Wolf <mjwolf@us.ibm.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Matt Mackall <mpm@selenic.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9e0f05efd114..e1ee6ad9c971 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4763,7 +4763,8 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
4763 pte_t *pte; 4763 pte_t *pte;
4764 spinlock_t *ptl; 4764 spinlock_t *ptl;
4765 4765
4766 VM_BUG_ON(pmd_trans_huge(*pmd)); 4766 split_huge_page_pmd(walk->mm, pmd);
4767
4767 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 4768 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
4768 for (; addr != end; pte++, addr += PAGE_SIZE) 4769 for (; addr != end; pte++, addr += PAGE_SIZE)
4769 if (is_target_pte_for_mc(vma, addr, *pte, NULL)) 4770 if (is_target_pte_for_mc(vma, addr, *pte, NULL))
@@ -4925,8 +4926,8 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
4925 pte_t *pte; 4926 pte_t *pte;
4926 spinlock_t *ptl; 4927 spinlock_t *ptl;
4927 4928
4929 split_huge_page_pmd(walk->mm, pmd);
4928retry: 4930retry:
4929 VM_BUG_ON(pmd_trans_huge(*pmd));
4930 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 4931 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
4931 for (; addr != end; addr += PAGE_SIZE) { 4932 for (; addr != end; addr += PAGE_SIZE) {
4932 pte_t ptent = *(pte++); 4933 pte_t ptent = *(pte++);