diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index db76ef72629..3878cfe399d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1832,6 +1832,7 @@ static int __mem_cgroup_do_charge(struct mem_cgroup *mem, gfp_t gfp_mask, | |||
1832 | if (likely(!ret)) | 1832 | if (likely(!ret)) |
1833 | return CHARGE_OK; | 1833 | return CHARGE_OK; |
1834 | 1834 | ||
1835 | res_counter_uncharge(&mem->res, csize); | ||
1835 | mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw); | 1836 | mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw); |
1836 | flags |= MEM_CGROUP_RECLAIM_NOSWAP; | 1837 | flags |= MEM_CGROUP_RECLAIM_NOSWAP; |
1837 | } else | 1838 | } else |
@@ -2144,6 +2145,8 @@ void mem_cgroup_split_huge_fixup(struct page *head, struct page *tail) | |||
2144 | struct page_cgroup *tail_pc = lookup_page_cgroup(tail); | 2145 | struct page_cgroup *tail_pc = lookup_page_cgroup(tail); |
2145 | unsigned long flags; | 2146 | unsigned long flags; |
2146 | 2147 | ||
2148 | if (mem_cgroup_disabled()) | ||
2149 | return; | ||
2147 | /* | 2150 | /* |
2148 | * We have no races with charge/uncharge but will have races with | 2151 | * We have no races with charge/uncharge but will have races with |
2149 | * page state accounting. | 2152 | * page state accounting. |
@@ -2233,7 +2236,12 @@ static int mem_cgroup_move_account(struct page_cgroup *pc, | |||
2233 | { | 2236 | { |
2234 | int ret = -EINVAL; | 2237 | int ret = -EINVAL; |
2235 | unsigned long flags; | 2238 | unsigned long flags; |
2236 | 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 | */ | ||
2237 | if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page)) | 2245 | if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page)) |
2238 | return -EBUSY; | 2246 | return -EBUSY; |
2239 | 2247 | ||
@@ -2265,7 +2273,7 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc, | |||
2265 | struct cgroup *cg = child->css.cgroup; | 2273 | struct cgroup *cg = child->css.cgroup; |
2266 | struct cgroup *pcg = cg->parent; | 2274 | struct cgroup *pcg = cg->parent; |
2267 | struct mem_cgroup *parent; | 2275 | struct mem_cgroup *parent; |
2268 | int charge = PAGE_SIZE; | 2276 | int page_size = PAGE_SIZE; |
2269 | unsigned long flags; | 2277 | unsigned long flags; |
2270 | int ret; | 2278 | int ret; |
2271 | 2279 | ||
@@ -2278,23 +2286,26 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc, | |||
2278 | goto out; | 2286 | goto out; |
2279 | if (isolate_lru_page(page)) | 2287 | if (isolate_lru_page(page)) |
2280 | goto put; | 2288 | goto put; |
2281 | /* The page is isolated from LRU and we have no race with splitting */ | 2289 | |
2282 | charge = PAGE_SIZE << compound_order(page); | 2290 | if (PageTransHuge(page)) |
2291 | page_size = HPAGE_SIZE; | ||
2283 | 2292 | ||
2284 | parent = mem_cgroup_from_cont(pcg); | 2293 | parent = mem_cgroup_from_cont(pcg); |
2285 | 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); | ||
2286 | if (ret || !parent) | 2296 | if (ret || !parent) |
2287 | goto put_back; | 2297 | goto put_back; |
2288 | 2298 | ||
2289 | if (charge > PAGE_SIZE) | 2299 | if (page_size > PAGE_SIZE) |
2290 | flags = compound_lock_irqsave(page); | 2300 | flags = compound_lock_irqsave(page); |
2291 | 2301 | ||
2292 | ret = mem_cgroup_move_account(pc, child, parent, true, charge); | 2302 | ret = mem_cgroup_move_account(pc, child, parent, true, page_size); |
2293 | if (ret) | 2303 | if (ret) |
2294 | mem_cgroup_cancel_charge(parent, charge); | 2304 | mem_cgroup_cancel_charge(parent, page_size); |
2295 | put_back: | 2305 | |
2296 | if (charge > PAGE_SIZE) | 2306 | if (page_size > PAGE_SIZE) |
2297 | compound_unlock_irqrestore(page, flags); | 2307 | compound_unlock_irqrestore(page, flags); |
2308 | put_back: | ||
2298 | putback_lru_page(page); | 2309 | putback_lru_page(page); |
2299 | put: | 2310 | put: |
2300 | put_page(page); | 2311 | put_page(page); |