Hi,
I want to restrict cpu usage of my process so i have planned to use
Cgroups.
I have followed the following Set of commands:
Code:
sudo cgcreate -g cpu:/cpulimited
sudo cgcreate -g cpu:/lesscpulimited
sudo cgset -r cpu.shares=512 cpulimited
This is the output of cgsnapshot -s command:
Code:
# 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 lesscpulimited {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.cfs_period_us="100000";
cpu.cfs_quota_us="-1";
cpu.shares="1024";
}
}
group cpulimited {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.cfs_period_us="100000";
cpu.cfs_quota_us="-1";
cpu.shares="512";
}
}
This command i am trying to execute:
Code:
sudo cgexec -g cpu:lesscpulimited dd if=/dev/zero of=/dev/null bs=1024k &
sudo cgexec -g cpu:cpulimited dd if=/dev/zero of=/dev/null bs=1024k &
But still i cant restrict the CPU usage:
Here is the output of mu top:
Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1727 root 20 0 9376 1660 524 R 100.0 0.1 8:47.74 dd
1730 root 20 0 9376 1660 524 R 100.0 0.1 8:07.66 dd
1 root 20 0 19232 1500 1220 S 0.0 0.1 0:00.63 init
I have restarted the service also.
What i am missing?