Subject: memcontrol: try charging huge pages from stock From: Johannes Weiner The stock unit is just bytes, there is no reason to only take normal pages from it. Signed-off-by: Johannes Weiner Signed-off-by: Andrea Arcangeli --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fdc7e1a..41a8cbd 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1469,19 +1469,19 @@ static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); static atomic_t memcg_drain_count; /* - * Try to consume stocked charge on this cpu. If success, PAGE_SIZE is consumed + * Try to consume stocked charge on this cpu. If success, @val is consumed * from local stock and true is returned. If the stock is 0 or charges from a * cgroup which is not current target, returns false. This stock will be * refilled. */ -static bool consume_stock(struct mem_cgroup *mem) +static bool consume_stock(struct mem_cgroup *mem, int val) { struct memcg_stock_pcp *stock; bool ret = true; stock = &get_cpu_var(memcg_stock); - if (mem == stock->cached && stock->charge) - stock->charge -= PAGE_SIZE; + if (mem == stock->cached && stock->charge >= val) + stock->charge -= val; else /* need to call res_counter_charge */ ret = false; put_cpu_var(memcg_stock); @@ -1629,9 +1629,8 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, int ret = 0; unsigned long flags = 0; - if (page_size == PAGE_SIZE) - if (consume_stock(mem)) - goto done; + if (consume_stock(mem, page_size)) + goto done; ret = res_counter_charge(&mem->res, csize, &fail_res); if (likely(!ret)) {