diff options
-rw-r--r-- | mm/memcontrol.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1a2020d72ca0..b06833f2b89e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2818,14 +2818,6 @@ static int __mem_cgroup_try_charge_swapin(struct mm_struct *mm, | |||
2818 | return 0; | 2818 | return 0; |
2819 | if (!do_swap_account) | 2819 | if (!do_swap_account) |
2820 | goto charge_cur_mm; | 2820 | goto charge_cur_mm; |
2821 | /* | ||
2822 | * A racing thread's fault, or swapoff, may have already updated | ||
2823 | * the pte, and even removed page from swap cache: in those cases | ||
2824 | * do_swap_page()'s pte_same() test will fail; but there's also a | ||
2825 | * KSM case which does need to charge the page. | ||
2826 | */ | ||
2827 | if (!PageSwapCache(page)) | ||
2828 | goto charge_cur_mm; | ||
2829 | memcg = try_get_mem_cgroup_from_page(page); | 2821 | memcg = try_get_mem_cgroup_from_page(page); |
2830 | if (!memcg) | 2822 | if (!memcg) |
2831 | goto charge_cur_mm; | 2823 | goto charge_cur_mm; |
@@ -2848,6 +2840,20 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm, struct page *page, | |||
2848 | *memcgp = NULL; | 2840 | *memcgp = NULL; |
2849 | if (mem_cgroup_disabled()) | 2841 | if (mem_cgroup_disabled()) |
2850 | return 0; | 2842 | return 0; |
2843 | /* | ||
2844 | * A racing thread's fault, or swapoff, may have already | ||
2845 | * updated the pte, and even removed page from swap cache: in | ||
2846 | * those cases unuse_pte()'s pte_same() test will fail; but | ||
2847 | * there's also a KSM case which does need to charge the page. | ||
2848 | */ | ||
2849 | if (!PageSwapCache(page)) { | ||
2850 | int ret; | ||
2851 | |||
2852 | ret = __mem_cgroup_try_charge(mm, gfp_mask, 1, memcgp, true); | ||
2853 | if (ret == -EINTR) | ||
2854 | ret = 0; | ||
2855 | return ret; | ||
2856 | } | ||
2851 | return __mem_cgroup_try_charge_swapin(mm, page, gfp_mask, memcgp); | 2857 | return __mem_cgroup_try_charge_swapin(mm, page, gfp_mask, memcgp); |
2852 | } | 2858 | } |
2853 | 2859 | ||