* [PATCH 1/3] memcg: correct RESOURCE_MAX to ULLONG_MAX and rename it to a better one
@ 2013-05-05 15:41 Sha Zhengju
2013-05-07 13:40 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: Sha Zhengju @ 2013-05-05 15:41 UTC (permalink / raw)
To: cgroups, linux-mm; +Cc: nishimura, akpm, mhocko, jeff.liu, Sha Zhengju
Current RESOURCE_MAX(unlimited) is ULONG_MAX, but we can set a bigger value
than it which is strange. This patch fix it to UULONG_MAX.
Notice that this change will affect user output of default *.limit_in_bytes:
before change:
$ cat /memcg/memory.limit_in_bytes
9223372036854775807
after change:
$ cat /memcg/memory.limit_in_bytes
18446744073709551615
But it doesn't alter the API in term of input - we can still use
"echo -1 > *.limit_in_bytes" to reset the numbers to "unlimited".
Thanks the suggestions from Andrew and Daisuke Nishimura!
Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
---
include/linux/res_counter.h | 2 +-
kernel/res_counter.c | 8 ++++----
mm/memcontrol.c | 4 ++--
net/ipv4/tcp_memcontrol.c | 10 +++++-----
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index c230994..d7e9056 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -54,7 +54,7 @@ struct res_counter {
struct res_counter *parent;
};
-#define RESOURCE_MAX (unsigned long long)LLONG_MAX
+#define RES_COUNTER_MAX ULLONG_MAX
/**
* Helpers to interact with userspace
diff --git a/kernel/res_counter.c b/kernel/res_counter.c
index ff55247..3f0417f 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -17,8 +17,8 @@
void res_counter_init(struct res_counter *counter, struct res_counter *parent)
{
spin_lock_init(&counter->lock);
- counter->limit = RESOURCE_MAX;
- counter->soft_limit = RESOURCE_MAX;
+ counter->limit = RES_COUNTER_MAX;
+ counter->soft_limit = RES_COUNTER_MAX;
counter->parent = parent;
}
@@ -182,12 +182,12 @@ int res_counter_memparse_write_strategy(const char *buf,
{
char *end;
- /* return RESOURCE_MAX(unlimited) if "-1" is specified */
+ /* return RES_COUNTER_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;
+ *res = RES_COUNTER_MAX;
return 0;
}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cd940b1..d328798 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5261,7 +5261,7 @@ static int memcg_update_kmem_limit(struct cgroup *cont, u64 val)
*/
mutex_lock(&memcg_create_mutex);
mutex_lock(&set_limit_mutex);
- if (!memcg->kmem_account_flags && val != RESOURCE_MAX) {
+ if (!memcg->kmem_account_flags && val != RES_COUNTER_MAX) {
if (cgroup_task_count(cont) || memcg_has_children(memcg)) {
ret = -EBUSY;
goto out;
@@ -5271,7 +5271,7 @@ static int memcg_update_kmem_limit(struct cgroup *cont, u64 val)
ret = memcg_update_cache_sizes(memcg);
if (ret) {
- res_counter_set_limit(&memcg->kmem, RESOURCE_MAX);
+ res_counter_set_limit(&memcg->kmem, RES_COUNTER_MAX);
goto out;
}
static_key_slow_inc(&memcg_kmem_enabled_key);
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index b6f3583..21f810d 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -90,8 +90,8 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
if (!cg_proto)
return -EINVAL;
- if (val > RESOURCE_MAX)
- val = RESOURCE_MAX;
+ if (val > RES_COUNTER_MAX)
+ val = RES_COUNTER_MAX;
tcp = tcp_from_cgproto(cg_proto);
@@ -104,9 +104,9 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
tcp->tcp_prot_mem[i] = min_t(long, val >> PAGE_SHIFT,
net->ipv4.sysctl_tcp_mem[i]);
- if (val == RESOURCE_MAX)
+ if (val == RES_COUNTER_MAX)
clear_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags);
- else if (val != RESOURCE_MAX) {
+ else if (val != RES_COUNTER_MAX) {
/*
* The active bit needs to be written after the static_key
* update. This is what guarantees that the socket activation
@@ -190,7 +190,7 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft)
switch (cft->private) {
case RES_LIMIT:
- val = tcp_read_stat(memcg, RES_LIMIT, RESOURCE_MAX);
+ val = tcp_read_stat(memcg, RES_LIMIT, RES_COUNTER_MAX);
break;
case RES_USAGE:
val = tcp_read_usage(memcg);
--
1.7.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] memcg: correct RESOURCE_MAX to ULLONG_MAX and rename it to a better one
2013-05-05 15:41 [PATCH 1/3] memcg: correct RESOURCE_MAX to ULLONG_MAX and rename it to a better one Sha Zhengju
@ 2013-05-07 13:40 ` Michal Hocko
2013-05-07 15:10 ` Sha Zhengju
0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2013-05-07 13:40 UTC (permalink / raw)
To: Sha Zhengju; +Cc: cgroups, linux-mm, nishimura, akpm, jeff.liu, Sha Zhengju
On Sun 05-05-13 23:41:17, Sha Zhengju wrote:
> Current RESOURCE_MAX(unlimited) is ULONG_MAX, but we can set a bigger value
You have a typo here. The current limit is LLONG_MAX
> than it which is strange. This patch fix it to UULONG_MAX.
and the new one is ULLONG_MAX
> Notice that this change will affect user output of default *.limit_in_bytes:
> before change:
> $ cat /memcg/memory.limit_in_bytes
> 9223372036854775807
>
> after change:
> $ cat /memcg/memory.limit_in_bytes
> 18446744073709551615
>
> But it doesn't alter the API in term of input - we can still use
> "echo -1 > *.limit_in_bytes" to reset the numbers to "unlimited".
>
> Thanks the suggestions from Andrew and Daisuke Nishimura!
>
> Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
For the default change
Acked-by: Michal Hocko <mhocko@suse.cz>
> ---
> include/linux/res_counter.h | 2 +-
> kernel/res_counter.c | 8 ++++----
> mm/memcontrol.c | 4 ++--
> net/ipv4/tcp_memcontrol.c | 10 +++++-----
> 4 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index c230994..d7e9056 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -54,7 +54,7 @@ struct res_counter {
> struct res_counter *parent;
> };
>
> -#define RESOURCE_MAX (unsigned long long)LLONG_MAX
> +#define RES_COUNTER_MAX ULLONG_MAX
I do not think the renaming is worth bothering but if you feel it is a
better match then just do it in a separate patch, please.
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] memcg: correct RESOURCE_MAX to ULLONG_MAX and rename it to a better one
2013-05-07 13:40 ` Michal Hocko
@ 2013-05-07 15:10 ` Sha Zhengju
0 siblings, 0 replies; 3+ messages in thread
From: Sha Zhengju @ 2013-05-07 15:10 UTC (permalink / raw)
To: Michal Hocko
Cc: Cgroups, linux-mm@kvack.org, Daisuke Nishimura, Andrew Morton,
jeff.liu, Sha Zhengju
Hi Michal,
On Tue, May 7, 2013 at 9:40 PM, Michal Hocko <mhocko@suse.cz> wrote:
> On Sun 05-05-13 23:41:17, Sha Zhengju wrote:
>> Current RESOURCE_MAX(unlimited) is ULONG_MAX, but we can set a bigger value
>
> You have a typo here. The current limit is LLONG_MAX
>
>> than it which is strange. This patch fix it to UULONG_MAX.
>
> and the new one is ULLONG_MAX
Oops... It was most thoughtless of me.
>
>> Notice that this change will affect user output of default *.limit_in_bytes:
>> before change:
>> $ cat /memcg/memory.limit_in_bytes
>> 9223372036854775807
>>
>> after change:
>> $ cat /memcg/memory.limit_in_bytes
>> 18446744073709551615
>>
>> But it doesn't alter the API in term of input - we can still use
>> "echo -1 > *.limit_in_bytes" to reset the numbers to "unlimited".
>>
>> Thanks the suggestions from Andrew and Daisuke Nishimura!
>>
>> Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
>
> For the default change
> Acked-by: Michal Hocko <mhocko@suse.cz>
Thanks!
>
>> ---
>> include/linux/res_counter.h | 2 +-
>> kernel/res_counter.c | 8 ++++----
>> mm/memcontrol.c | 4 ++--
>> net/ipv4/tcp_memcontrol.c | 10 +++++-----
>> 4 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
>> index c230994..d7e9056 100644
>> --- a/include/linux/res_counter.h
>> +++ b/include/linux/res_counter.h
>> @@ -54,7 +54,7 @@ struct res_counter {
>> struct res_counter *parent;
>> };
>>
>> -#define RESOURCE_MAX (unsigned long long)LLONG_MAX
>> +#define RES_COUNTER_MAX ULLONG_MAX
>
> I do not think the renaming is worth bothering but if you feel it is a
> better match then just do it in a separate patch, please.
I've received comments from Andrew that he suggested we had better
rename it since it is too general. (Sorry, it's my fault that I didn't
mention the change log from V1, I will take care next time. The
previous discussion is here:
http://www.spinics.net/lists/cgroups/msg06788.html). I think we might
as well do it and I'll separate it in next turn.
--
Thanks,
Sha
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-07 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-05 15:41 [PATCH 1/3] memcg: correct RESOURCE_MAX to ULLONG_MAX and rename it to a better one Sha Zhengju
2013-05-07 13:40 ` Michal Hocko
2013-05-07 15:10 ` Sha Zhengju
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).