标签:
环境: centos6.6 mini cpu
4核心
cat /proc/cpuinfo |grep ‘processor‘|wc -l 4
[root@kvm ~]# ps -eLo psr |grep 0|wc -l 63 [root@kvm ~]# ps -eLo psr |grep 1|wc -l 57 [root@kvm ~]# ps -eLo psr |grep 2|wc -l 35 [root@kvm ~]# ps -eLo psr |grep 3|wc -l 32
编辑/etc/grub.conf 中在当前使用的 kernel 选项后添加 isolcpus=cpu_number [, cpu_number ,...]
kernel /vmlinuz-2.6.32-504.8.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet isolcpus=2,3
[root@kvm ~]# ps -eLo psr |grep 0|wc -l 45 [root@kvm ~]# ps -eLo psr |grep 1|wc -l 52 [root@kvm ~]# ps -eLo psr |grep 2|wc -l 13 [root@kvm ~]# ps -eLo psr |grep 3|wc -l 13
cpu 2,3 上只有13个进程 查看分别cpu2,3上运行的进程
[root@kvm ~]# ps -eLo ruser,pid,ppid,lwp,psr,args|awk ‘{if($5==2) print $0}‘ root 11 2 11 2 [migration/2] root 12 2 12 2 [stopper/2] root 13 2 13 2 [ksoftirqd/2] root 14 2 14 2 [watchdog/2] root 21 2 21 2 [events/2] root 32 2 32 2 [kintegrityd/2] root 36 2 36 2 [kblockd/2] root 44 2 44 2 [ata_sff/2] root 51 2 51 2 [md/2] root 55 2 55 2 [md_misc/2] root 65 2 65 2 [aio/2] root 69 2 69 2 [crypto/2] root 80 2 80 2 [kthrotld/2] [root@kvm ~]# ps -eLo ruser,pid,ppid,lwp,psr,args|awk ‘{if($5==3) print $0}‘ root 15 2 15 3 [migration/3] root 16 2 16 3 [stopper/3] root 17 2 17 3 [ksoftirqd/3] root 18 2 18 3 [watchdog/3] root 22 2 22 3 [events/3] root 33 2 33 3 [kintegrityd/3] root 37 2 37 3 [kblockd/3] root 45 2 45 3 [ata_sff/3] root 52 2 52 3 [md/3] root 56 2 56 3 [md_misc/3] root 66 2 66 3 [aio/3] root 70 2 70 3 [crypto/3] root 81 2 81 3 [kthrotld/3]
没有其他普通进程在cpu2,3上运行 说明隔离生效了。
至此cpu隔离完成,通过这样的做法可以将隔离出的cpu分配给kvm虚拟机使用 以达到客户机cpu负载不受宿主机cpu负载影响。
参考 : kvm虚拟化技术
http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/re46.html
标签:
原文地址:http://my.oschina.net/firxiao/blog/375574