diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2012-07-31 19:42:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-31 21:42:42 -0400 |
commit | 3c935d189be9bb877c5a1110ac5fbf9c8e310658 (patch) | |
tree | 84aa62c9309a27cba588bb1a822a344b648a3497 /mm/memcontrol.c | |
parent | 6068bf0104becf07792b2867bc4d17c369419f8b (diff) |
memcg: make mem_cgroup_force_empty_list() return bool
mem_cgroup_force_empty_list() just returns 0 or -EBUSY and -EBUSY
indicates 'you need to retry'. Make mem_cgroup_force_empty_list() return
a bool to simplify the logic.
[akpm@linux-foundation.org: rework mem_cgroup_force_empty_list()'s comment]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 964786634746..a2677e0a6387 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3609,10 +3609,12 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | |||
3609 | } | 3609 | } |
3610 | 3610 | ||
3611 | /* | 3611 | /* |
3612 | * This routine traverse page_cgroup in given list and drop them all. | 3612 | * Traverse a specified page_cgroup list and try to drop them all. This doesn't |
3613 | * *And* this routine doesn't reclaim page itself, just removes page_cgroup. | 3613 | * reclaim the pages page themselves - it just removes the page_cgroups. |
3614 | * Returns true if some page_cgroups were not freed, indicating that the caller | ||
3615 | * must retry this operation. | ||
3614 | */ | 3616 | */ |
3615 | static int mem_cgroup_force_empty_list(struct mem_cgroup *memcg, | 3617 | static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg, |
3616 | int node, int zid, enum lru_list lru) | 3618 | int node, int zid, enum lru_list lru) |
3617 | { | 3619 | { |
3618 | struct mem_cgroup_per_zone *mz; | 3620 | struct mem_cgroup_per_zone *mz; |
@@ -3620,7 +3622,6 @@ static int mem_cgroup_force_empty_list(struct mem_cgroup *memcg, | |||
3620 | struct list_head *list; | 3622 | struct list_head *list; |
3621 | struct page *busy; | 3623 | struct page *busy; |
3622 | struct zone *zone; | 3624 | struct zone *zone; |
3623 | int ret = 0; | ||
3624 | 3625 | ||
3625 | zone = &NODE_DATA(node)->node_zones[zid]; | 3626 | zone = &NODE_DATA(node)->node_zones[zid]; |
3626 | mz = mem_cgroup_zoneinfo(memcg, node, zid); | 3627 | mz = mem_cgroup_zoneinfo(memcg, node, zid); |
@@ -3634,7 +3635,6 @@ static int mem_cgroup_force_empty_list(struct mem_cgroup *memcg, | |||
3634 | struct page_cgroup *pc; | 3635 | struct page_cgroup *pc; |
3635 | struct page *page; | 3636 | struct page *page; |
3636 | 3637 | ||
3637 | ret = 0; | ||
3638 | spin_lock_irqsave(&zone->lru_lock, flags); | 3638 | spin_lock_irqsave(&zone->lru_lock, flags); |
3639 | if (list_empty(list)) { | 3639 | if (list_empty(list)) { |
3640 | spin_unlock_irqrestore(&zone->lru_lock, flags); | 3640 | spin_unlock_irqrestore(&zone->lru_lock, flags); |
@@ -3651,19 +3651,14 @@ static int mem_cgroup_force_empty_list(struct mem_cgroup *memcg, | |||
3651 | 3651 | ||
3652 | pc = lookup_page_cgroup(page); | 3652 | pc = lookup_page_cgroup(page); |
3653 | 3653 | ||
3654 | ret = mem_cgroup_move_parent(page, pc, memcg); | 3654 | if (mem_cgroup_move_parent(page, pc, memcg)) { |
3655 | |||
3656 | if (ret == -EBUSY || ret == -EINVAL) { | ||
3657 | /* found lock contention or "pc" is obsolete. */ | 3655 | /* found lock contention or "pc" is obsolete. */ |
3658 | busy = page; | 3656 | busy = page; |
3659 | cond_resched(); | 3657 | cond_resched(); |
3660 | } else | 3658 | } else |
3661 | busy = NULL; | 3659 | busy = NULL; |
3662 | } | 3660 | } |
3663 | 3661 | return !list_empty(list); | |
3664 | if (!ret && !list_empty(list)) | ||
3665 | return -EBUSY; | ||
3666 | return ret; | ||
3667 | } | 3662 | } |
3668 | 3663 | ||
3669 | /* | 3664 | /* |