diff options
author | Dave Hansen <dave@linux.vnet.ibm.com> | 2011-03-22 19:32:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:04 -0400 |
commit | 033193275b3ffcfe7f3fde7b569f3d207f6cd6a0 (patch) | |
tree | fc65fa02248f855f0f63e087f35a507b6abb5617 /fs | |
parent | 278df9f451dc71dcd002246be48358a473504ad0 (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 'fs')
-rw-r--r-- | fs/proc/task_mmu.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 60b914860f8..78fd3621f56 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -343,6 +343,8 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
343 | struct page *page; | 343 | struct page *page; |
344 | int mapcount; | 344 | int mapcount; |
345 | 345 | ||
346 | split_huge_page_pmd(walk->mm, pmd); | ||
347 | |||
346 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | 348 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); |
347 | for (; addr != end; pte++, addr += PAGE_SIZE) { | 349 | for (; addr != end; pte++, addr += PAGE_SIZE) { |
348 | ptent = *pte; | 350 | ptent = *pte; |
@@ -467,6 +469,8 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, | |||
467 | spinlock_t *ptl; | 469 | spinlock_t *ptl; |
468 | struct page *page; | 470 | struct page *page; |
469 | 471 | ||
472 | split_huge_page_pmd(walk->mm, pmd); | ||
473 | |||
470 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | 474 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); |
471 | for (; addr != end; pte++, addr += PAGE_SIZE) { | 475 | for (; addr != end; pte++, addr += PAGE_SIZE) { |
472 | ptent = *pte; | 476 | ptent = *pte; |
@@ -623,6 +627,8 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
623 | pte_t *pte; | 627 | pte_t *pte; |
624 | int err = 0; | 628 | int err = 0; |
625 | 629 | ||
630 | split_huge_page_pmd(walk->mm, pmd); | ||
631 | |||
626 | /* find the first VMA at or above 'addr' */ | 632 | /* find the first VMA at or above 'addr' */ |
627 | vma = find_vma(walk->mm, addr); | 633 | vma = find_vma(walk->mm, addr); |
628 | for (; addr != end; addr += PAGE_SIZE) { | 634 | for (; addr != end; addr += PAGE_SIZE) { |