diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b83790083087..6ad309e9825f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -571,6 +571,18 @@ done: | |||
571 | return ret; | 571 | return ret; |
572 | } | 572 | } |
573 | 573 | ||
574 | static bool mem_cgroup_check_under_limit(struct mem_cgroup *mem) | ||
575 | { | ||
576 | if (do_swap_account) { | ||
577 | if (res_counter_check_under_limit(&mem->res) && | ||
578 | res_counter_check_under_limit(&mem->memsw)) | ||
579 | return true; | ||
580 | } else | ||
581 | if (res_counter_check_under_limit(&mem->res)) | ||
582 | return true; | ||
583 | return false; | ||
584 | } | ||
585 | |||
574 | /* | 586 | /* |
575 | * Dance down the hierarchy if needed to reclaim memory. We remember the | 587 | * Dance down the hierarchy if needed to reclaim memory. We remember the |
576 | * last child we reclaimed from, so that we don't end up penalizing | 588 | * last child we reclaimed from, so that we don't end up penalizing |
@@ -592,7 +604,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, | |||
592 | * have left. | 604 | * have left. |
593 | */ | 605 | */ |
594 | ret = try_to_free_mem_cgroup_pages(root_mem, gfp_mask, noswap); | 606 | ret = try_to_free_mem_cgroup_pages(root_mem, gfp_mask, noswap); |
595 | if (res_counter_check_under_limit(&root_mem->res)) | 607 | if (mem_cgroup_check_under_limit(root_mem)) |
596 | return 0; | 608 | return 0; |
597 | 609 | ||
598 | next_mem = mem_cgroup_get_first_node(root_mem); | 610 | next_mem = mem_cgroup_get_first_node(root_mem); |
@@ -606,7 +618,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, | |||
606 | continue; | 618 | continue; |
607 | } | 619 | } |
608 | ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap); | 620 | ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap); |
609 | if (res_counter_check_under_limit(&root_mem->res)) | 621 | if (mem_cgroup_check_under_limit(root_mem)) |
610 | return 0; | 622 | return 0; |
611 | cgroup_lock(); | 623 | cgroup_lock(); |
612 | next_mem = mem_cgroup_get_next_node(next_mem, root_mem); | 624 | next_mem = mem_cgroup_get_next_node(next_mem, root_mem); |
@@ -709,12 +721,8 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
709 | * current usage of the cgroup before giving up | 721 | * current usage of the cgroup before giving up |
710 | * | 722 | * |
711 | */ | 723 | */ |
712 | if (do_swap_account) { | 724 | if (mem_cgroup_check_under_limit(mem_over_limit)) |
713 | if (res_counter_check_under_limit(&mem_over_limit->res) && | 725 | continue; |
714 | res_counter_check_under_limit(&mem_over_limit->memsw)) | ||
715 | continue; | ||
716 | } else if (res_counter_check_under_limit(&mem_over_limit->res)) | ||
717 | continue; | ||
718 | 726 | ||
719 | if (!nr_retries--) { | 727 | if (!nr_retries--) { |
720 | if (oom) { | 728 | if (oom) { |
@@ -1334,7 +1342,7 @@ int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask) | |||
1334 | 1342 | ||
1335 | do { | 1343 | do { |
1336 | progress = try_to_free_mem_cgroup_pages(mem, gfp_mask, true); | 1344 | progress = try_to_free_mem_cgroup_pages(mem, gfp_mask, true); |
1337 | progress += res_counter_check_under_limit(&mem->res); | 1345 | progress += mem_cgroup_check_under_limit(mem); |
1338 | } while (!progress && --retry); | 1346 | } while (!progress && --retry); |
1339 | 1347 | ||
1340 | css_put(&mem->css); | 1348 | css_put(&mem->css); |