memcg: keep only one charge cancelling function
We have two charge cancelling functions: one takes a page count, the other a page size. The second one just divides the parameter by PAGE_SIZE and then calls the first one. This is trivial, no need for an extra function. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: 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>
This commit is contained in:
parent
bf1ff2635a
commit
e7018b8d27
|
@ -2031,19 +2031,15 @@ bypass:
|
||||||
* gotten by try_charge().
|
* gotten by try_charge().
|
||||||
*/
|
*/
|
||||||
static void __mem_cgroup_cancel_charge(struct mem_cgroup *mem,
|
static void __mem_cgroup_cancel_charge(struct mem_cgroup *mem,
|
||||||
unsigned long count)
|
unsigned int nr_pages)
|
||||||
{
|
{
|
||||||
if (!mem_cgroup_is_root(mem)) {
|
if (!mem_cgroup_is_root(mem)) {
|
||||||
res_counter_uncharge(&mem->res, PAGE_SIZE * count);
|
unsigned long bytes = nr_pages * PAGE_SIZE;
|
||||||
if (do_swap_account)
|
|
||||||
res_counter_uncharge(&mem->memsw, PAGE_SIZE * count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mem_cgroup_cancel_charge(struct mem_cgroup *mem,
|
res_counter_uncharge(&mem->res, bytes);
|
||||||
int page_size)
|
if (do_swap_account)
|
||||||
{
|
res_counter_uncharge(&mem->memsw, bytes);
|
||||||
__mem_cgroup_cancel_charge(mem, page_size >> PAGE_SHIFT);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2104,7 +2100,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem,
|
||||||
lock_page_cgroup(pc);
|
lock_page_cgroup(pc);
|
||||||
if (unlikely(PageCgroupUsed(pc))) {
|
if (unlikely(PageCgroupUsed(pc))) {
|
||||||
unlock_page_cgroup(pc);
|
unlock_page_cgroup(pc);
|
||||||
mem_cgroup_cancel_charge(mem, page_size);
|
__mem_cgroup_cancel_charge(mem, nr_pages);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -2242,7 +2238,7 @@ static int mem_cgroup_move_account(struct page *page, struct page_cgroup *pc,
|
||||||
mem_cgroup_charge_statistics(from, PageCgroupCache(pc), -nr_pages);
|
mem_cgroup_charge_statistics(from, PageCgroupCache(pc), -nr_pages);
|
||||||
if (uncharge)
|
if (uncharge)
|
||||||
/* This is not "cancel", but cancel_charge does all we need. */
|
/* This is not "cancel", but cancel_charge does all we need. */
|
||||||
mem_cgroup_cancel_charge(from, charge_size);
|
__mem_cgroup_cancel_charge(from, nr_pages);
|
||||||
|
|
||||||
/* caller should have done css_get */
|
/* caller should have done css_get */
|
||||||
pc->mem_cgroup = to;
|
pc->mem_cgroup = to;
|
||||||
|
@ -2307,7 +2303,7 @@ static int mem_cgroup_move_parent(struct page *page,
|
||||||
|
|
||||||
ret = mem_cgroup_move_account(page, pc, child, parent, true, page_size);
|
ret = mem_cgroup_move_account(page, pc, child, parent, true, page_size);
|
||||||
if (ret)
|
if (ret)
|
||||||
mem_cgroup_cancel_charge(parent, page_size);
|
__mem_cgroup_cancel_charge(parent, page_size >> PAGE_SHIFT);
|
||||||
|
|
||||||
if (page_size > PAGE_SIZE)
|
if (page_size > PAGE_SIZE)
|
||||||
compound_unlock_irqrestore(page, flags);
|
compound_unlock_irqrestore(page, flags);
|
||||||
|
@ -2538,7 +2534,7 @@ void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *mem)
|
||||||
return;
|
return;
|
||||||
if (!mem)
|
if (!mem)
|
||||||
return;
|
return;
|
||||||
mem_cgroup_cancel_charge(mem, PAGE_SIZE);
|
__mem_cgroup_cancel_charge(mem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Reference in New Issue