aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/memcontrol.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 79a53f0f0cf5..ea5f5edf00b7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2018,10 +2018,9 @@ out:
2018 * < 0 if the cgroup is over its limit 2018 * < 0 if the cgroup is over its limit
2019 */ 2019 */
2020static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, 2020static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
2021 gfp_t gfp_mask, enum charge_type ctype, 2021 gfp_t gfp_mask, enum charge_type ctype)
2022 struct mem_cgroup *memcg)
2023{ 2022{
2024 struct mem_cgroup *mem; 2023 struct mem_cgroup *mem = NULL;
2025 struct page_cgroup *pc; 2024 struct page_cgroup *pc;
2026 int ret; 2025 int ret;
2027 2026
@@ -2031,7 +2030,6 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
2031 return 0; 2030 return 0;
2032 prefetchw(pc); 2031 prefetchw(pc);
2033 2032
2034 mem = memcg;
2035 ret = __mem_cgroup_try_charge(mm, gfp_mask, &mem, true); 2033 ret = __mem_cgroup_try_charge(mm, gfp_mask, &mem, true);
2036 if (ret || !mem) 2034 if (ret || !mem)
2037 return ret; 2035 return ret;
@@ -2059,7 +2057,7 @@ int mem_cgroup_newpage_charge(struct page *page,
2059 if (unlikely(!mm)) 2057 if (unlikely(!mm))
2060 mm = &init_mm; 2058 mm = &init_mm;
2061 return mem_cgroup_charge_common(page, mm, gfp_mask, 2059 return mem_cgroup_charge_common(page, mm, gfp_mask,
2062 MEM_CGROUP_CHARGE_TYPE_MAPPED, NULL); 2060 MEM_CGROUP_CHARGE_TYPE_MAPPED);
2063} 2061}
2064 2062
2065static void 2063static void
@@ -2069,7 +2067,6 @@ __mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *ptr,
2069int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, 2067int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
2070 gfp_t gfp_mask) 2068 gfp_t gfp_mask)
2071{ 2069{
2072 struct mem_cgroup *mem = NULL;
2073 int ret; 2070 int ret;
2074 2071
2075 if (mem_cgroup_disabled()) 2072 if (mem_cgroup_disabled())
@@ -2101,22 +2098,24 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
2101 unlock_page_cgroup(pc); 2098 unlock_page_cgroup(pc);
2102 } 2099 }
2103 2100
2104 if (unlikely(!mm && !mem)) 2101 if (unlikely(!mm))
2105 mm = &init_mm; 2102 mm = &init_mm;
2106 2103
2107 if (page_is_file_cache(page)) 2104 if (page_is_file_cache(page))
2108 return mem_cgroup_charge_common(page, mm, gfp_mask, 2105 return mem_cgroup_charge_common(page, mm, gfp_mask,
2109 MEM_CGROUP_CHARGE_TYPE_CACHE, NULL); 2106 MEM_CGROUP_CHARGE_TYPE_CACHE);
2110 2107
2111 /* shmem */ 2108 /* shmem */
2112 if (PageSwapCache(page)) { 2109 if (PageSwapCache(page)) {
2110 struct mem_cgroup *mem = NULL;
2111
2113 ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &mem); 2112 ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &mem);
2114 if (!ret) 2113 if (!ret)
2115 __mem_cgroup_commit_charge_swapin(page, mem, 2114 __mem_cgroup_commit_charge_swapin(page, mem,
2116 MEM_CGROUP_CHARGE_TYPE_SHMEM); 2115 MEM_CGROUP_CHARGE_TYPE_SHMEM);
2117 } else 2116 } else
2118 ret = mem_cgroup_charge_common(page, mm, gfp_mask, 2117 ret = mem_cgroup_charge_common(page, mm, gfp_mask,
2119 MEM_CGROUP_CHARGE_TYPE_SHMEM, mem); 2118 MEM_CGROUP_CHARGE_TYPE_SHMEM);
2120 2119
2121 return ret; 2120 return ret;
2122} 2121}