From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mhocko-AlSwsSmVLrQ@public.gmane.org,
kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org,
vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: [PATCH v2 4/4] memcg: force use_hierarchy if sane_behavior
Date: Mon, 15 Apr 2013 13:40:16 -0700 [thread overview]
Message-ID: <20130415204016.GA19531@mtj.dyndns.org> (raw)
In-Reply-To: <1365808259-31073-5-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Turn on use_hierarchy by default if sane_behavior is specified and
don't create .use_hierarchy file.
It is debatable whether to remove .use_hierarchy file or make it ro as
the former could make transition easier in certain cases; however, the
behavior changes which will be gated by sane_behavior are intensive
including changing basic meaning of certain control knobs in a few
controllers and I don't really think keeping this piece would make
things easier in any noticeable way, so let's remove it.
v2: Explain that mem_cgroup_bind() doesn't have to worry about
children as suggested by Michal Hocko.
Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Serge E. Hallyn <serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
Acked-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Acked-by: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
Applying to cgroup/for-3.10.
Thanks!
include/linux/cgroup.h | 3 +++
mm/memcontrol.c | 17 +++++++++++++++++
2 files changed, 20 insertions(+)
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -269,6 +269,9 @@ enum {
*
* - Remount is disallowed.
*
+ * - memcg: use_hierarchy is on by default and the cgroup file for
+ * the flag is not created.
+ *
* The followings are planned changes.
*
* - release_agent will be disallowed once replacement notification
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5814,6 +5814,7 @@ static struct cftype mem_cgroup_files[]
},
{
.name = "use_hierarchy",
+ .flags = CFTYPE_INSANE,
.write_u64 = mem_cgroup_hierarchy_write,
.read_u64 = mem_cgroup_hierarchy_read,
},
@@ -6784,6 +6785,21 @@ static void mem_cgroup_move_task(struct
}
#endif
+/*
+ * Cgroup retains root cgroups across [un]mount cycles making it necessary
+ * to verify sane_behavior flag on each mount attempt.
+ */
+static void mem_cgroup_bind(struct cgroup *root)
+{
+ /*
+ * use_hierarchy is forced with sane_behavior. cgroup core
+ * guarantees that @root doesn't have any children, so turning it
+ * on for the root memcg is enough.
+ */
+ if (cgroup_sane_behavior(root))
+ mem_cgroup_from_cont(root)->use_hierarchy = true;
+}
+
struct cgroup_subsys mem_cgroup_subsys = {
.name = "memory",
.subsys_id = mem_cgroup_subsys_id,
@@ -6794,6 +6810,7 @@ struct cgroup_subsys mem_cgroup_subsys =
.can_attach = mem_cgroup_can_attach,
.cancel_attach = mem_cgroup_cancel_attach,
.attach = mem_cgroup_move_task,
+ .bind = mem_cgroup_bind,
.base_cftypes = mem_cgroup_files,
.early_init = 0,
.use_id = 1,
next prev parent reply other threads:[~2013-04-15 20:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-12 23:10 [PATCHSET] cgroup, memcg: introduce sane_behavior mount option Tejun Heo
[not found] ` <1365808259-31073-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-04-12 23:10 ` [PATCH 1/4] cgroup: convert cgroupfs_root flag bits to masks and add CGRP_ prefix Tejun Heo
[not found] ` <1365808259-31073-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-04-15 0:56 ` Serge Hallyn
2013-04-12 23:10 ` [PATCH 2/4] move cgroupfs_root to include/linux/cgroup.h Tejun Heo
[not found] ` <1365808259-31073-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-04-15 1:02 ` Serge Hallyn
2013-04-12 23:10 ` [PATCH 3/4] cgroup: introduce sane_behavior mount option Tejun Heo
[not found] ` <1365808259-31073-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-04-15 1:05 ` Serge Hallyn
2013-04-15 2:49 ` Li Zefan
[not found] ` <516B6AAB.8010507-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-04-15 2:54 ` Tejun Heo
2013-04-15 2:50 ` [PATCHSET] cgroup, memcg: " Li Zefan
2013-04-15 3:17 ` Tejun Heo
[not found] ` <20130415031754.GG3050-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-04-15 14:46 ` Michal Hocko
2013-04-12 23:10 ` [PATCH 4/4] memcg: force use_hierarchy if sane_behavior Tejun Heo
[not found] ` <1365808259-31073-5-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-04-15 1:06 ` Serge Hallyn
2013-04-15 1:13 ` Serge Hallyn
2013-04-15 2:35 ` Michal Hocko
2013-04-15 2:39 ` Tejun Heo
[not found] ` <20130415023935.GE3050-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-04-15 5:29 ` Serge Hallyn
2013-04-15 14:42 ` Michal Hocko
2013-04-15 15:29 ` Kamezawa Hiroyuki
2013-04-15 20:40 ` Tejun Heo [this message]
[not found] ` <20130415204016.GA19531-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-04-15 20:57 ` [PATCH v2 " Michal Hocko
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=20130415204016.GA19531@mtj.dyndns.org \
--to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org \
--cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
--cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).