Re: [PATCH 12/12] cgroup: implement dynamic subtree controller enable/disable on the default hierarchy

From: Raghavendra KT
Date: Thu Apr 17 2014 - 14:04:12 EST


On Tue, Apr 15, 2014 at 3:07 AM, Tejun Heo <tj@xxxxxxxxxx> wrote:
[...]
> * White-space separated list of controller names prefixed with either
> '+' or '-' can be written to "cgroup.subtree_control". The ones
> prefixed with '+' are enabled on the controller and '-' disabled.
>

[...]

> +
> +/* change the enabled child controllers for a cgroup in the default hierarchy */
> +static int cgroup_subtree_control_write(struct cgroup_subsys_state *dummy_css,
> + struct cftype *cft, char *buffer)
> +{
> + unsigned long enable_req = 0, disable_req = 0, enable, disable;
> + struct cgroup *cgrp = dummy_css->cgroup, *child;
> + struct cgroup_subsys *ss;
> + char *tok, *p;
> + int ssid, ret;
> +
> + /*
> + * Parse input - white space separated list of subsystem names
> + * prefixed with either + or -.
> + */
> + p = buffer;
> + while ((tok = strsep(&p, " \t\n"))) {
> + for_each_subsys(ss, ssid) {
> + if (ss->disabled || strcmp(tok + 1, ss->name))
> + continue;
> +
> + if (*tok == '+') {
> + enable_req |= 1 << ssid;
> + disable_req &= ~(1 << ssid);
> + } else if (*tok == '-') {
> + disable_req |= 1 << ssid;
> + enable_req &= ~(1 << ssid);
> + } else {
> + return -EINVAL;
> + }
> + break;
> + }
> + if (ssid == CGROUP_SUBSYS_COUNT)
> + return -EINVAL;
> + }

I undertsand that with the above parsing we could do
echo "-blkio +blkio" > cgroup.subtree_control and honor last enable/disable.
It confused me while testing. do you think we should return -EINVAL in
such case?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/