[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E4B3322.6060608@cn.fujitsu.com>
Date: Wed, 17 Aug 2011 11:18:58 +0800
From: Li Zefan <lizf@...fujitsu.com>
To: Frederic Weisbecker <fweisbec@...il.com>
CC: LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Paul Menage <menage@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Aditya Kali <adityakali@...gle.com>,
Oleg Nesterov <oleg@...hat.com>
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.
> +};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists