Commit c5b947b2 authored by Daisuke Nishimura's avatar Daisuke Nishimura Committed by Linus Torvalds

memcg: add interface to reset limits

We don't have an interface to reset mem.limit or memsw.limit now.

This patch allows to reset mem.limit or memsw.limit when they are being
set to -1.
Signed-off-by: default avatarDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 22a668d7
...@@ -209,6 +209,7 @@ We can alter the memory limit: ...@@ -209,6 +209,7 @@ We can alter the memory limit:
NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo,
mega or gigabytes. mega or gigabytes.
NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited).
# cat /cgroups/0/memory.limit_in_bytes # cat /cgroups/0/memory.limit_in_bytes
4194304 4194304
......
...@@ -49,6 +49,8 @@ struct res_counter { ...@@ -49,6 +49,8 @@ struct res_counter {
struct res_counter *parent; struct res_counter *parent;
}; };
#define RESOURCE_MAX (unsigned long long)LLONG_MAX
/** /**
* Helpers to interact with userspace * Helpers to interact with userspace
* res_counter_read_u64() - returns the value of the specified member. * res_counter_read_u64() - returns the value of the specified member.
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
void res_counter_init(struct res_counter *counter, struct res_counter *parent) void res_counter_init(struct res_counter *counter, struct res_counter *parent)
{ {
spin_lock_init(&counter->lock); spin_lock_init(&counter->lock);
counter->limit = (unsigned long long)LLONG_MAX; counter->limit = RESOURCE_MAX;
counter->parent = parent; counter->parent = parent;
} }
...@@ -133,6 +133,16 @@ int res_counter_memparse_write_strategy(const char *buf, ...@@ -133,6 +133,16 @@ int res_counter_memparse_write_strategy(const char *buf,
unsigned long long *res) unsigned long long *res)
{ {
char *end; char *end;
/* return RESOURCE_MAX(unlimited) if "-1" is specified */
if (*buf == '-') {
*res = simple_strtoull(buf + 1, &end, 10);
if (*res != 1 || *end != '\0')
return -EINVAL;
*res = RESOURCE_MAX;
return 0;
}
/* FIXME - make memparse() take const char* args */ /* FIXME - make memparse() take const char* args */
*res = memparse((char *)buf, &end); *res = memparse((char *)buf, &end);
if (*end != '\0') if (*end != '\0')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment