diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8f9381976c59..09a450684f70 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2031,21 +2031,17 @@ bypass: | |||
2031 | * gotten by try_charge(). | 2031 | * gotten by try_charge(). |
2032 | */ | 2032 | */ |
2033 | static void __mem_cgroup_cancel_charge(struct mem_cgroup *mem, | 2033 | static void __mem_cgroup_cancel_charge(struct mem_cgroup *mem, |
2034 | unsigned long count) | 2034 | unsigned int nr_pages) |
2035 | { | 2035 | { |
2036 | if (!mem_cgroup_is_root(mem)) { | 2036 | if (!mem_cgroup_is_root(mem)) { |
2037 | res_counter_uncharge(&mem->res, PAGE_SIZE * count); | 2037 | unsigned long bytes = nr_pages * PAGE_SIZE; |
2038 | |||
2039 | res_counter_uncharge(&mem->res, bytes); | ||
2038 | if (do_swap_account) | 2040 | if (do_swap_account) |
2039 | res_counter_uncharge(&mem->memsw, PAGE_SIZE * count); | 2041 | res_counter_uncharge(&mem->memsw, bytes); |
2040 | } | 2042 | } |
2041 | } | 2043 | } |
2042 | 2044 | ||
2043 | static void mem_cgroup_cancel_charge(struct mem_cgroup *mem, | ||
2044 | int page_size) | ||
2045 | { | ||
2046 | __mem_cgroup_cancel_charge(mem, page_size >> PAGE_SHIFT); | ||
2047 | } | ||
2048 | |||
2049 | /* | 2045 | /* |
2050 | * A helper function to get mem_cgroup from ID. must be called under | 2046 | * A helper function to get mem_cgroup from ID. must be called under |
2051 | * rcu_read_lock(). The caller must check css_is_removed() or some if | 2047 | * rcu_read_lock(). The caller must check css_is_removed() or some if |
@@ -2104,7 +2100,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem, | |||
2104 | lock_page_cgroup(pc); | 2100 | lock_page_cgroup(pc); |
2105 | if (unlikely(PageCgroupUsed(pc))) { | 2101 | if (unlikely(PageCgroupUsed(pc))) { |
2106 | unlock_page_cgroup(pc); | 2102 | unlock_page_cgroup(pc); |
2107 | mem_cgroup_cancel_charge(mem, page_size); | 2103 | __mem_cgroup_cancel_charge(mem, nr_pages); |
2108 | return; | 2104 | return; |
2109 | } | 2105 | } |
2110 | /* | 2106 | /* |
@@ -2242,7 +2238,7 @@ static int mem_cgroup_move_account(struct page *page, struct page_cgroup *pc, | |||
2242 | mem_cgroup_charge_statistics(from, PageCgroupCache(pc), -nr_pages); | 2238 | mem_cgroup_charge_statistics(from, PageCgroupCache(pc), -nr_pages); |
2243 | if (uncharge) | 2239 | if (uncharge) |
2244 | /* This is not "cancel", but cancel_charge does all we need. */ | 2240 | /* This is not "cancel", but cancel_charge does all we need. */ |
2245 | mem_cgroup_cancel_charge(from, charge_size); | 2241 | __mem_cgroup_cancel_charge(from, nr_pages); |
2246 | 2242 | ||
2247 | /* caller should have done css_get */ | 2243 | /* caller should have done css_get */ |
2248 | pc->mem_cgroup = to; | 2244 | pc->mem_cgroup = to; |
@@ -2307,7 +2303,7 @@ static int mem_cgroup_move_parent(struct page *page, | |||
2307 | 2303 | ||
2308 | ret = mem_cgroup_move_account(page, pc, child, parent, true, page_size); | 2304 | ret = mem_cgroup_move_account(page, pc, child, parent, true, page_size); |
2309 | if (ret) | 2305 | if (ret) |
2310 | mem_cgroup_cancel_charge(parent, page_size); | 2306 | __mem_cgroup_cancel_charge(parent, page_size >> PAGE_SHIFT); |
2311 | 2307 | ||
2312 | if (page_size > PAGE_SIZE) | 2308 | if (page_size > PAGE_SIZE) |
2313 | compound_unlock_irqrestore(page, flags); | 2309 | compound_unlock_irqrestore(page, flags); |
@@ -2538,7 +2534,7 @@ void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *mem) | |||
2538 | return; | 2534 | return; |
2539 | if (!mem) | 2535 | if (!mem) |
2540 | return; | 2536 | return; |
2541 | mem_cgroup_cancel_charge(mem, PAGE_SIZE); | 2537 | __mem_cgroup_cancel_charge(mem, 1); |
2542 | } | 2538 | } |
2543 | 2539 | ||
2544 | static void | 2540 | static void |