From a4bf584ed8c2393966606748b73b34645a9c6ef8 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 14 May 2014 10:01:59 +1000 Subject: memcg: allow setting low_limit Export memory.low_limit_in_bytes knob with the same rules as the hard limit represented by limit_in_bytes knob (e.g. no limit to be set for the root cgroup). There is no memsw alternative for low_limit_in_bytes because the primary motivation behind this limit is to protect the working set of the group and so considering swap doesn't make much sense. There is also no kmem variant exported because we do not have any easy way to protect kernel allocations now. Please note that the low limit might exceed the hard limit which basically means that the group is not reclaimable if there is other reclaim target in the hierarchy under pressure. Signed-off-by: Michal Hocko Cc: Johannes Weiner Cc: KAMEZAWA Hiroyuki Cc: KOSAKI Motohiro Cc: Greg Thelen Cc: Michel Lespinasse Cc: Tejun Heo Cc: Hugh Dickins Cc: Roman Gushchin Signed-off-by: Andrew Morton --- kernel/res_counter.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'kernel/res_counter.c') diff --git a/kernel/res_counter.c b/kernel/res_counter.c index 51dbac6a3633..e851a9ad50bf 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c @@ -136,6 +136,8 @@ res_counter_member(struct res_counter *counter, int member) return &counter->failcnt; case RES_SOFT_LIMIT: return &counter->soft_limit; + case RES_LOW_LIMIT: + return &counter->low_limit; }; BUG(); -- cgit v1.2.3 From b8731b937d8890a2afaefde1673be791cc4055f9 Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 14 May 2014 10:02:23 +1000 Subject: kernel/res_counter.c: replace simple_strtoull by kstrtoull Signed-off-by: Fabian Frederick Cc: Michal Hocko Cc: Tejun Heo Signed-off-by: Andrew Morton --- kernel/res_counter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kernel/res_counter.c') diff --git a/kernel/res_counter.c b/kernel/res_counter.c index e851a9ad50bf..90b9f0e304fa 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c @@ -188,8 +188,8 @@ int res_counter_memparse_write_strategy(const char *buf, /* return RES_COUNTER_MAX(unlimited) if "-1" is specified */ if (*buf == '-') { - res = simple_strtoull(buf + 1, &end, 10); - if (res != 1 || *end != '\0') + int rc = kstrtoull(buf + 1, 10, &res); + if ((res != 1) || rc) return -EINVAL; *resp = RES_COUNTER_MAX; return 0; -- cgit v1.2.3 From 5f763f9cbb3542ee95cf68bbce746a02f19783d3 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 14 May 2014 10:02:23 +1000 Subject: kernel-res_counterc-replace-simple_strtoull-by-kstrtoull-fix don't overwrite kstrtoull()'s errno Cc: Fabian Frederick Cc: Michal Hocko Cc: Tejun Heo Signed-off-by: Andrew Morton --- kernel/res_counter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'kernel/res_counter.c') diff --git a/kernel/res_counter.c b/kernel/res_counter.c index 90b9f0e304fa..85ea94305015 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c @@ -189,7 +189,10 @@ int res_counter_memparse_write_strategy(const char *buf, /* return RES_COUNTER_MAX(unlimited) if "-1" is specified */ if (*buf == '-') { int rc = kstrtoull(buf + 1, 10, &res); - if ((res != 1) || rc) + + if (rc) + return rc; + if (res != 1) return -EINVAL; *resp = RES_COUNTER_MAX; return 0; -- cgit v1.2.3