diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2015-02-11 18:26:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-11 20:06:02 -0500 |
commit | 650c5e565492f9092552bfe4d65935196c7d9567 (patch) | |
tree | 5fce0f701502f4b75339d4c53b37301d3db65fdb | |
parent | 8d29e18a459dfc2adeafc1acb9c4185ee6713116 (diff) |
mm: page_counter: pull "-1" handling out of page_counter_memparse()
The unified hierarchy interface for memory cgroups will no longer use "-1"
to mean maximum possible resource value. In preparation for this, make
the string an argument and let the caller supply it.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Vladimir Davydov <vdavydov@parallels.com>
Cc: Greg Thelen <gthelen@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/page_counter.h | 3 | ||||
-rw-r--r-- | mm/hugetlb_cgroup.c | 2 | ||||
-rw-r--r-- | mm/memcontrol.c | 4 | ||||
-rw-r--r-- | mm/page_counter.c | 7 | ||||
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 2 |
5 files changed, 10 insertions, 8 deletions
diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h index 955421575d16..17fa4f8de3a6 100644 --- a/include/linux/page_counter.h +++ b/include/linux/page_counter.h | |||
@@ -41,7 +41,8 @@ int page_counter_try_charge(struct page_counter *counter, | |||
41 | struct page_counter **fail); | 41 | struct page_counter **fail); |
42 | void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); | 42 | void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); |
43 | int page_counter_limit(struct page_counter *counter, unsigned long limit); | 43 | int page_counter_limit(struct page_counter *counter, unsigned long limit); |
44 | int page_counter_memparse(const char *buf, unsigned long *nr_pages); | 44 | int page_counter_memparse(const char *buf, const char *max, |
45 | unsigned long *nr_pages); | ||
45 | 46 | ||
46 | static inline void page_counter_reset_watermark(struct page_counter *counter) | 47 | static inline void page_counter_reset_watermark(struct page_counter *counter) |
47 | { | 48 | { |
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 037e1c00a5b7..6e0057439a46 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c | |||
@@ -279,7 +279,7 @@ static ssize_t hugetlb_cgroup_write(struct kernfs_open_file *of, | |||
279 | return -EINVAL; | 279 | return -EINVAL; |
280 | 280 | ||
281 | buf = strstrip(buf); | 281 | buf = strstrip(buf); |
282 | ret = page_counter_memparse(buf, &nr_pages); | 282 | ret = page_counter_memparse(buf, "-1", &nr_pages); |
283 | if (ret) | 283 | if (ret) |
284 | return ret; | 284 | return ret; |
285 | 285 | ||
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index dc5c4cd0afdf..6453ea5a27aa 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3414,7 +3414,7 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of, | |||
3414 | int ret; | 3414 | int ret; |
3415 | 3415 | ||
3416 | buf = strstrip(buf); | 3416 | buf = strstrip(buf); |
3417 | ret = page_counter_memparse(buf, &nr_pages); | 3417 | ret = page_counter_memparse(buf, "-1", &nr_pages); |
3418 | if (ret) | 3418 | if (ret) |
3419 | return ret; | 3419 | return ret; |
3420 | 3420 | ||
@@ -3786,7 +3786,7 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg, | |||
3786 | unsigned long usage; | 3786 | unsigned long usage; |
3787 | int i, size, ret; | 3787 | int i, size, ret; |
3788 | 3788 | ||
3789 | ret = page_counter_memparse(args, &threshold); | 3789 | ret = page_counter_memparse(args, "-1", &threshold); |
3790 | if (ret) | 3790 | if (ret) |
3791 | return ret; | 3791 | return ret; |
3792 | 3792 | ||
diff --git a/mm/page_counter.c b/mm/page_counter.c index a009574fbba9..11b4beda14ba 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c | |||
@@ -166,18 +166,19 @@ int page_counter_limit(struct page_counter *counter, unsigned long limit) | |||
166 | /** | 166 | /** |
167 | * page_counter_memparse - memparse() for page counter limits | 167 | * page_counter_memparse - memparse() for page counter limits |
168 | * @buf: string to parse | 168 | * @buf: string to parse |
169 | * @max: string meaning maximum possible value | ||
169 | * @nr_pages: returns the result in number of pages | 170 | * @nr_pages: returns the result in number of pages |
170 | * | 171 | * |
171 | * Returns -EINVAL, or 0 and @nr_pages on success. @nr_pages will be | 172 | * Returns -EINVAL, or 0 and @nr_pages on success. @nr_pages will be |
172 | * limited to %PAGE_COUNTER_MAX. | 173 | * limited to %PAGE_COUNTER_MAX. |
173 | */ | 174 | */ |
174 | int page_counter_memparse(const char *buf, unsigned long *nr_pages) | 175 | int page_counter_memparse(const char *buf, const char *max, |
176 | unsigned long *nr_pages) | ||
175 | { | 177 | { |
176 | char unlimited[] = "-1"; | ||
177 | char *end; | 178 | char *end; |
178 | u64 bytes; | 179 | u64 bytes; |
179 | 180 | ||
180 | if (!strncmp(buf, unlimited, sizeof(unlimited))) { | 181 | if (!strcmp(buf, max)) { |
181 | *nr_pages = PAGE_COUNTER_MAX; | 182 | *nr_pages = PAGE_COUNTER_MAX; |
182 | return 0; | 183 | return 0; |
183 | } | 184 | } |
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index 272327134a1b..c2a75c6957a1 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c | |||
@@ -120,7 +120,7 @@ static ssize_t tcp_cgroup_write(struct kernfs_open_file *of, | |||
120 | switch (of_cft(of)->private) { | 120 | switch (of_cft(of)->private) { |
121 | case RES_LIMIT: | 121 | case RES_LIMIT: |
122 | /* see memcontrol.c */ | 122 | /* see memcontrol.c */ |
123 | ret = page_counter_memparse(buf, &nr_pages); | 123 | ret = page_counter_memparse(buf, "-1", &nr_pages); |
124 | if (ret) | 124 | if (ret) |
125 | break; | 125 | break; |
126 | mutex_lock(&tcp_limit_mutex); | 126 | mutex_lock(&tcp_limit_mutex); |