On 24/07/09 12:02 +0200, Louis Rilling wrote: > Hi Ben, > > On 23/07/09 20:22 -0700, Ben Blum wrote: > > Makes procs file writable to move all threads by tgid at once > > > > This patch adds functionality that enables users to move all threads in a > > threadgroup at once to a cgroup by writing the tgid to the 'cgroup.procs' > > file. This current implementation makes use of a rwsem that's taken for > > reading in the fork() path to prevent newly forking threads within the > > threadgroup from "escaping" while moving is in progress. > > > > Signed-off-by: Ben Blum <bblum@xxxxxxxxxx> > [...] > > +int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader) > > +{ > > + int retval; > > + struct cgroup_subsys *ss; > > + struct cgroup *oldcgrp; > > + struct css_set *oldcg; > > + struct cgroupfs_root *root = cgrp->root; > > + int subsys_id; > > + /* threadgroup list cursor */ > > + struct task_struct *tsk; > > + /* > > + * we need to make sure we have css_sets for all the tasks we're > > + * going to move -before- we actually start moving them, so that in > > + * case we get an ENOMEM we can bail out before making any changes. > > + */ > > + struct list_head newcg_list; > > + struct cg_list_entry *cg_entry; > > + > > + /* first, make sure this came from a valid tgid */ > > + if (!thread_group_leader(leader)) > > + return -EINVAL; > > + /* > > + * check that we can legitimately attach to the cgroup. > > + */ > > + for_each_subsys(root, ss) { > > + if (ss->can_attach) { > > + retval = ss->can_attach(ss, cgrp, leader); > > + if (retval) > > + return retval; > > + } > > } > > So the semantics of ->can_attach() becomes: if called for a thread group leader, > the result should be valid for the whole thread group, even if only the thread > group leader is being attached. This looks a bit fuzzy and thus not desirable. > Why not checking ->can_attach() for all threads (and lock cgroup_fork_mutex > earlier)? Ok I've read the next patch. Patch 6 should really go before this one, both for better understanding and safety. Thanks, Louis -- Dr Louis Rilling Kerlabs Skype: louis.rilling Batiment Germanium Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes http://www.kerlabs.com/ 35700 Rennes
Attachment:
signature.asc
Description: Digital signature
_______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/containers