Messages in this thread | | | Date | Wed, 17 Aug 2011 11:18:58 +0800 | From | Li Zefan <> | Subject | Re: [PATCH 7/8] cgroups: Add a task counter subsystem |
| |
> diff --git a/init/Kconfig b/init/Kconfig > index 412c21b..bea98d2d 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -690,6 +690,13 @@ config CGROUP_MEM_RES_CTLR_SWAP_ENABLED > select this option (if, for some reason, they need to disable it > then noswapaccount does the trick). > > +config CGROUP_TASK_COUNTER > + bool "Control number of tasks in a cgroup"
TAB
> + depends on RESOURCE_COUNTERS > + help > + This option let the user to set up an upper bound allowed number
will let?
> + of tasks inside a cgroup. > + > config CGROUP_PERF > bool "Enable perf_event per-cpu per-container group (cgroup) monitoring" > depends on PERF_EVENTS && CGROUPS
...
> +int cgroup_task_counter_fork(struct task_struct *child) > +{ > + struct cgroup_subsys_state *css = child->cgroups->subsys[tasks_subsys_id]; > + struct cgroup *cgrp = css->cgroup; > + struct res_counter *limit_fail_at; > + > + /* Optimize for the root cgroup case, which doesn't have a limit */ > + if (!cgrp->parent) > + return 0; > + > + return res_counter_charge(cgroup_task_counter_res(cgrp), 1, &limit_fail_at);
I think we should change the return value of res_counter_charge. Currently it returns -ENOMEM when we excceed limit.
> +} > + > +struct cgroup_subsys tasks_subsys = { > + .name = "tasks", > + .subsys_id = tasks_subsys_id, > + .create = task_counter_create, > + .post_clone = task_counter_post_clone, > + .destroy = task_counter_destroy, > + .exit = task_counter_exit, > + .can_attach_task = task_counter_can_attach_task, > + .cancel_attach_task = task_counter_cancel_attach_task, > + .attach_task = task_counter_attach_task, > + .populate = task_counter_populate, > + .early_init = 1,
Just set early_init to 0, since this subsystem doesn't have to be initialized early during kernel boot.
> +};
| |