Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 127577
b: refs/heads/master
c: b85a96c
h: refs/heads/master
i:
  127575: 0b6b242
v: v3
  • Loading branch information
Daisuke Nishimura authored and Linus Torvalds committed Jan 8, 2009
1 parent 9b5106c commit fa959b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9717d28d673468883df8ac34b47268719ac5a3d
refs/heads/master: b85a96c0b6cb79c67e7b01b66368f2e31579d7c5
26 changes: 17 additions & 9 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ mem_cgroup_get_first_node(struct mem_cgroup *root_mem)
return ret;
}

static bool mem_cgroup_check_under_limit(struct mem_cgroup *mem)
{
if (do_swap_account) {
if (res_counter_check_under_limit(&mem->res) &&
res_counter_check_under_limit(&mem->memsw))
return true;
} else
if (res_counter_check_under_limit(&mem->res))
return true;
return false;
}

/*
* Dance down the hierarchy if needed to reclaim memory. We remember the
* last child we reclaimed from, so that we don't end up penalizing
Expand All @@ -592,7 +604,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
* have left.
*/
ret = try_to_free_mem_cgroup_pages(root_mem, gfp_mask, noswap);
if (res_counter_check_under_limit(&root_mem->res))
if (mem_cgroup_check_under_limit(root_mem))
return 0;

next_mem = mem_cgroup_get_first_node(root_mem);
Expand All @@ -606,7 +618,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
continue;
}
ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap);
if (res_counter_check_under_limit(&root_mem->res))
if (mem_cgroup_check_under_limit(root_mem))
return 0;
cgroup_lock();
next_mem = mem_cgroup_get_next_node(next_mem, root_mem);
Expand Down Expand Up @@ -709,12 +721,8 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
* current usage of the cgroup before giving up
*
*/
if (do_swap_account) {
if (res_counter_check_under_limit(&mem_over_limit->res) &&
res_counter_check_under_limit(&mem_over_limit->memsw))
continue;
} else if (res_counter_check_under_limit(&mem_over_limit->res))
continue;
if (mem_cgroup_check_under_limit(mem_over_limit))
continue;

if (!nr_retries--) {
if (oom) {
Expand Down Expand Up @@ -1334,7 +1342,7 @@ int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask)

do {
progress = try_to_free_mem_cgroup_pages(mem, gfp_mask, true);
progress += res_counter_check_under_limit(&mem->res);
progress += mem_cgroup_check_under_limit(mem);
} while (!progress && --retry);

css_put(&mem->css);
Expand Down

0 comments on commit fa959b2

Please sign in to comment.