Search code examples
rhelrhel6cgroups

RHEL: cgroup change of group failed


When I run the following command, I get cgroup change of group failed:

cgexec --sticky -g *:/throttle some_task

Cgroup throttle is defined in cgconfig.conf, which looks like this:

# Configuration file generated by cgsnapshot
mount {
        cpuset = /cgroup/cpuset;
        cpu = /cgroup/cpu;
        cpuacct = /cgroup/cpuacct;
        memory = /cgroup/memory;
        devices = /cgroup/devices;
        freezer = /cgroup/freezer;
        net_cls = /cgroup/net_cls;
        blkio = /cgroup/blkio;
}

group throttle {
        cpu {
                cpu.rt_period_us="1000000";
                cpu.rt_runtime_us="0";
                cpu.cfs_period_us="1000000";
                cpu.cfs_quota_us="500000";
                cpu.shares="1024";
        }
}

group throttle {
        memory {
                memory.memsw.failcnt="0";
                memory.limit_in_bytes="1073741824";
                memory.memsw.max_usage_in_bytes="0";
                memory.move_charge_at_immigrate="0";
                memory.swappiness="60";
                memory.use_hierarchy="0";
                memory.failcnt="0";
                memory.soft_limit_in_bytes="134217728";
                memory.memsw.limit_in_bytes="1073741824";
                memory.max_usage_in_bytes="0";
        }
}

group throttle {
        blkio {
                blkio.throttle.write_iops_device="8:0   10";
                blkio.throttle.read_iops_device="8:0    10";
                blkio.throttle.write_bps_device="";
                blkio.throttle.read_bps_device="";
                blkio.weight="500";
                blkio.weight_device="";
        }
}

I have searched far and wide and haven't a clue how to start trouble shooting this. This seems to be commonly associated with incorrect permissions. However, I don't define permissions (the documentation for cgroups says that this is optional). I'm running the process as root.


Solution

  • Figured it out. For some reason, cgexec on my system is not liking the wildcard (*) for the controller. When I listed controllers by name, it worked:

    cgexec --sticky -g "cpu,memory,blkio":/throttle some_task
    

    The manpage for cgexec on my system lists *:<group_name> as valid syntax, however, so I'm not sure what exactly is going on. Either way, it's working correctly when the controllers are specified.