diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2009-10-01 18:44:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-10-01 19:11:13 -0400 |
commit | 4e649152cbaa1aedd01821d200ab9d597fe469e4 (patch) | |
tree | 635fa7d75acda929e81b8b0db7e641b7d4e07b35 /kernel/res_counter.c | |
parent | 3dece8347df6a16239fab10dadb370854f1c969c (diff) |
memcg: some modification to softlimit under hierarchical memory reclaim.
This patch clean up/fixes for memcg's uncharge soft limit path.
Problems:
Now, res_counter_charge()/uncharge() handles softlimit information at
charge/uncharge and softlimit-check is done when event counter per memcg
goes over limit. Now, event counter per memcg is updated only when
memory usage is over soft limit. Here, considering hierarchical memcg
management, ancesotors should be taken care of.
Now, ancerstors(hierarchy) are handled in charge() but not in uncharge().
This is not good.
Prolems:
1. memcg's event counter incremented only when softlimit hits. That's bad.
It makes event counter hard to be reused for other purpose.
2. At uncharge, only the lowest level rescounter is handled. This is bug.
Because ancesotor's event counter is not incremented, children should
take care of them.
3. res_counter_uncharge()'s 3rd argument is NULL in most case.
ops under res_counter->lock should be small. No "if" sentense is better.
Fixes:
* Removed soft_limit_xx poitner and checks in charge and uncharge.
Do-check-only-when-necessary scheme works enough well without them.
* make event-counter of memcg incremented at every charge/uncharge.
(per-cpu area will be accessed soon anyway)
* All ancestors are checked at soft-limit-check. This is necessary because
ancesotor's event counter may never be modified. Then, they should be
checked at the same time.
Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/res_counter.c')
-rw-r--r-- | kernel/res_counter.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/kernel/res_counter.c b/kernel/res_counter.c index 88faec23e833..bcdabf37c40b 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c | |||
@@ -37,27 +37,17 @@ int res_counter_charge_locked(struct res_counter *counter, unsigned long val) | |||
37 | } | 37 | } |
38 | 38 | ||
39 | int res_counter_charge(struct res_counter *counter, unsigned long val, | 39 | int res_counter_charge(struct res_counter *counter, unsigned long val, |
40 | struct res_counter **limit_fail_at, | 40 | struct res_counter **limit_fail_at) |
41 | struct res_counter **soft_limit_fail_at) | ||
42 | { | 41 | { |
43 | int ret; | 42 | int ret; |
44 | unsigned long flags; | 43 | unsigned long flags; |
45 | struct res_counter *c, *u; | 44 | struct res_counter *c, *u; |
46 | 45 | ||
47 | *limit_fail_at = NULL; | 46 | *limit_fail_at = NULL; |
48 | if (soft_limit_fail_at) | ||
49 | *soft_limit_fail_at = NULL; | ||
50 | local_irq_save(flags); | 47 | local_irq_save(flags); |
51 | for (c = counter; c != NULL; c = c->parent) { | 48 | for (c = counter; c != NULL; c = c->parent) { |
52 | spin_lock(&c->lock); | 49 | spin_lock(&c->lock); |
53 | ret = res_counter_charge_locked(c, val); | 50 | ret = res_counter_charge_locked(c, val); |
54 | /* | ||
55 | * With soft limits, we return the highest ancestor | ||
56 | * that exceeds its soft limit | ||
57 | */ | ||
58 | if (soft_limit_fail_at && | ||
59 | !res_counter_soft_limit_check_locked(c)) | ||
60 | *soft_limit_fail_at = c; | ||
61 | spin_unlock(&c->lock); | 51 | spin_unlock(&c->lock); |
62 | if (ret < 0) { | 52 | if (ret < 0) { |
63 | *limit_fail_at = c; | 53 | *limit_fail_at = c; |
@@ -85,8 +75,7 @@ void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val) | |||
85 | counter->usage -= val; | 75 | counter->usage -= val; |
86 | } | 76 | } |
87 | 77 | ||
88 | void res_counter_uncharge(struct res_counter *counter, unsigned long val, | 78 | void res_counter_uncharge(struct res_counter *counter, unsigned long val) |
89 | bool *was_soft_limit_excess) | ||
90 | { | 79 | { |
91 | unsigned long flags; | 80 | unsigned long flags; |
92 | struct res_counter *c; | 81 | struct res_counter *c; |
@@ -94,9 +83,6 @@ void res_counter_uncharge(struct res_counter *counter, unsigned long val, | |||
94 | local_irq_save(flags); | 83 | local_irq_save(flags); |
95 | for (c = counter; c != NULL; c = c->parent) { | 84 | for (c = counter; c != NULL; c = c->parent) { |
96 | spin_lock(&c->lock); | 85 | spin_lock(&c->lock); |
97 | if (was_soft_limit_excess) | ||
98 | *was_soft_limit_excess = | ||
99 | !res_counter_soft_limit_check_locked(c); | ||
100 | res_counter_uncharge_locked(c, val); | 86 | res_counter_uncharge_locked(c, val); |
101 | spin_unlock(&c->lock); | 87 | spin_unlock(&c->lock); |
102 | } | 88 | } |