aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8ab1d42664f..3878cfe399d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2236,7 +2236,12 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
2236{ 2236{
2237 int ret = -EINVAL; 2237 int ret = -EINVAL;
2238 unsigned long flags; 2238 unsigned long flags;
2239 2239 /*
2240 * The page is isolated from LRU. So, collapse function
2241 * will not handle this page. But page splitting can happen.
2242 * Do this check under compound_page_lock(). The caller should
2243 * hold it.
2244 */
2240 if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page)) 2245 if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page))
2241 return -EBUSY; 2246 return -EBUSY;
2242 2247
@@ -2268,7 +2273,7 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
2268 struct cgroup *cg = child->css.cgroup; 2273 struct cgroup *cg = child->css.cgroup;
2269 struct cgroup *pcg = cg->parent; 2274 struct cgroup *pcg = cg->parent;
2270 struct mem_cgroup *parent; 2275 struct mem_cgroup *parent;
2271 int charge = PAGE_SIZE; 2276 int page_size = PAGE_SIZE;
2272 unsigned long flags; 2277 unsigned long flags;
2273 int ret; 2278 int ret;
2274 2279
@@ -2281,22 +2286,24 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
2281 goto out; 2286 goto out;
2282 if (isolate_lru_page(page)) 2287 if (isolate_lru_page(page))
2283 goto put; 2288 goto put;
2284 /* The page is isolated from LRU and we have no race with splitting */ 2289
2285 charge = PAGE_SIZE << compound_order(page); 2290 if (PageTransHuge(page))
2291 page_size = HPAGE_SIZE;
2286 2292
2287 parent = mem_cgroup_from_cont(pcg); 2293 parent = mem_cgroup_from_cont(pcg);
2288 ret = __mem_cgroup_try_charge(NULL, gfp_mask, &parent, false, charge); 2294 ret = __mem_cgroup_try_charge(NULL, gfp_mask,
2295 &parent, false, page_size);
2289 if (ret || !parent) 2296 if (ret || !parent)
2290 goto put_back; 2297 goto put_back;
2291 2298
2292 if (charge > PAGE_SIZE) 2299 if (page_size > PAGE_SIZE)
2293 flags = compound_lock_irqsave(page); 2300 flags = compound_lock_irqsave(page);
2294 2301
2295 ret = mem_cgroup_move_account(pc, child, parent, true, charge); 2302 ret = mem_cgroup_move_account(pc, child, parent, true, page_size);
2296 if (ret) 2303 if (ret)
2297 mem_cgroup_cancel_charge(parent, charge); 2304 mem_cgroup_cancel_charge(parent, page_size);
2298 2305
2299 if (charge > PAGE_SIZE) 2306 if (page_size > PAGE_SIZE)
2300 compound_unlock_irqrestore(page, flags); 2307 compound_unlock_irqrestore(page, flags);
2301put_back: 2308put_back:
2302 putback_lru_page(page); 2309 putback_lru_page(page);