diff options
author | Qiang Huang <h.huangqiang@huawei.com> | 2014-06-04 19:08:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:05 -0400 |
commit | bdcbb659fe630fc64f6604e99a180bb2ccc630c2 (patch) | |
tree | 4a4a7ef641fcd4c704c47b55cf57fbbcb946d7d9 /mm/memcontrol.c | |
parent | 3fb1c8dcfcda2f5bfb7d79d8b08bf2f04b1eed8f (diff) |
memcg: fold mem_cgroup_stolen
It is only used in __mem_cgroup_begin_update_page_stat(), the name is
confusing and 2 routines for one thing also confuse people, so fold this
function seems more clear.
[akpm@linux-foundation.org: fix typo, per Michal]
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: 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 | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 03d76628fd9d..4a9dfc83643d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1594,23 +1594,12 @@ static void mem_cgroup_end_move(struct mem_cgroup *memcg) | |||
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | /* | 1596 | /* |
1597 | * 2 routines for checking "mem" is under move_account() or not. | 1597 | * A routine for checking "mem" is under move_account() or not. |
1598 | * | 1598 | * |
1599 | * mem_cgroup_stolen() - checking whether a cgroup is mc.from or not. This | 1599 | * Checking a cgroup is mc.from or mc.to or under hierarchy of |
1600 | * is used for avoiding races in accounting. If true, | 1600 | * moving cgroups. This is for waiting at high-memory pressure |
1601 | * pc->mem_cgroup may be overwritten. | 1601 | * caused by "move". |
1602 | * | ||
1603 | * mem_cgroup_under_move() - checking a cgroup is mc.from or mc.to or | ||
1604 | * under hierarchy of moving cgroups. This is for | ||
1605 | * waiting at hith-memory prressure caused by "move". | ||
1606 | */ | 1602 | */ |
1607 | |||
1608 | static bool mem_cgroup_stolen(struct mem_cgroup *memcg) | ||
1609 | { | ||
1610 | VM_BUG_ON(!rcu_read_lock_held()); | ||
1611 | return atomic_read(&memcg->moving_account) > 0; | ||
1612 | } | ||
1613 | |||
1614 | static bool mem_cgroup_under_move(struct mem_cgroup *memcg) | 1603 | static bool mem_cgroup_under_move(struct mem_cgroup *memcg) |
1615 | { | 1604 | { |
1616 | struct mem_cgroup *from; | 1605 | struct mem_cgroup *from; |
@@ -1653,7 +1642,6 @@ static bool mem_cgroup_wait_acct_move(struct mem_cgroup *memcg) | |||
1653 | * Take this lock when | 1642 | * Take this lock when |
1654 | * - a code tries to modify page's memcg while it's USED. | 1643 | * - a code tries to modify page's memcg while it's USED. |
1655 | * - a code tries to modify page state accounting in a memcg. | 1644 | * - a code tries to modify page state accounting in a memcg. |
1656 | * see mem_cgroup_stolen(), too. | ||
1657 | */ | 1645 | */ |
1658 | static void move_lock_mem_cgroup(struct mem_cgroup *memcg, | 1646 | static void move_lock_mem_cgroup(struct mem_cgroup *memcg, |
1659 | unsigned long *flags) | 1647 | unsigned long *flags) |
@@ -2326,9 +2314,10 @@ again: | |||
2326 | * If this memory cgroup is not under account moving, we don't | 2314 | * If this memory cgroup is not under account moving, we don't |
2327 | * need to take move_lock_mem_cgroup(). Because we already hold | 2315 | * need to take move_lock_mem_cgroup(). Because we already hold |
2328 | * rcu_read_lock(), any calls to move_account will be delayed until | 2316 | * rcu_read_lock(), any calls to move_account will be delayed until |
2329 | * rcu_read_unlock() if mem_cgroup_stolen() == true. | 2317 | * rcu_read_unlock(). |
2330 | */ | 2318 | */ |
2331 | if (!mem_cgroup_stolen(memcg)) | 2319 | VM_BUG_ON(!rcu_read_lock_held()); |
2320 | if (atomic_read(&memcg->moving_account) <= 0) | ||
2332 | return; | 2321 | return; |
2333 | 2322 | ||
2334 | move_lock_mem_cgroup(memcg, flags); | 2323 | move_lock_mem_cgroup(memcg, flags); |