From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.cz>, Tejun Heo <tj@kernel.org>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [patch 3/4] mm: memcontrol: add memory.max to default hierarchy
Date: Mon, 4 Aug 2014 17:14:56 -0400 [thread overview]
Message-ID: <1407186897-21048-4-git-send-email-hannes@cmpxchg.org> (raw)
In-Reply-To: <1407186897-21048-1-git-send-email-hannes@cmpxchg.org>
There are cases where a strict upper limit on a memcg is required, for
example, when containers are rented out and interference between them
can not be tolerated.
Provide memory.max, a limit that can not be breached and will trigger
group-internal OOM killing once page reclaim can no longer enforce it.
This can be combined with the high limit, to create a window in which
allocating tasks are throttled to approach the strict maximum limit
gracefully and with opportunity for the user or admin to intervene.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
Documentation/cgroups/unified-hierarchy.txt | 4 ++++
mm/memcontrol.c | 35 +++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/Documentation/cgroups/unified-hierarchy.txt b/Documentation/cgroups/unified-hierarchy.txt
index fd4f7f6847f6..6c52c926810f 100644
--- a/Documentation/cgroups/unified-hierarchy.txt
+++ b/Documentation/cgroups/unified-hierarchy.txt
@@ -334,6 +334,10 @@ supported and the interface files "release_agent" and
- memory.usage_in_bytes is renamed to memory.current to be in line
with the new naming scheme
+- memory.max provides a hard upper limit as a last-resort backup to
+ memory.high for situations with aggressive isolation requirements.
+
+
5. Planned Changes
5-1. CAP for resource control
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5a64fa96c08a..461834c86b94 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6306,6 +6306,36 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
return nbytes;
}
+static u64 memory_max_read(struct cgroup_subsys_state *css,
+ struct cftype *cft)
+{
+ struct mem_cgroup *memcg = mem_cgroup_from_css(css);
+
+ return res_counter_read_u64(&memcg->res, RES_LIMIT);
+}
+
+static ssize_t memory_max_write(struct kernfs_open_file *of,
+ char *buf, size_t nbytes, loff_t off)
+{
+ struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
+ u64 max;
+ int ret;
+
+ if (mem_cgroup_is_root(memcg))
+ return -EINVAL;
+
+ buf = strim(buf);
+ ret = res_counter_memparse_write_strategy(buf, &max);
+ if (ret)
+ return ret;
+
+ ret = mem_cgroup_resize_limit(memcg, max);
+ if (ret)
+ return ret;
+
+ return nbytes;
+}
+
static struct cftype memory_files[] = {
{
.name = "current",
@@ -6316,6 +6346,11 @@ static struct cftype memory_files[] = {
.read_u64 = memory_high_read,
.write = memory_high_write,
},
+ {
+ .name = "max",
+ .read_u64 = memory_max_read,
+ .write = memory_max_write,
+ },
};
struct cgroup_subsys memory_cgrp_subsys = {
--
2.0.3
--
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>
next prev parent reply other threads:[~2014-08-04 21:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-04 21:14 [patch 0/4] mm: memcontrol: populate unified hierarchy interface Johannes Weiner
2014-08-04 21:14 ` [patch 1/4] mm: memcontrol: reduce reclaim invocations for higher order requests Johannes Weiner
2014-08-07 13:08 ` Michal Hocko
2014-08-07 15:31 ` Johannes Weiner
2014-08-07 16:10 ` Greg Thelen
2014-08-08 12:47 ` Michal Hocko
2014-08-08 12:32 ` Michal Hocko
2014-08-08 13:26 ` Johannes Weiner
2014-08-11 7:49 ` Michal Hocko
2014-08-13 14:59 ` Michal Hocko
2014-08-13 20:41 ` Johannes Weiner
2014-08-14 16:12 ` Michal Hocko
2014-08-04 21:14 ` [patch 2/4] mm: memcontrol: add memory.current and memory.high to default hierarchy Johannes Weiner
2014-08-07 13:36 ` Michal Hocko
2014-08-07 13:39 ` Michal Hocko
2014-08-07 15:47 ` Johannes Weiner
2014-08-04 21:14 ` Johannes Weiner [this message]
2014-08-04 21:14 ` [patch 4/4] mm: memcontrol: add memory.vmstat " Johannes Weiner
2014-08-05 12:40 ` [patch 0/4] mm: memcontrol: populate unified hierarchy interface Michal Hocko
2014-08-05 13:53 ` Johannes Weiner
2014-08-05 15:27 ` Michal Hocko
2014-08-07 14:21 ` Johannes Weiner
2014-08-08 21:38 [patch 0/4] mm: memcontrol: populate unified hierarchy interface v2 Johannes Weiner
2014-08-08 21:38 ` [patch 3/4] mm: memcontrol: add memory.max to default hierarchy Johannes Weiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407186897-21048-4-git-send-email-hannes@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox