本文共 5830 字,大约阅读时间需要 19 分钟。
创建cpu的cgroup的过程
root@cliffr zl]# cat /proc/cpuinfo processor : 0vendor_id : GenuineIntelcpu family : 6model : 55model name : Intel(R) Atom(TM) CPU Z3735F @ 1.33GHzstepping : 8cpu MHz : 1332.696cache size : 1024 KBphysical id : 0siblings : 4core id : 0cpu cores : 4apicid : 0initial apicid : 0fdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 11wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand lahf_lm 3dnowprefetchbogomips : 2665.39clflush size : 64cache_alignment : 64address sizes : 36 bits physical, 48 bits virtualpower management:processor : 1vendor_id : GenuineIntelcpu family : 6model : 55model name : Intel(R) Atom(TM) CPU Z3735F @ 1.33GHzstepping : 8cpu MHz : 1332.696cache size : 1024 KBphysical id : 0siblings : 4core id : 1cpu cores : 4apicid : 1initial apicid : 1fdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 11wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand lahf_lm 3dnowprefetchbogomips : 2665.39clflush size : 64cache_alignment : 64address sizes : 36 bits physical, 48 bits virtualpower management:processor : 2vendor_id : GenuineIntelcpu family : 6model : 55model name : Intel(R) Atom(TM) CPU Z3735F @ 1.33GHzstepping : 8cpu MHz : 1332.696cache size : 1024 KBphysical id : 0siblings : 4core id : 2cpu cores : 4apicid : 2initial apicid : 2fdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 11wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand lahf_lm 3dnowprefetchbogomips : 2665.39clflush size : 64cache_alignment : 64address sizes : 36 bits physical, 48 bits virtualpower management:processor : 3vendor_id : GenuineIntelcpu family : 6model : 55model name : Intel(R) Atom(TM) CPU Z3735F @ 1.33GHzstepping : 8cpu MHz : 1332.696cache size : 1024 KBphysical id : 0siblings : 4core id : 3cpu cores : 4apicid : 3initial apicid : 3fdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 11wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand lahf_lm 3dnowprefetchbogomips : 2665.39clflush size : 64cache_alignment : 64address sizes : 36 bits physical, 48 bits virtualpower management:[root@cliffr zl]# [root@cliffr zl]# mkdir /dev/cgroup_cpu[root@cliffr zl]# mount -t cgroup -o cpuset cpuset /dev/cgroup_cpu/[root@cliffr zl]# ls /dev/cgroup_cpu/cgroup.event_control cpuset.cpus cpuset.memory_migrate cpuset.memory_spread_page cpuset.sched_load_balance notify_on_releasecgroup.procs cpuset.mem_exclusive cpuset.memory_pressure cpuset.memory_spread_slab cpuset.sched_relax_domain_level release_agentcpuset.cpu_exclusive cpuset.mem_hardwall cpuset.memory_pressure_enabled cpuset.mems libvirt tasks[root@cliffr zl]# cd /dev/cgroup_cpu/[root@cliffr cgroup_cpu]# mkdir Charlie[root@cliffr cgroup_cpu]# cd Charlie[root@cliffr Charlie]# lscgroup.event_control cpuset.cpus cpuset.memory_migrate cpuset.memory_spread_slab cpuset.sched_relax_domain_levelcgroup.procs cpuset.mem_exclusive cpuset.memory_pressure cpuset.mems notify_on_releasecpuset.cpu_exclusive cpuset.mem_hardwall cpuset.memory_spread_page cpuset.sched_load_balance tasks[root@cliffr Charlie]# /bin/echo 2-3 > cpuset.cpus[root@cliffr Charlie]# cat cpuset.cpus 2-3[root@cliffr Charlie]# cat cpuset.mems [root@cliffr Charlie]# echo 1 > cpuset.memsbash: echo: write error: Numerical result out of range[root@cliffr Charlie]# echo 0 > cpuset.mems[root@cliffr Charlie]# cat cpuset.mems 0[root@cliffr Charlie]# echo $$ > tasks[root@cliffr Charlie]# cat tasks 23832407[root@cliffr Charlie]# ps PID TTY TIME CMD 2376 pts/0 00:00:00 su 2383 pts/0 00:00:00 bash 2408 pts/0 00:00:00 ps[root@cliffr Charlie]#
Linux Cgroup浅析
https://zhuanlan.zhihu.com/p/102372680Linux cgroup机制分析之框架分析
https://blog.csdn.net/ctoday/article/details/20838587Linux cgroup机制分析之框架分析
http://blog.chinaunix.net/uid-20543183-id-1930840.htmlCgroup框架分析
https://blog.csdn.net/zhangyifei216/article/details/49491549Android/Linux下CGroup框架分析及其使用
https://www.cnblogs.com/arnoldlu/p/6208443.htmlcgroup框架结构
http://blog.chinaunix.net/uid-30126070-id-5065454.htmlDocker背后的内核知识——cgroups资源限制
http://www.sel.zju.edu.cn/?p=573cgroup中的cgroup_subsys[]数组解析
https://blog.csdn.net/wennuanddianbo/article/details/71244276Linux Cgroups详解 好文
https://www.cnblogs.com/lisperl/archive/2012/04/17/2453838.html