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

Raghavendra KT raghavendra.kt at linux.vnet.ibm.com
Thu Apr 17 18:03:50 UTC 2014


On Tue, Apr 15, 2014 at 3:07 AM, Tejun Heo <tj at kernel.org> 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?


More information about the Containers mailing list