????cgroups???control groups????RHEL6??2.6.32??????????????cgroup??patch???????????鰲?RHEL6(CentOS6)?????cgroups???????е????
???????????????? ( > 2.6.26?汾)
???????cgroups
????apt-get install cgroup-bin
????????????vi /etc/cgconfig.conf
?????????mount ????????????

 

mount {
cpuset = /sys/fs/cgroup/cpuset;
net_cls = /sys/fs/cgroup/net_cls;
blkio = /sys/fs/cgroup/blkio;
perf_event = /sys/fs/cgroup/perf_event;
cpu = /sys/fs//cgroup/cpu;
cpuacct = /sys/fs/cgroup/cpuacct;
devices = /sys/fs/cgroup/devices;
memory = /sys/fs/cgroup/memory;
freezer = /sys/fs/cgroup/freezer;
}

???????? cpu ????
????cpu.shares??????cgroup A?? tasks ?? cpu.shares ??1??cgroup B??tasks??cpu.shares??2????cgroup B?????????cpu?????cgroup A??????2????
????cpu.rt_runtime_us
????cpu.rt_period_us??  ??????????鯔??裬??OS?????????CPU???????
???????? cpu ????
????sina@ubuntu:~$ cd /sys/fs/cgroup/cpu
????????????
????# mkdir   tinker
????# mkdir   tailor
???????????taskset -c 3 ??????????????  ??????? cpu affinity?cpu 3?????2?????????
????# taskset -c 3 ./for-test.sh
?????????????????? ?????????? ????????????
?????????????????PID????cpu??????

 

root@ubuntu:~# ps -C qemu-system-i386 -opid??%cpu??psr??args
PID %CPU PSR COMMAND
3237 50.1   3 /home/sina/Downloads/qemu-kvm-1.1.0/i386-softmmu/qemu-system-i386
3306 49.8   3 /home/sina/Downloads/qemu-kvm-1.1.0/i386-softmmu/qemu-system-i386

?????????????qemu ????? pid??? echo ?? tasks ????С????????  cpu/tinker  ?? cpu.shares ?2048?? cpu/tailor  ?? cpu.shares ?512??

 

root@ubuntu:~# echo 3237 > /sys/fs/cgroup/cpu/tinker/tasks
root@ubuntu:~# echo 3306 > /sys/fs/cgroup/cpu/tailor/tasks
root@ubuntu:~# echo 2048 > /sys/fs/cgroup/cpu/tinker/cpu.shares
root@ubuntu:~# echo 512 > /sys/fs/cgroup/cpu/tailor/cpu.shares

??????????????????? cpu ??????
??????????cpu.shares???CPU???????????????shares?????????????????????????????????????仯????????????????????????cpu??????
??????????????????????