diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2009-09-23 18:56:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-24 10:20:59 -0400 |
commit | 296c81d89f4f14269f7346f81442910158c0a83a (patch) | |
tree | cf0e1facd1fed8282c1885bc4126e7bca1928712 /mm/memcontrol.c | |
parent | a6df63615b943dbef22df04c19f4506330fe835e (diff) |
memory controller: soft limit interface
Add an interface to allow get/set of soft limits. Soft limits for memory
plus swap controller (memsw) is currently not supported. Resource
counters have been enhanced to support soft limits and new type
RES_SOFT_LIMIT has been added. Unlike hard limits, soft limits can be
directly set and do not need any reclaim or checks before setting them to
a newer value.
Kamezawa-San raised a question as to whether soft limit should belong to
res_counter. Since all resources understand the basic concepts of hard
and soft limits, it is justified to add soft limits here. Soft limits are
a generic resource usage feature, even file system quotas support soft
limits.
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
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 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index eb9571815f0c..4ad3e6be045d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2123,6 +2123,20 @@ static int mem_cgroup_write(struct cgroup *cont, struct cftype *cft, | |||
2123 | else | 2123 | else |
2124 | ret = mem_cgroup_resize_memsw_limit(memcg, val); | 2124 | ret = mem_cgroup_resize_memsw_limit(memcg, val); |
2125 | break; | 2125 | break; |
2126 | case RES_SOFT_LIMIT: | ||
2127 | ret = res_counter_memparse_write_strategy(buffer, &val); | ||
2128 | if (ret) | ||
2129 | break; | ||
2130 | /* | ||
2131 | * For memsw, soft limits are hard to implement in terms | ||
2132 | * of semantics, for now, we support soft limits for | ||
2133 | * control without swap | ||
2134 | */ | ||
2135 | if (type == _MEM) | ||
2136 | ret = res_counter_set_soft_limit(&memcg->res, val); | ||
2137 | else | ||
2138 | ret = -EINVAL; | ||
2139 | break; | ||
2126 | default: | 2140 | default: |
2127 | ret = -EINVAL; /* should be BUG() ? */ | 2141 | ret = -EINVAL; /* should be BUG() ? */ |
2128 | break; | 2142 | break; |
@@ -2376,6 +2390,12 @@ static struct cftype mem_cgroup_files[] = { | |||
2376 | .read_u64 = mem_cgroup_read, | 2390 | .read_u64 = mem_cgroup_read, |
2377 | }, | 2391 | }, |
2378 | { | 2392 | { |
2393 | .name = "soft_limit_in_bytes", | ||
2394 | .private = MEMFILE_PRIVATE(_MEM, RES_SOFT_LIMIT), | ||
2395 | .write_string = mem_cgroup_write, | ||
2396 | .read_u64 = mem_cgroup_read, | ||
2397 | }, | ||
2398 | { | ||
2379 | .name = "failcnt", | 2399 | .name = "failcnt", |
2380 | .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT), | 2400 | .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT), |
2381 | .trigger = mem_cgroup_reset, | 2401 | .trigger = mem_cgroup_reset, |