diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ff7cac602984..ac8774426fec 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -261,7 +261,8 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | |||
261 | * 0 if the charge was successful | 261 | * 0 if the charge was successful |
262 | * < 0 if the cgroup is over its limit | 262 | * < 0 if the cgroup is over its limit |
263 | */ | 263 | */ |
264 | int mem_cgroup_charge(struct page *page, struct mm_struct *mm) | 264 | int mem_cgroup_charge(struct page *page, struct mm_struct *mm, |
265 | gfp_t gfp_mask) | ||
265 | { | 266 | { |
266 | struct mem_cgroup *mem; | 267 | struct mem_cgroup *mem; |
267 | struct page_cgroup *pc, *race_pc; | 268 | struct page_cgroup *pc, *race_pc; |
@@ -293,7 +294,7 @@ retry: | |||
293 | 294 | ||
294 | unlock_page_cgroup(page); | 295 | unlock_page_cgroup(page); |
295 | 296 | ||
296 | pc = kzalloc(sizeof(struct page_cgroup), GFP_KERNEL); | 297 | pc = kzalloc(sizeof(struct page_cgroup), gfp_mask); |
297 | if (pc == NULL) | 298 | if (pc == NULL) |
298 | goto err; | 299 | goto err; |
299 | 300 | ||
@@ -320,7 +321,14 @@ retry: | |||
320 | * the cgroup limit. | 321 | * the cgroup limit. |
321 | */ | 322 | */ |
322 | while (res_counter_charge(&mem->res, PAGE_SIZE)) { | 323 | while (res_counter_charge(&mem->res, PAGE_SIZE)) { |
323 | if (try_to_free_mem_cgroup_pages(mem)) | 324 | bool is_atomic = gfp_mask & GFP_ATOMIC; |
325 | /* | ||
326 | * We cannot reclaim under GFP_ATOMIC, fail the charge | ||
327 | */ | ||
328 | if (is_atomic) | ||
329 | goto noreclaim; | ||
330 | |||
331 | if (try_to_free_mem_cgroup_pages(mem, gfp_mask)) | ||
324 | continue; | 332 | continue; |
325 | 333 | ||
326 | /* | 334 | /* |
@@ -344,9 +352,10 @@ retry: | |||
344 | congestion_wait(WRITE, HZ/10); | 352 | congestion_wait(WRITE, HZ/10); |
345 | continue; | 353 | continue; |
346 | } | 354 | } |
347 | 355 | noreclaim: | |
348 | css_put(&mem->css); | 356 | css_put(&mem->css); |
349 | mem_cgroup_out_of_memory(mem, GFP_KERNEL); | 357 | if (!is_atomic) |
358 | mem_cgroup_out_of_memory(mem, GFP_KERNEL); | ||
350 | goto free_pc; | 359 | goto free_pc; |
351 | } | 360 | } |
352 | 361 | ||
@@ -385,7 +394,8 @@ err: | |||
385 | /* | 394 | /* |
386 | * See if the cached pages should be charged at all? | 395 | * See if the cached pages should be charged at all? |
387 | */ | 396 | */ |
388 | int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm) | 397 | int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, |
398 | gfp_t gfp_mask) | ||
389 | { | 399 | { |
390 | struct mem_cgroup *mem; | 400 | struct mem_cgroup *mem; |
391 | if (!mm) | 401 | if (!mm) |
@@ -393,7 +403,7 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm) | |||
393 | 403 | ||
394 | mem = rcu_dereference(mm->mem_cgroup); | 404 | mem = rcu_dereference(mm->mem_cgroup); |
395 | if (mem->control_type == MEM_CGROUP_TYPE_ALL) | 405 | if (mem->control_type == MEM_CGROUP_TYPE_ALL) |
396 | return mem_cgroup_charge(page, mm); | 406 | return mem_cgroup_charge(page, mm, gfp_mask); |
397 | else | 407 | else |
398 | return 0; | 408 | return 0; |
399 | } | 409 | } |