aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorHugh Dickins <hugh.dickins@tiscali.co.uk>2009-12-14 20:59:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:19 -0500
commit407f9c8b0889ced1dbe2f9157e4e60c61329d5c9 (patch)
tree30c0c9ad224a73de621bc23909cd89cd81eda1aa /mm
parent80e148226028257ec0a1909d99b2c40d0ffe17f2 (diff)
ksm: mem cgroup charge swapin copy
But ksm swapping does require one small change in mem cgroup handling. When do_swap_page()'s call to ksm_might_need_to_copy() does indeed substitute a duplicate page to accommodate a different anon_vma (or a the !PageSwapCache check in mem_cgroup_try_charge_swapin(). That was returning success without charging, on the assumption that pte_same() would fail after, which is not the case here. Originally I proposed that success, so that an unshrinkable mem cgroup at its limit would not fail unnecessarily; but that's a minor point, and there are plenty of other places where we may fail an overallocation which might later prove unnecessary. So just go ahead and do what all the other exceptions do: proceed to charge current mm. Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Cc: Izik Eidus <ieidus@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Chris Wright <chrisw@redhat.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.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/memcontrol.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c31a310aa146..e0c2066495e3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1737,11 +1737,12 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
1737 goto charge_cur_mm; 1737 goto charge_cur_mm;
1738 /* 1738 /*
1739 * A racing thread's fault, or swapoff, may have already updated 1739 * A racing thread's fault, or swapoff, may have already updated
1740 * the pte, and even removed page from swap cache: return success 1740 * the pte, and even removed page from swap cache: in those cases
1741 * to go on to do_swap_page()'s pte_same() test, which should fail. 1741 * do_swap_page()'s pte_same() test will fail; but there's also a
1742 * KSM case which does need to charge the page.
1742 */ 1743 */
1743 if (!PageSwapCache(page)) 1744 if (!PageSwapCache(page))
1744 return 0; 1745 goto charge_cur_mm;
1745 mem = try_get_mem_cgroup_from_swapcache(page); 1746 mem = try_get_mem_cgroup_from_swapcache(page);
1746 if (!mem) 1747 if (!mem)
1747 goto charge_cur_mm; 1748 goto charge_cur_mm;