cgroup: cftype based file interface, take #2
Subsystems (10)
Tejun Heo
maintainerPATCH 1/1 cgroup: cftype based file interface, take #2
Hello,
This is the second take at improving cgroup file addition/removal interface. Changes from the last take[L] are,
* CGROUP_SUBSYS_CFTYPES[_COND]() dropped and cgroup_subsys->base_cftypes is added instead. This works better for subsystems implemented as module. tcp_memcontrol now uses an explicit __initcall() to register its cftypes.
* 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch added as cleanup.
* 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch added so that memsw files are always created if enabled in config as suggested by KAMEZAWA.
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use. This will also be useful for implementing unified hierarchy.
This patchset contains the following patches.
0001-cgroup-move-cgroup_clear_directory-call-out-of-cgrou.patch 0002-cgroup-build-list-of-all-cgroups-under-a-given-cgrou.patch 0003-cgroup-implement-cgroup_add_cftypes-and-friends.patch 0004-cgroup-merge-cft_release_agent-cftype-array-into-the.patch 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch 0006-cgroup-convert-all-non-memcg-controllers-to-the-new-.patch 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch 0008-cgroup-convert-memcg-controller-to-the-new-cftype-in.patch 0009-cgroup-remove-cgroup_add_file-s.patch 0010-cgroup-relocate-__d_cgrp-and-__d_cft.patch 0011-cgroup-introduce-struct-cfent.patch 0012-cgroup-implement-cgroup_rm_cftypes.patch
and is on top of
cgroup/for-3.4 3ce3230a0cff484e5130153f244d4fb8a56b3a8b
+ [1] cgroup: deprecate remount option changes mount option
and is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git cgroup-cftype
Glauber, I think the cftypes registration for tcp_memcontrol is fine as is in this patchset and we just need to move the init to the tail of ->create(). Let's worry about memcg for module-loadable protocols whey they are added. Can you please send a patch to move init to ->create()?
If nobody objects && after Li comes back and acks the changes, I'll route these through cgroup/for-3.5.
diffstat follows.
block/blk-cgroup.c | 45 ++--- include/linux/cgroup.h | 51 ++++-- kernel/cgroup.c | 359 +++++++++++++++++++++++++++++++++++----------- kernel/cgroup_freezer.c | 11 - kernel/cpuset.c | 31 +-- kernel/sched/core.c | 16 -- mm/memcontrol.c | 77 ++++----- net/core/netprio_cgroup.c | 30 +-- net/ipv4/tcp_memcontrol.c | 71 ++++----- net/sched/cls_cgroup.c | 31 +-- security/device_cgroup.c | 10 - 11 files changed, 437 insertions(+), 295 deletions(-)
Thanks.
--
tejun
[L] http://thread.gmane.org/gmane.linux.kernel.containers/22623
[1] http://thread.gmane.org/gmane.linux.kernel.cgroups/1192/focus=22611
Tejun Heo
maintainerPATCH 1/12 cgroup: move cgroup_clear_directory() call out of cgroup_populate_dir()
cgroup_populate_dir() currently clears all files and then repopulate the directory; however, the clearing part is only useful when it's called from cgroup_remount(). Relocate the invocation to cgroup_remount().
This is to prepare for further cgroup file handling updates.
--- kernel/cgroup.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
kernel/cgroup.c +2 -4
@@ -1313,7 +1313,8 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data) goto out_unlock; } -/* (re)populate subsystem files */ +/* clear out any existing files and repopulate subsystem files */ +cgroup_clear_directory (cgrp->dentry);cgroup_populate_dir (cgrp);if (opts.release_agent)
@@ -3648,9 +3649,6 @@ static int cgroup_populate_dir(struct cgroup *cgrp)int err;struct cgroup_subsys *ss; -/* First clear out any existing files */ -cgroup_clear_directory (cgrp->dentry); - err =cgroup_add_files (cgrp,NULL , files,ARRAY_SIZE (files));if (err <0 )return err;
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 2/12 cgroup: build list of all cgroups under a given cgroupfs_root
In reply to Tejun HeoBuild a list of all cgroups anchored at cgroupfs_root->allcg_list and going through cgroup->allcg_node. The list is protected by cgroup_mutex and will be used to improve cgroup file handling.
--- include/linux/cgroup.h | 2 ++ kernel/cgroup.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
include/linux/cgroup.h +2 -0
@@ -191,6 +191,8 @@ struct cgroup {*/ struct list_head css_sets; +struct list_head allcg_node;/* cgroupfs_root->allcg_list */ +/* * Linked list running through all cgroups that can * potentially be reaped by the release agent. Protected by
kernel/cgroup.c +10 -0
@@ -127,6 +127,9 @@ struct cgroupfs_root {/* A list running through the active hierarchies */ struct list_head root_list; +/* All cgroups on this root, cgroup_mutex protected */ +struct list_head allcg_list; +/* Hierarchy-specific flags */ unsigned long flags;
@@ -1350,11 +1353,14 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)static void init_cgroup_root (struct cgroupfs_root *root) {struct cgroup *cgrp = &root->top_cgroup; +INIT_LIST_HEAD (&root->subsys_list);INIT_LIST_HEAD (&root->root_list); +INIT_LIST_HEAD (&root->allcg_list); root->number_of_cgroups =1 ; cgrp->root = root; cgrp->top_cgroup = cgrp; +list_add_tail (&cgrp->allcg_node, &root->allcg_list);init_cgroup_housekeeping (cgrp); }
@@ -3794,6 +3800,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,/* The cgroup directory was pre-locked for us */ BUG_ON (!mutex_is_locked (&cgrp->dentry->d_inode->i_mutex)); +list_add_tail (&cgrp->allcg_node, &root->allcg_list); + err =cgroup_populate_dir (cgrp);/* If err < 0, we have a half-filled directory - oh well ;) */
@@ -4002,6 +4010,8 @@ again:list_del_init (&cgrp->sibling);cgroup_unlock_hierarchy (cgrp->root); +list_del_init (&cgrp->allcg_node); + d =dget (cgrp->dentry);cgroup_d_remove_dir (d);
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 3/12 cgroup: implement cgroup_add_cftypes() and friends
In reply to Tejun HeoCurrently, cgroup directories are populated by subsys->populate() callback explicitly creating files on each cgroup creation. This level of flexibility isn't needed or desirable. It provides largely unused flexibility which call for abuses while severely limiting what the core layer can do through the lack of structure and conventions.
Per each cgroup file type, the only distinction that cgroup users is making is whether a cgroup is root or not, which can easily be expressed with flags.
This patch introduces cgroup_add_cftypes(). These deal with cftypes instead of individual files - controllers indicate that certain types of files exist for certain subsystem. Newly added CFTYPE_*_ON_ROOT flags indicate whether a cftype should be excluded or created only on the root cgroup.
cgroup_add_cftypes() can be called any time whether the target subsystem is currently attached or not. cgroup core will create files on the existing cgroups as necessary.
Also, cgroup_subsys->base_cftypes is added to ease registration of the base files for the subsystem. If non-NULL on subsys init, the cftypes pointed to by ->base_cftypes are automatically registered on subsys init / load.
Further patches will convert the existing users and remove the file based interface. Note that this interface allows dynamic addition of files to an active controller. This will be used for sub-controller modularity and unified hierarchy in the longer term.
This patch implements the new mechanism but doesn't apply it to any user.
v2: replaced DECLARE_CGROUP_CFTYPES[_COND]() with
cgroup_subsys->base_cftypes, which works better for cgroup_subsys which is loaded as module.
--- include/linux/cgroup.h | 33 +++++++++++- kernel/cgroup.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 162 insertions(+), 3 deletions(-)
include/linux/cgroup.h +31 -2
@@ -192,6 +192,7 @@ struct cgroup {struct list_head css_sets;struct list_head allcg_node;/* cgroupfs_root->allcg_list */ +struct list_head cft_q_node;/* used during cftype add/rm */ /* * Linked list running through all cgroups that can
@@ -277,11 +278,17 @@ struct cgroup_map_cb {* - the 'cftype' of the file is file->f_dentry->d_fsdata */ -#define MAX_CFTYPE_NAME 64 +/* cftype->flags */ +#define CFTYPE_ONLY_ON_ROOT (1U << 0)/* only create on root cg */ +#define CFTYPE_NOT_ON_ROOT (1U << 1)/* don't create onp root cg */ + +#define MAX_CFTYPE_NAME 64 +struct cftype {/* * By convention, the name should begin with the name of the -* subsystem, followed by a period +* subsystem, followed by a period. Zero length string indicates +* end of cftype array. */ char name[MAX_CFTYPE_NAME ];int private;
@@ -297,6 +304,9 @@ struct cftype {*/ size_t max_write_len; +/* CFTYPE_* flags */ +unsigned int flags; +int (*open)(struct inode *inode,struct file *file); ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft, struct file *file,
@@ -375,6 +385,16 @@ struct cftype { struct eventfd_ctx *eventfd); }; +/* +* cftype_sets describe cftypes belonging to a subsystem and are chained at +* cgroup_subsys->cftsets. Each cftset points to an array of cftypes +* terminated by zero length name. +*/ +struct cftype_set { +struct list_head node;/* chained at subsys->cftsets */ +const struct cftype *cfts; +}; +struct cgroup_scanner {struct cgroup *cg;int (*test_task)(struct task_struct *p,struct cgroup_scanner *scan);
@@ -400,6 +420,8 @@ int cgroup_add_files(struct cgroup *cgrp,const struct cftype cft[], int count); +int cgroup_add_cftypes (struct cgroup_subsys *ss,const struct cftype *cfts); +int cgroup_is_removed (const struct cgroup *cgrp);int cgroup_path (const struct cgroup *cgrp,char *buf,int buflen);
@@ -502,6 +524,13 @@ struct cgroup_subsys {struct idr idr;rwlock_t id_lock; +/* list of cftype_sets */ +struct list_head cftsets; + +/* base cftypes, automatically [de]registered with subsys itself */ +struct cftype *base_cftypes; +struct cftype_set base_cftset; +/* should be defined only by modular subsystems */ struct module *module; };
kernel/cgroup.c +131 -1
173 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 4/12 cgroup: merge cft_release_agent cftype array into the base files array
In reply to Tejun HeoNow that cftype can express whether a file should only be on root, cft_release_agent can be merged into the base files cftypes array.
--- kernel/cgroup.c | 19 +++++++------------ 1 files changed, 7 insertions(+), 12 deletions(-)
kernel/cgroup.c +7 -12
@@ -3736,13 +3736,13 @@ static struct cftype files[] = { .read_u64 = cgroup_clone_children_read, .write_u64 = cgroup_clone_children_write, }, -}; - -static struct cftype cft_release_agent = { - .name ="release_agent" , - .read_seq_string = cgroup_release_agent_show, - .write_string = cgroup_release_agent_write, - .max_write_len =PATH_MAX , + { + .name = "release_agent", + .flags = CFTYPE_ONLY_ON_ROOT, + .read_seq_string = cgroup_release_agent_show, + .write_string = cgroup_release_agent_write, + .max_write_len = PATH_MAX, + }, };static int cgroup_populate_dir (struct cgroup *cgrp)
@@ -3754,11 +3754,6 @@ static int cgroup_populate_dir(struct cgroup *cgrp)if (err <0 )return err; -if (cgrp == cgrp->top_cgroup) { -if ((err =cgroup_add_file (cgrp,NULL , &cft_release_agent)) <0 ) -return err; - } -/* process cftsets of each subsystem */ for_each_subsys (cgrp->root, ss) {struct cftype_set *set;
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 5/12 cgroup: relocate cftype and cgroup_subsys definitions in controllers
In reply to Tejun Heoblk-cgroup, netprio_cgroup, cls_cgroup and tcp_memcontrol unnecessarily define cftype array and cgroup_subsys structures at the top of the file, which is unconventional and necessiates forward declaration of methods.
This patch relocates those below the definitions of the methods and removes the forward declarations. Note that forward declaration of tcp_files[] is added in tcp_memcontrol.c for tcp_init_cgroup(). This will be removed soon by another patch.
This patch doesn't introduce any functional change.
--- block/blk-cgroup.c | 38 ++++++++++++----------------- net/core/netprio_cgroup.c | 26 ++++++++------------ net/ipv4/tcp_memcontrol.c | 57 +++++++++++++++++++++----------------------- net/sched/cls_cgroup.c | 27 ++++++++------------ 4 files changed, 65 insertions(+), 83 deletions(-)
block/blk-cgroup.c +16 -22
@@ -28,34 +28,12 @@ static LIST_HEAD(blkio_list);struct blkio_cgroup blkio_root_cgroup = { .weight =2 *BLKIO_WEIGHT_DEFAULT };EXPORT_SYMBOL_GPL (blkio_root_cgroup); -static struct cgroup_subsys_state *blkiocg_create (struct cgroup *); -static int blkiocg_can_attach (struct cgroup *,struct cgroup_taskset *); -static void blkiocg_attach (struct cgroup *,struct cgroup_taskset *); -static void blkiocg_destroy (struct cgroup *); -static int blkiocg_populate (struct cgroup_subsys *,struct cgroup *); -/* for encoding cft->private value on file */ #define BLKIOFILE_PRIVATE (x, val) (((x) << 16) | (val))/* What policy owns the file, proportional or throttle */ #define BLKIOFILE_POLICY (val) (((val) >> 16) & 0xffff)#define BLKIOFILE_ATTR (val) ((val) & 0xffff) -struct cgroup_subsys blkio_subsys = { - .name ="blkio" , - .create = blkiocg_create, - .can_attach = blkiocg_can_attach, - .attach = blkiocg_attach, - .destroy = blkiocg_destroy, - .populate = blkiocg_populate, -#ifdef CONFIG_BLK_CGROUP -/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ - .subsys_id = blkio_subsys_id, -#endif - .use_id =1 , - .module =THIS_MODULE , -}; -EXPORT_SYMBOL_GPL (blkio_subsys); -static inline void blkio_policy_insert_node (struct blkio_cgroup *blkcg,struct blkio_policy_node *pn) {
@@ -1658,6 +1636,22 @@ static void blkiocg_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) } } +struct cgroup_subsys blkio_subsys = { + .name ="blkio" , + .create = blkiocg_create, + .can_attach = blkiocg_can_attach, + .attach = blkiocg_attach, + .destroy = blkiocg_destroy, + .populate = blkiocg_populate, +#ifdef CONFIG_BLK_CGROUP +/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ + .subsys_id = blkio_subsys_id, +#endif + .use_id =1 , + .module =THIS_MODULE , +}; +EXPORT_SYMBOL_GPL (blkio_subsys); +void blkio_policy_register (struct blkio_policy_type *blkiop) {spin_lock (&blkio_list_lock);
net/core/netprio_cgroup.c +11 -15
@@ -23,21 +23,6 @@#include <net/sock.h> #include <net/netprio_cgroup.h> -static struct cgroup_subsys_state *cgrp_create (struct cgroup *cgrp); -static void cgrp_destroy (struct cgroup *cgrp); -static int cgrp_populate (struct cgroup_subsys *ss,struct cgroup *cgrp); - -struct cgroup_subsys net_prio_subsys = { - .name ="net_prio" , - .create = cgrp_create, - .destroy = cgrp_destroy, - .populate = cgrp_populate, -#ifdef CONFIG_NETPRIO_CGROUP - .subsys_id = net_prio_subsys_id, -#endif - .module =THIS_MODULE -}; -#define PRIOIDX_SZ 128static unsigned long prioidx_map[PRIOIDX_SZ ];
@@ -263,6 +248,17 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)return cgroup_add_files (cgrp, ss, ss_files,ARRAY_SIZE (ss_files)); } +struct cgroup_subsys net_prio_subsys = { + .name ="net_prio" , + .create = cgrp_create, + .destroy = cgrp_destroy, + .populate = cgrp_populate, +#ifdef CONFIG_NETPRIO_CGROUP + .subsys_id = net_prio_subsys_id, +#endif + .module =THIS_MODULE +}; +static int netprio_device_event (struct notifier_block *unused,unsigned long event,void *ptr) {
net/ipv4/tcp_memcontrol.c +27 -30
66 lines not on this page · raw message
net/sched/cls_cgroup.c +11 -16
@@ -22,22 +22,6 @@#include <net/sock.h> #include <net/cls_cgroup.h> -static struct cgroup_subsys_state *cgrp_create (struct cgroup *cgrp); -static void cgrp_destroy (struct cgroup *cgrp); -static int cgrp_populate (struct cgroup_subsys *ss,struct cgroup *cgrp); - -struct cgroup_subsys net_cls_subsys = { - .name ="net_cls" , - .create = cgrp_create, - .destroy = cgrp_destroy, - .populate = cgrp_populate, -#ifdef CONFIG_NET_CLS_CGROUP - .subsys_id = net_cls_subsys_id, -#endif - .module =THIS_MODULE , -}; - -static inline struct cgroup_cls_state *cgrp_cls_state (struct cgroup *cgrp) { return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id),
@@ -93,6 +77,17 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)return cgroup_add_files (cgrp, ss, ss_files,ARRAY_SIZE (ss_files)); } +struct cgroup_subsys net_cls_subsys = { + .name ="net_cls" , + .create = cgrp_create, + .destroy = cgrp_destroy, + .populate = cgrp_populate, +#ifdef CONFIG_NET_CLS_CGROUP + .subsys_id = net_cls_subsys_id, +#endif + .module =THIS_MODULE , +}; +struct cls_cgroup_head {u32 handle;struct tcf_exts exts;
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 6/12 cgroup: convert all non-memcg controllers to the new cftype interface
In reply to Tejun HeoConvert debug, freezer, cpuset, cpu_cgroup, cpuacct, net_prio, blkio, net_cls and device controllers to use the new cftype based interface. Termination entry is added to cftype arrays and populate callbacks are replaced with cgroup_subsys->base_cftypes initializations.
This is functionally identical transformation. There shouldn't be any visible behavior change.
memcg is rather special and will be converted separately.
--- block/blk-cgroup.c | 9 ++------- kernel/cgroup.c | 10 +++------- kernel/cgroup_freezer.c | 11 +++-------- kernel/cpuset.c | 31 ++++++++++--------------------- kernel/sched/core.c | 16 ++++------------ net/core/netprio_cgroup.c | 8 ++------ net/sched/cls_cgroup.c | 8 ++------ security/device_cgroup.c | 10 ++-------- 8 files changed, 28 insertions(+), 75 deletions(-)
block/blk-cgroup.c +2 -7
@@ -1515,14 +1515,9 @@ struct cftype blkio_files[] = { .read_map = blkiocg_file_read_map, },#endif + { }/* terminate */ }; -static int blkiocg_populate (struct cgroup_subsys *subsys,struct cgroup *cgroup) -{ -return cgroup_add_files (cgroup, subsys, blkio_files, -ARRAY_SIZE (blkio_files)); -} -static void blkiocg_destroy (struct cgroup *cgroup) {struct blkio_cgroup *blkcg =cgroup_to_blkio_cgroup (cgroup);
@@ -1642,11 +1637,11 @@ struct cgroup_subsys blkio_subsys = { .can_attach = blkiocg_can_attach, .attach = blkiocg_attach, .destroy = blkiocg_destroy, - .populate = blkiocg_populate, #ifdef CONFIG_BLK_CGROUP/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ .subsys_id = blkio_subsys_id, #endif + .base_cftypes = blkio_files, .use_id = 1, .module = THIS_MODULE, };
kernel/cgroup.c +3 -7
@@ -5354,19 +5354,15 @@ static struct cftype debug_files[] = { .name = "releasable", .read_u64 = releasable_read, }, -}; -static int debug_populate (struct cgroup_subsys *ss,struct cgroup *cont) -{ -return cgroup_add_files (cont, ss, debug_files, -ARRAY_SIZE (debug_files)); -} + { }/* terminate */ +};struct cgroup_subsys debug_subsys = { .name ="debug" , .create = debug_create, .destroy = debug_destroy, - .populate = debug_populate, .subsys_id = debug_subsys_id, + .base_cftypes = debug_files, };#endif /* CONFIG_CGROUP_DEBUG */
kernel/cgroup_freezer.c +3 -8
@@ -358,24 +358,19 @@ static int freezer_write(struct cgroup *cgroup,static struct cftype files[] = { { .name ="state" , + .flags =CFTYPE_NOT_ON_ROOT , .read_seq_string = freezer_read, .write_string = freezer_write, }, + { }/* terminate */ }; -static int freezer_populate (struct cgroup_subsys *ss,struct cgroup *cgroup) -{ -if (!cgroup->parent) -return 0 ; -return cgroup_add_files (cgroup, ss, files,ARRAY_SIZE (files)); -} -struct cgroup_subsys freezer_subsys = { .name ="freezer" , .create = freezer_create, .destroy = freezer_destroy, - .populate = freezer_populate, .subsys_id = freezer_subsys_id, .can_attach = freezer_can_attach, .fork = freezer_fork, + .base_cftypes = files, };
kernel/cpuset.c +10 -21
@@ -1792,28 +1792,17 @@ static struct cftype files[] = { .write_u64 = cpuset_write_u64, .private = FILE_SPREAD_SLAB, }, -}; - -static struct cftype cft_memory_pressure_enabled = { - .name ="memory_pressure_enabled" , - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private =FILE_MEMORY_PRESSURE_ENABLED , -}; -static int cpuset_populate (struct cgroup_subsys *ss,struct cgroup *cont) -{ -int err; + { + .name = "memory_pressure_enabled", + .flags = CFTYPE_ONLY_ON_ROOT, + .read_u64 = cpuset_read_u64, + .write_u64 = cpuset_write_u64, + .private = FILE_MEMORY_PRESSURE_ENABLED, + }, - err =cgroup_add_files (cont, ss, files,ARRAY_SIZE (files)); -if (err) -return err; -/* memory_pressure_enabled is in root cpuset only */ -if (!cont->parent) - err =cgroup_add_file (cont, ss, - &cft_memory_pressure_enabled); -return err; -} + { }/* terminate */ +};/* * post_clone() is called during cgroup_create() when the
@@ -1914,9 +1903,9 @@ struct cgroup_subsys cpuset_subsys = { .destroy = cpuset_destroy, .can_attach = cpuset_can_attach, .attach = cpuset_attach, - .populate = cpuset_populate, .post_clone = cpuset_post_clone, .subsys_id = cpuset_subsys_id, + .base_cftypes = files, .early_init = 1, };
kernel/sched/core.c +4 -12
@@ -7902,13 +7902,9 @@ static struct cftype cpu_files[] = { .write_u64 = cpu_rt_period_write_uint, },#endif + { }/* terminate */ }; -static int cpu_cgroup_populate (struct cgroup_subsys *ss,struct cgroup *cont) -{ -return cgroup_add_files (cont, ss, cpu_files,ARRAY_SIZE (cpu_files)); -} -struct cgroup_subsys cpu_cgroup_subsys = { .name ="cpu" , .create = cpu_cgroup_create,
@@ -7916,8 +7912,8 @@ struct cgroup_subsys cpu_cgroup_subsys = { .can_attach = cpu_cgroup_can_attach, .attach = cpu_cgroup_attach, .exit = cpu_cgroup_exit, - .populate = cpu_cgroup_populate, .subsys_id = cpu_cgroup_subsys_id, + .base_cftypes = cpu_files, .early_init = 1, };
@@ -8102,13 +8098,9 @@ static struct cftype files[] = { .name = "stat", .read_map = cpuacct_stats_show, }, + { }/* terminate */ }; -static int cpuacct_populate (struct cgroup_subsys *ss,struct cgroup *cgrp) -{ -return cgroup_add_files (cgrp, ss, files,ARRAY_SIZE (files)); -} -/* * charge this task's execution time to its accounting group. *
@@ -8140,7 +8132,7 @@ struct cgroup_subsys cpuacct_subsys = { .name = "cpuacct", .create = cpuacct_create, .destroy = cpuacct_destroy, - .populate = cpuacct_populate, .subsys_id = cpuacct_subsys_id, + .base_cftypes = files, };#endif /* CONFIG_CGROUP_CPUACCT */
net/core/netprio_cgroup.c +2 -6
@@ -241,21 +241,17 @@ static struct cftype ss_files[] = { .read_map = read_priomap, .write_string = write_priomap, }, + { }/* terminate */ }; -static int cgrp_populate (struct cgroup_subsys *ss,struct cgroup *cgrp) -{ -return cgroup_add_files (cgrp, ss, ss_files,ARRAY_SIZE (ss_files)); -} -struct cgroup_subsys net_prio_subsys = { .name ="net_prio" , .create = cgrp_create, .destroy = cgrp_destroy, - .populate = cgrp_populate, #ifdef CONFIG_NETPRIO_CGROUP .subsys_id = net_prio_subsys_id, #endif + .base_cftypes = ss_files, .module =THIS_MODULE };
net/sched/cls_cgroup.c +2 -6
@@ -70,21 +70,17 @@ static struct cftype ss_files[] = { .read_u64 = read_classid, .write_u64 = write_classid, }, + { }/* terminate */ }; -static int cgrp_populate (struct cgroup_subsys *ss,struct cgroup *cgrp) -{ -return cgroup_add_files (cgrp, ss, ss_files,ARRAY_SIZE (ss_files)); -} -struct cgroup_subsys net_cls_subsys = { .name ="net_cls" , .create = cgrp_create, .destroy = cgrp_destroy, - .populate = cgrp_populate, #ifdef CONFIG_NET_CLS_CGROUP .subsys_id = net_cls_subsys_id, #endif + .base_cftypes = ss_files, .module =THIS_MODULE , };
security/device_cgroup.c +2 -8
@@ -447,22 +447,16 @@ static struct cftype dev_cgroup_files[] = { .read_seq_string = devcgroup_seq_read, .private = DEVCG_LIST, }, + { }/* terminate */ }; -static int devcgroup_populate (struct cgroup_subsys *ss, -struct cgroup *cgroup) -{ -return cgroup_add_files (cgroup, ss, dev_cgroup_files, -ARRAY_SIZE (dev_cgroup_files)); -} -struct cgroup_subsys devices_subsys = { .name ="devices" , .can_attach = devcgroup_can_attach, .create = devcgroup_create, .destroy = devcgroup_destroy, - .populate = devcgroup_populate, .subsys_id = devices_subsys_id, + .base_cftypes = dev_cgroup_files, };int __devcgroup_inode_permission (struct inode *inode,int mask)
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 7/12 memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP
In reply to Tejun HeoInstead of conditioning creation of memsw files on do_swap_account, always create the files if compiled-in and fail read/write attempts with -EOPNOTSUPP if !do_swap_account.
This is suggested by KAMEZAWA to simplify memcg file creation so that it can use cgroup->subsys_cftypes.
--- mm/memcontrol.c | 65 ++++++++++++++++++++++++++---------------------------- 1 files changed, 31 insertions(+), 34 deletions(-)
mm/memcontrol.c +31 -34
@@ -3818,14 +3818,21 @@ static inline u64 mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)return val <<PAGE_SHIFT ; } -static u64 mem_cgroup_read (struct cgroup *cont,struct cftype *cft) +static ssize_t mem_cgroup_read (struct cgroup *cont,struct cftype *cft, +struct file *file,char __user *buf, +size_t nbytes,loff_t *ppos) {struct mem_cgroup *memcg =mem_cgroup_from_cont (cont); +char str[64 ];u64 val; -int type, name; +int type, name, len; type =MEMFILE_TYPE (cft->private); name =MEMFILE_ATTR (cft->private); + +if (!do_swap_account && type == _MEMSWAP) +return -EOPNOTSUPP ; +switch (type) {case _MEM:if (name ==RES_USAGE )
@@ -3843,7 +3850,9 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)BUG ();break ; } -return val; + + len =scnprintf (str,sizeof (str),"%llu\n" , (unsigned long long )val); +return simple_read_from_buffer (buf, nbytes, ppos, str, len); }/* * The user of this function is...
@@ -3859,6 +3868,10 @@ static int mem_cgroup_write(struct cgroup *cont, struct cftype *cft, type =MEMFILE_TYPE (cft->private); name =MEMFILE_ATTR (cft->private); + +if (!do_swap_account && type == _MEMSWAP) +return -EOPNOTSUPP ; +switch (name) {case RES_LIMIT :if (mem_cgroup_is_root (memcg)) {/* Can't set limit on root */
@@ -3925,12 +3938,15 @@ out:static int mem_cgroup_reset (struct cgroup *cont,unsigned int event) { -struct mem_cgroup *memcg; +struct mem_cgroup *memcg =mem_cgroup_from_cont (cont);int type, name; - memcg =mem_cgroup_from_cont (cont); type =MEMFILE_TYPE (event); name =MEMFILE_ATTR (event); + +if (!do_swap_account && type == _MEMSWAP) +return -EOPNOTSUPP ; +switch (name) {case RES_MAX_USAGE :if (type == _MEM)
@@ -4599,7 +4615,7 @@ static struct cftype mem_cgroup_files[] = { { .name = "usage_in_bytes", .private = MEMFILE_PRIVATE(_MEM, RES_USAGE), - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, .register_event = mem_cgroup_usage_register_event, .unregister_event = mem_cgroup_usage_unregister_event, },
@@ -4607,25 +4623,25 @@ static struct cftype mem_cgroup_files[] = { .name = "max_usage_in_bytes", .private = MEMFILE_PRIVATE(_MEM, RES_MAX_USAGE), .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "limit_in_bytes", .private = MEMFILE_PRIVATE(_MEM, RES_LIMIT), .write_string = mem_cgroup_write, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "soft_limit_in_bytes", .private = MEMFILE_PRIVATE(_MEM, RES_SOFT_LIMIT), .write_string = mem_cgroup_write, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "failcnt", .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT), .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "stat",
@@ -4665,14 +4681,11 @@ static struct cftype mem_cgroup_files[] = { .mode = S_IRUGO, },#endif -}; - #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP -static struct cftype memsw_cgroup_files[] = { { .name = "memsw.usage_in_bytes", .private = MEMFILE_PRIVATE(_MEMSWAP, RES_USAGE), - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, .register_event = mem_cgroup_usage_register_event, .unregister_event = mem_cgroup_usage_unregister_event, },
@@ -4680,35 +4693,22 @@ static struct cftype memsw_cgroup_files[] = { .name = "memsw.max_usage_in_bytes", .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE), .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "memsw.limit_in_bytes", .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT), .write_string = mem_cgroup_write, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "memsw.failcnt", .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT), .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, -}; - -static int register_memsw_files(struct cgroup *cont, struct cgroup_subsys *ss) -{ - if (!do_swap_account) - return 0; - return cgroup_add_files(cont, ss, memsw_cgroup_files, - ARRAY_SIZE(memsw_cgroup_files)); -}; -#else -static int register_memsw_files(struct cgroup *cont, struct cgroup_subsys *ss) -{ - return 0; -} #endif +}; static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) {
@@ -4969,9 +4969,6 @@ static int mem_cgroup_populate(struct cgroup_subsys *ss, ARRAY_SIZE(mem_cgroup_files));if (!ret) - ret =register_memsw_files (cont, ss); - -if (!ret) ret =register_kmem_files (cont, ss);return ret;
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 8/12 cgroup: convert memcg controller to the new cftype interface
In reply to Tejun HeoConvert memcg to use the new cftype based interface. kmem support abuses ->populate() for mem_cgroup_sockets_init() so it can't be removed at the moment.
tcp_memcontrol is updated so that tcp_files[] is registered via a __initcall. This change also allows removing the forward declaration of tcp_files[]. Removed.
--- mm/memcontrol.c | 12 +++--------- net/ipv4/tcp_memcontrol.c | 16 ++++++++++------ 2 files changed, 13 insertions(+), 15 deletions(-)
mm/memcontrol.c +3 -9
@@ -4708,6 +4708,7 @@ static struct cftype mem_cgroup_files[] = { .read = mem_cgroup_read, },#endif + { }, /* terminate */ };static int alloc_mem_cgroup_per_zone_info (struct mem_cgroup *memcg,int node)
@@ -4963,15 +4964,7 @@ static void mem_cgroup_destroy(struct cgroup *cont)static int mem_cgroup_populate (struct cgroup_subsys *ss,struct cgroup *cont) { -int ret; - - ret =cgroup_add_files (cont, ss, mem_cgroup_files, -ARRAY_SIZE (mem_cgroup_files)); - -if (!ret) - ret =register_kmem_files (cont, ss); - -return ret; +return register_kmem_files (cont, ss); }#ifdef CONFIG_MMU
@@ -5485,6 +5478,7 @@ struct cgroup_subsys mem_cgroup_subsys = { .can_attach = mem_cgroup_can_attach, .cancel_attach = mem_cgroup_cancel_attach, .attach = mem_cgroup_move_task, + .base_cftypes = mem_cgroup_files, .early_init = 0, .use_id = 1, };
net/ipv4/tcp_memcontrol.c +10 -6
@@ -6,8 +6,6 @@#include <linux/memcontrol.h> #include <linux/module.h> -static struct cftype tcp_files[4 ];/* XXX: will be removed soon */ -static inline struct tcp_memcontrol *tcp_from_cgproto (struct cg_proto *cg_proto) { return container_of(cg_proto, struct tcp_memcontrol, cg_proto);
@@ -36,7 +34,7 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) cg_proto = tcp_prot.proto_cgroup (memcg);if (!cg_proto) - goto create_files; +return 0 ; tcp =tcp_from_cgproto (cg_proto);
@@ -59,9 +57,7 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) cg_proto->sockets_allocated = &tcp->tcp_sockets_allocated; cg_proto->memcg = memcg; -create_files: -return cgroup_add_files (cgrp, ss, tcp_files, -ARRAY_SIZE (tcp_files)); +return 0 ; }EXPORT_SYMBOL (tcp_init_cgroup);
@@ -266,4 +262,12 @@ static struct cftype tcp_files[] = { .trigger = tcp_cgroup_reset, .read_u64 = tcp_cgroup_read, }, + { }/* terminate */ }; + +static int __init tcp_memcontrol_init (void ) +{ +WARN_ON (cgroup_add_cftypes (&mem_cgroup_subsys, tcp_files)); +return 0 ; +} +__initcall (tcp_memcontrol_init);
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 9/12 cgroup: remove cgroup_add_file[s]()
In reply to Tejun HeoNo controller is using cgroup_add_files[s](). Unexport them, and convert cgroup_add_files() to handle NULL entry terminated array instead of taking count explicitly and continue creation on failure for internal use.
--- include/linux/cgroup.h | 16 --------------- kernel/cgroup.c | 51 ++++++++++++++++++----------------------------- 2 files changed, 20 insertions(+), 47 deletions(-)
include/linux/cgroup.h +0 -16
@@ -404,22 +404,6 @@ struct cgroup_scanner {void *data; }; -/* -* Add a new file to the given cgroup directory. Should only be -* called by subsystems from within a populate() method -*/ -int cgroup_add_file (struct cgroup *cgrp,struct cgroup_subsys *subsys, -const struct cftype *cft); - -/* -* Add a set of new files to the given cgroup directory. Should -* only be called by subsystems from within a populate() method -*/ -int cgroup_add_files (struct cgroup *cgrp, -struct cgroup_subsys *subsys, -const struct cftype cft[], -int count); -int cgroup_add_cftypes (struct cgroup_subsys *ss,const struct cftype *cfts);int cgroup_is_removed (const struct cgroup *cgrp);
kernel/cgroup.c +20 -31
97 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 10/12 cgroup: relocate __d_cgrp() and __d_cft()
In reply to Tejun HeoMove the two macros upwards as they'll be used earlier in the file.
--- kernel/cgroup.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
kernel/cgroup.c +10 -10
@@ -282,6 +282,16 @@ list_for_each_entry(_ss, &_root->subsys_list, sibling)#define for_each_active_root (_root) \ list_for_each_entry(_root, &roots, root_list) +static inline struct cgroup *__d_cgrp (struct dentry *dentry) +{ +return dentry->d_fsdata; +} + +static inline struct cftype *__d_cft (struct dentry *dentry) +{ +return dentry->d_fsdata; +} +/* the list of cgroups eligible for automatic release. Protected by * release_list_lock */ static LIST_HEAD (release_list);
@@ -1708,16 +1718,6 @@ static struct file_system_type cgroup_fs_type = {static struct kobject *cgroup_kobj; -static inline struct cgroup *__d_cgrp (struct dentry *dentry) -{ -return dentry->d_fsdata; -} - -static inline struct cftype *__d_cft (struct dentry *dentry) -{ -return dentry->d_fsdata; -} -/** * cgroup_path - generate the path of a cgroup * @cgrp: the cgroup in question
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 11/12 cgroup: introduce struct cfent
In reply to Tejun HeoThis patch adds cfent (cgroup file entry) which is the association between a cgroup and a file. This is in-cgroup representation of files under a cgroup directory. This simplifies walking walking cgroup files and thus cgroup_clear_directory(), which is now implemented in two parts - cgroup_rm_file() and a loop around it.
cgroup_rm_file() will be used to implement cftype removal and cfent is scheduled to serve cgroup specific per-file data (e.g. for sysfs-like "sever" semantics).
v2: - cfe was freed from cgroup_rm_file() which led to use-after-free
if the file had openers at the time of removal. Moved to cgroup_diput().
- cgroup_clear_directory() triggered WARN_ON_ONCE() if d_subdirs wasn't empty after removing all files. This triggered spuriously if some files were open during directory clearing. Removed.
--- include/linux/cgroup.h | 1 + kernel/cgroup.c | 111 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 76 insertions(+), 36 deletions(-)
include/linux/cgroup.h +1 -0
@@ -175,6 +175,7 @@ struct cgroup {*/ struct list_head sibling;/* my parent's children */ struct list_head children;/* my children */ +struct list_head files;/* my files */ struct cgroup *parent;/* my parent */ struct dentry __rcu *dentry;/* cgroup fs entry, RCU protected */
kernel/cgroup.c +75 -36
162 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Tejun Heo
maintainerPATCH 12/12 cgroup: implement cgroup_rm_cftypes()
In reply to Tejun HeoImplement cgroup_rm_cftypes() which removes an array of cftypes from a subsystem. It can be called whether the target subsys is attached or not. cgroup core will remove the specified file from all existing cgroups.
This will be used to improve sub-subsys modularity and will be helpful for unified hierarchy.
--- include/linux/cgroup.h | 1 + kernel/cgroup.c | 54 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 10 deletions(-)
include/linux/cgroup.h +1 -0
@@ -406,6 +406,7 @@ struct cgroup_scanner { };int cgroup_add_cftypes (struct cgroup_subsys *ss,const struct cftype *cfts); +int cgroup_rm_cftypes (struct cgroup_subsys *ss,const struct cftype *cfts);int cgroup_is_removed (const struct cgroup *cgrp);
kernel/cgroup.c +44 -10
102 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Re: [PATCH 07/12] memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP
In reply to Tejun HeoQuoted 9 lines · Tejun Heo
Instead of conditioning creation of memsw files on
do_swap_account, always create the files if compiled-in and fail read/write attempts with-EOPNOTSUPPif !do_swap_account.This is suggested by KAMEZAWA to simplify memcg file creation so that it can use
cgroup->subsys_cftypes.Signed-off-by Tejun Heo <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>
seems O.K. to me.
KAMEZAWA Hiroyuki
Acked-byRe: [PATCH 07/12] memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP
In reply to a message not in the archiveQuoted 9 lines · Tejun Heo
Instead of conditioning creation of memsw files on
do_swap_account, always create the files if compiled-in and fail read/write attempts with-EOPNOTSUPPif !do_swap_account.This is suggested by KAMEZAWA to simplify memcg file creation so that it can use
cgroup->subsys_cftypes.Signed-off-by Tejun Heo <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>
seems O.K. to me.
Re: [PATCH 08/12] cgroup: convert memcg controller to the new cftype interface
In reply to Tejun HeoQuoted 8 lines · Tejun Heo
Convert memcg to use the new cftype based interface. kmem support abuses ->populate() for
mem_cgroup_sockets_init()so it can't be removed at the moment.
tcp_memcontrolis updated so that tcp_files[] is registered via a__initcall. This change also allows removing the forward declaration of tcp_files[]. Removed.
Quoted 8 lines
Signed-off-by Tejun Heo <[email protected]>Cc Johannes Weiner <[email protected]>Cc Michal Hocko <[email protected]>Cc Balbir Singh <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Glauber Costa <[email protected]>Cc Hugh Dickins <[email protected]>Cc Greg Thelen <[email protected]>
Ok, then, files will be created by cgroup core not by memcg. base_cftypes seems very good.
Thank you.
Quoted 2 lines · Tejun Heo
Can you please send a patch to move init to
->create()?
Yes.
Quoted 2 lines · Tejun Heo
Can you please send a patch to move init to
->create()?
Yes.
Quoted 17 lines · Tejun Heo
Hello,
This is the second take at improving cgroup file addition/removal interface. Changes from the last take[L] are,
* CGROUP_SUBSYS_CFTYPES[_COND]() dropped and
cgroup_subsys->base_cftypesis added instead. This works better for subsystems implemented as module.tcp_memcontrolnow uses an explicit__initcall()to register its cftypes.* 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch added as cleanup.
* 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch added so that memsw files are always created if enabled in config as suggested by KAMEZAWA.
Quoted 6 lines
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
What's the problem with remount? and is it important enough that it should be fixed even the feature is marked as deprecated?
Quoted 4 lines
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use.
Dynamic cgroup files was mentioned before. The scenario in mind was blkio control files can be added/removed automatically as devices come and ago.
So this time blkio subsystem is really going to be made more dynamic soon?
Quoted 6 lines
This will also be useful for implementing unified hierarchy.
This patchset contains the following patches.
I'll look into the patches tomorrow.
Quoted 30 lines
0001-cgroup-move-cgroup_clear_directory-call-out-of-cgrou.patch 0002-cgroup-build-list-of-all-cgroups-under-a-given-cgrou.patch 0003-cgroup-implement-cgroup_add_cftypes-and-friends.patch 0004-cgroup-merge-cft_release_agent-cftype-array-into-the.patch 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch 0006-cgroup-convert-all-non-memcg-controllers-to-the-new-.patch 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch 0008-cgroup-convert-memcg-controller-to-the-new-cftype-in.patch 0009-cgroup-remove-cgroup_add_file-s.patch 0010-cgroup-relocate-__d_cgrp-and-__d_cft.patch 0011-cgroup-introduce-struct-cfent.patch 0012-cgroup-implement-cgroup_rm_cftypes.patch
and is on top of
cgroup/for-3.4
3ce3230a0cff484e5130153f244d4fb8a56b3a8b
+ [1] cgroup: deprecate remount option changes mount optionand is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftypeGlauber, I think the cftypes registration for
tcp_memcontrolis fine as is in this patchset and we just need to move the init to the tail of ->create(). Let's worry about memcg for module-loadable protocols whey they are added. Can you please send a patch to move init to ->create()?If nobody objects && after Li comes back and acks the changes, I'll route these through cgroup/for-3.5.
Quoted 17 lines · Tejun Heo
Hello,
This is the second take at improving cgroup file addition/removal interface. Changes from the last take[L] are,
* CGROUP_SUBSYS_CFTYPES[_COND]() dropped and
cgroup_subsys->base_cftypesis added instead. This works better for subsystems implemented as module.tcp_memcontrolnow uses an explicit__initcall()to register its cftypes.* 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch added as cleanup.
* 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch added so that memsw files are always created if enabled in config as suggested by KAMEZAWA.
Quoted 6 lines
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
What's the problem with remount? and is it important enough that it should be fixed even the feature is marked as deprecated?
Quoted 4 lines
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use.
Dynamic cgroup files was mentioned before. The scenario in mind was blkio control files can be added/removed automatically as devices come and ago.
So this time blkio subsystem is really going to be made more dynamic soon?
Quoted 6 lines
This will also be useful for implementing unified hierarchy.
This patchset contains the following patches.
I'll look into the patches tomorrow.
Quoted 30 lines
0001-cgroup-move-cgroup_clear_directory-call-out-of-cgrou.patch 0002-cgroup-build-list-of-all-cgroups-under-a-given-cgrou.patch 0003-cgroup-implement-cgroup_add_cftypes-and-friends.patch 0004-cgroup-merge-cft_release_agent-cftype-array-into-the.patch 0005-cgroup-relocate-cftype-and-cgroup_subsys-definitions.patch 0006-cgroup-convert-all-non-memcg-controllers-to-the-new-.patch 0007-memcg-always-create-memsw-files-if-CONFIG_CGROUP_MEM.patch 0008-cgroup-convert-memcg-controller-to-the-new-cftype-in.patch 0009-cgroup-remove-cgroup_add_file-s.patch 0010-cgroup-relocate-__d_cgrp-and-__d_cft.patch 0011-cgroup-introduce-struct-cfent.patch 0012-cgroup-implement-cgroup_rm_cftypes.patch
and is on top of
cgroup/for-3.4
3ce3230a0cff484e5130153f244d4fb8a56b3a8b
+ [1] cgroup: deprecate remount option changes mount optionand is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftypeGlauber, I think the cftypes registration for
tcp_memcontrolis fine as is in this patchset and we just need to move the init to the tail of ->create(). Let's worry about memcg for module-loadable protocols whey they are added. Can you please send a patch to move init to ->create()?If nobody objects && after Li comes back and acks the changes, I'll route these through cgroup/for-3.5.
Tejun Heo
maintainerHey, Li.
Quoted 7 lines · Li Zefan
Quoted 5 lines
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
What's the problem with remount?
Subsys can't be changed if any non-root cgroup exists.
Quoted 2 lines
and is it important enough that it should be fixed even the feature is marked as deprecated?
I'm not sure. We *might* need it during multi-mount -> single-mount transition depending on how that's implemented, so the "at the moment" qualifier. It probably won't be fixed but I'm not fully sure.
Quoted 10 lines
Quoted 4 lines
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use.
Dynamic cgroup files was mentioned before. The scenario in mind was blkio control files can be added/removed automatically as devices come and ago.
So this time blkio subsystem is really going to be made more dynamic soon?
Patchset already posted.
http://thread.gmane.org/gmane.linux.kernel.cgroups/1376
Thanks.
Signature · 1 line
tejun
Tejun Heo
maintainerPATCH 11/12 cgroup: introduce struct cfent
In reply to Tejun HeoThis patch adds cfent (cgroup file entry) which is the association between a cgroup and a file. This is in-cgroup representation of files under a cgroup directory. This simplifies walking walking cgroup files and thus cgroup_clear_directory(), which is now implemented in two parts - cgroup_rm_file() and a loop around it.
cgroup_rm_file() will be used to implement cftype removal and cfent is scheduled to serve cgroup specific per-file data (e.g. for sysfs-like "sever" semantics).
v2: - cfe was freed from cgroup_rm_file() which led to use-after-free
if the file had openers at the time of removal. Moved to cgroup_diput().
- cgroup_clear_directory() triggered WARN_ON_ONCE() if d_subdirs wasn't empty after removing all files. This triggered spuriously if some files were open during directory clearing. Removed.
v3: - In cgroup_diput(), WARN_ONCE(!list_empty(&cfe->node)) could be
spuriously triggered for root cgroups because they don't go through cgroup_clear_directory() on unmount. Don't trigger WARN for root cgroups.
---cgroup_diput() may trigger WARN_ONCE() spuriously on unmount. Fixed.
include/linux/cgroup.h | 1 kernel/cgroup.c | 109 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 76 insertions(+), 34 deletions(-)
include/linux/cgroup.h +1 -0
@@ -175,6 +175,7 @@ struct cgroup {*/ struct list_head sibling;/* my parent's children */ struct list_head children;/* my children */ +struct list_head files;/* my files */ struct cgroup *parent;/* my parent */ struct dentry __rcu *dentry;/* cgroup fs entry, RCU protected */
kernel/cgroup.c +75 -34
161 lines not on this page · raw message
Tejun Heo
maintainerQuoted 3 lines · Tejun Heo
and is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftype
Branch has been refreshed on top of the current mainline and with the updated patch.
Thanks.
Signature · 1 line
tejun
Quoted 8 lines · Tejun Heo
Quoted 3 lines · Tejun Heo
and is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftypeBranch has been refreshed on top of the current mainline and with the updated patch.
I've gone through the whole patchset, feel free to add my acks.
Quoted 9 lines · Tejun Heo
Hey, Li.
Quoted 6 lines · Li Zefan
Quoted 5 lines
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
Quoted 4 lines
Quoted 1 line
What's the problem with remount?
Subsys can't be changed if any non-root cgroup exists.
Ah, this is a long-standing defect, which is documented in Doc/../cgroups.txt. It's not trivial to fix it, and I never heard someone request it to be fixed.
Quoted 7 lines
Quoted 2 lines
and is it important enough that it should be fixed even the feature is marked as deprecated?
I'm not sure. We *might* need it during multi-mount -> single-mount transition depending on how that's implemented, so the "at the moment" qualifier. It probably won't be fixed but I'm not fully sure.
fine.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use.
Dynamic cgroup files was mentioned before. The scenario in mind was blkio control files can be added/removed automatically as devices come and ago.
Quoted 7 lines
Quoted 2 lines
So this time blkio subsystem is really going to be made more dynamic soon?
Patchset already posted.
Thanks!
Quoted 9 lines · Tejun Heo
Hey, Li.
Quoted 6 lines · Li Zefan
Quoted 5 lines
This patch replaces cgroup file interface with cftype based one which allows dynamic additions and removals of cftype arrays whether the target subsystem is attached or not. This can be used to make subsys rebinding via remount work properly but I intentionally avoided doing that at the moment.
Quoted 4 lines
Quoted 1 line
What's the problem with remount?
Subsys can't be changed if any non-root cgroup exists.
Ah, this is a long-standing defect, which is documented in Doc/../cgroups.txt. It's not trivial to fix it, and I never heard someone request it to be fixed.
Quoted 7 lines
Quoted 2 lines
and is it important enough that it should be fixed even the feature is marked as deprecated?
I'm not sure. We *might* need it during multi-mount -> single-mount transition depending on how that's implemented, so the "at the moment" qualifier. It probably won't be fixed but I'm not fully sure.
fine.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
This makes cgroup population simpler for controllers and will be used to allow controllers to be more dynamic. e.g. blkio subsys has sub-policies which may come and go while blkio subsys is attached and it currently uses fixed set of files which stays blank if not in use.
Dynamic cgroup files was mentioned before. The scenario in mind was blkio control files can be added/removed automatically as devices come and ago.
Quoted 7 lines
Quoted 2 lines
So this time blkio subsystem is really going to be made more dynamic soon?
Patchset already posted.
Thanks!
Tejun Heo
maintainerHello,
Quoted 4 lines · Li Zefan
Quoted 1 line
Subsys can't be changed if any non-root cgroup exists.
Ah, this is a long-standing defect, which is documented in
Doc/../cgroups.txt. It's not trivial to fix it, and I never heard someone request it to be fixed.
Yeah, it was a bit of head scratcher. If it can be done only when there's no cgroup configured, one might as well unmount and mount w/ new subsys instead of remounting. There's the minute difference that existing root cgroup state is preserved but that hardly justifies the crippled feature. IMHO, lack of fix request indicates the feature not being used rather than anything else, so the deprecation proposal.
Thanks.
Signature · 1 line
tejun
Hello,
Quoted 4 lines · Li Zefan
Quoted 1 line
Subsys can't be changed if any non-root cgroup exists.
Ah, this is a long-standing defect, which is documented in
Doc/../cgroups.txt. It's not trivial to fix it, and I never heard someone request it to be fixed.
Yeah, it was a bit of head scratcher. If it can be done only when there's no cgroup configured, one might as well unmount and mount w/ new subsys instead of remounting. There's the minute difference that existing root cgroup state is preserved but that hardly justifies the crippled feature. IMHO, lack of fix request indicates the feature not being used rather than anything else, so the deprecation proposal.
Thanks.
Signature · 1 line
tejun
Tejun Heo
maintainerHello,
Quoted 1 line · Li Zefan
I've gone through the whole patchset, feel free to add my acks.
I'll add acked-by's to all patches including the remount deprecation patch and start cgroup/for-3.5 branch. If there's any disagreement, please scream.
Thanks.
Signature · 1 line
tejun
Hello,
Quoted 1 line · Li Zefan
I've gone through the whole patchset, feel free to add my acks.
I'll add acked-by's to all patches including the remount deprecation patch and start cgroup/for-3.5 branch. If there's any disagreement, please scream.
Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedQuoted 2 lines · Tejun Heo
This is the second take at improving cgroup file addition/removal interface. Changes from the last take[L] are,
Applied to cgroup/for-3.5 w/ Li's acks added.
Thanks.
Signature · 1 line
tejun
Quoted 2 lines · Tejun Heo
This is the second take at improving cgroup file addition/removal interface. Changes from the last take[L] are,
Applied to cgroup/for-3.5 w/ Li's acks added.
Thanks.
Signature · 1 line
tejun
Quoted 10 lines · Tejun Heo
Quoted 3 lines · Tejun Heo
and is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftypeBranch has been refreshed on top of the current mainline and with the updated patch.
Thanks.
Do I need to send you a patch to remove memcg's populate on top of this ?
Quoted 10 lines · Tejun Heo
Quoted 3 lines · Tejun Heo
and is also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitcgroup-cftypeBranch has been refreshed on top of the current mainline and with the updated patch.
Thanks.
Do I need to send you a patch to remove memcg's populate on top of this ?
Tejun Heo
maintainerHello, Glauber.
Quoted 1 line · Glauber Costa
Do I need to send you a patch to remove memcg's populate on top of this ?
populate is already gone. My memory is a bit fuzzy now. Can you spot something broken / to be improved re. memcg cftypes in the current cgroup/for-3.5 branch?
Thanks.
Signature · 1 line
tejun
Tejun Heo
maintainerQuoted 8 lines · Tejun Heo
Hello, Glauber.
Quoted 1 line · Glauber Costa
Do I need to send you a patch to remove memcg's populate on top of this ?
populate is already gone. My memory is a bit fuzzy now. Can you spot something broken / to be improved re. memcg cftypes in the current cgroup/for-3.5 branch?
Ugh... brainfart. Please disregard the previous message. Can you please resend the patches on top of cgroup/for-3.5 and use Li's new address - [email protected] ?
Thanks.
Signature · 1 line
tejun
Quoted 8 lines · Tejun Heo
Hello, Glauber.
Quoted 1 line · Glauber Costa
Do I need to send you a patch to remove memcg's populate on top of this ?
populate is already gone. My memory is a bit fuzzy now. Can you spot something broken / to be improved re. memcg cftypes in the current cgroup/for-3.5 branch?
Ugh... brainfart. Please disregard the previous message. Can you please resend the patches on top of cgroup/for-3.5 and use Li's new address - [email protected] ?
Thanks.
Signature · 1 line
tejun
Quoted 10 lines · Tejun Heo
Quoted 8 lines · Tejun Heo
Hello, Glauber.
Quoted 1 line · Glauber Costa
Do I need to send you a patch to remove memcg's populate on top of this ?
populate is already gone. My memory is a bit fuzzy now. Can you spot something broken / to be improved re. memcg cftypes in the current cgroup/for-3.5 branch?
Quoted 6 lines
Ugh... brainfart. Please disregard the previous message. Can you please resend the patches on top of cgroup/for-3.5 and use Li's new address - [email protected] ?
Thanks.
All right.
I'll give a new test to make sure it is still okay, and send shortly
Quoted 10 lines · Tejun Heo
Quoted 8 lines · Tejun Heo
Hello, Glauber.
Quoted 1 line · Glauber Costa
Do I need to send you a patch to remove memcg's populate on top of this ?
populate is already gone. My memory is a bit fuzzy now. Can you spot something broken / to be improved re. memcg cftypes in the current cgroup/for-3.5 branch?
Quoted 6 lines
Ugh... brainfart. Please disregard the previous message. Can you please resend the patches on top of cgroup/for-3.5 and use Li's new address - [email protected] ?
Thanks.
All right.
I'll give a new test to make sure it is still okay, and send shortly