diff options
-rw-r--r-- | Documentation/cgroups/memory.txt | 1 | ||||
-rw-r--r-- | include/linux/res_counter.h | 2 | ||||
-rw-r--r-- | kernel/res_counter.c | 12 |
3 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index af48135bd9b8..23d1262c0775 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt | |||
@@ -209,6 +209,7 @@ We can alter the memory limit: | |||
209 | 209 | ||
210 | NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, | 210 | NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, |
211 | mega or gigabytes. | 211 | mega or gigabytes. |
212 | NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited). | ||
212 | 213 | ||
213 | # cat /cgroups/0/memory.limit_in_bytes | 214 | # cat /cgroups/0/memory.limit_in_bytes |
214 | 4194304 | 215 | 4194304 |
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h index 4c5bcf6ca7e8..511f42fc6816 100644 --- a/include/linux/res_counter.h +++ b/include/linux/res_counter.h | |||
@@ -49,6 +49,8 @@ struct res_counter { | |||
49 | struct res_counter *parent; | 49 | struct res_counter *parent; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | #define RESOURCE_MAX (unsigned long long)LLONG_MAX | ||
53 | |||
52 | /** | 54 | /** |
53 | * Helpers to interact with userspace | 55 | * Helpers to interact with userspace |
54 | * res_counter_read_u64() - returns the value of the specified member. | 56 | * res_counter_read_u64() - returns the value of the specified member. |
diff --git a/kernel/res_counter.c b/kernel/res_counter.c index bf8e7534c803..e1338f074314 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c | |||
@@ -18,7 +18,7 @@ | |||
18 | void res_counter_init(struct res_counter *counter, struct res_counter *parent) | 18 | void res_counter_init(struct res_counter *counter, struct res_counter *parent) |
19 | { | 19 | { |
20 | spin_lock_init(&counter->lock); | 20 | spin_lock_init(&counter->lock); |
21 | counter->limit = (unsigned long long)LLONG_MAX; | 21 | counter->limit = RESOURCE_MAX; |
22 | counter->parent = parent; | 22 | counter->parent = parent; |
23 | } | 23 | } |
24 | 24 | ||
@@ -133,6 +133,16 @@ int res_counter_memparse_write_strategy(const char *buf, | |||
133 | unsigned long long *res) | 133 | unsigned long long *res) |
134 | { | 134 | { |
135 | char *end; | 135 | char *end; |
136 | |||
137 | /* return RESOURCE_MAX(unlimited) if "-1" is specified */ | ||
138 | if (*buf == '-') { | ||
139 | *res = simple_strtoull(buf + 1, &end, 10); | ||
140 | if (*res != 1 || *end != '\0') | ||
141 | return -EINVAL; | ||
142 | *res = RESOURCE_MAX; | ||
143 | return 0; | ||
144 | } | ||
145 | |||
136 | /* FIXME - make memparse() take const char* args */ | 146 | /* FIXME - make memparse() take const char* args */ |
137 | *res = memparse((char *)buf, &end); | 147 | *res = memparse((char *)buf, &end); |
138 | if (*end != '\0') | 148 | if (*end != '\0') |