Check the physical and logical number of CPUs under linux

[plain]  view plain copy  
 
  1. hadoop@chw-desktop3:~$ cat /proc/cpuinfo  
  2. processor   : 0  
  3. vendor_id   : GenuineIntel  
  4. cpu family  : 15  
  5. model       : 2  
  6. model name  : Intel(R) Pentium(R) 4 CPU 3.00GHz  
  7. stepping    : 9  
  8. microcode   : 0x17  
  9. cpu MHz     : 2992.615  
  10. cache size  : 512 KB  
  11. physical id : 0  
  12. siblings    : 2  
  13. core id     : 0  
  14. cpu cores   : 1  
  15. apicid      : 0  
  16. initial apicid  : 0  
  17. fdiv_bug    : no  
  18. hlt_bug     : no  
  19. f00f_bug    : no  
  20. coma_bug    : no  
  21. fpu     : yes  
  22. fpu_exception   : yes  
  23. cpuid level : 2  
  24. wp      : yes  
  25. flags       : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr  
  26. bogomips    : 5985.23  
  27. clflush size    : 64  
  28. cache_alignment : 128  
  29. address sizes   : 36 bits physical, 32 bits virtual  
  30. power management:  
  31.   
  32. processor   : 1  
  33. vendor_id   : GenuineIntel  
  34. cpu family  : 15  
  35. model       : 2  
  36. model name  : Intel(R) Pentium(R) 4 CPU 3.00GHz  
  37. stepping    : 9  
  38. microcode   : 0x17  
  39. cpu MHz     : 2992.615  
  40. cache size  : 512 KB  
  41. physical id : 0  
  42. siblings    : 2  
  43. core id     : 0  
  44. cpu cores   : 1  
  45. apicid      : 1  
  46. initial apicid  : 1  
  47. fdiv_bug    : no  
  48. hlt_bug     : no  
  49. f00f_bug    : no  
  50. coma_bug    : no  
  51. fpu     : yes  
  52. fpu_exception   : yes  
  53. cpuid level : 2  
  54. wp      : yes  
  55. flags       : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr  
  56. bogomips    : 5990.44  
  57. clflush size    : 64  
  58. cache_alignment : 128  
  59. address sizes   : 36 bits physical, 32 bits virtual  
  60. power management:  

 

Enter the command cat /proc/cpuinfo to check how many physical IDs there are. The above result shows that there is only 0, so there is only one physical cpu; to check how many processors there are, the above result shows that there are 0 and 1, so there are two logical cpus.


(一)概念
① 物理CPU
实际Server中插槽上的CPU个数
物理cpu数量,可以数不重复的 physical id 有几个
② 逻辑CPU 
 /proc/cpuinfo 用来存储cpu硬件信息的
信息内容分别列出了processor 0 –processor n 的规格。这里需要注意,n是逻辑cpu数
一般情况,我们认为一颗cpu可以有多核,加上intel的超线程技术(HT), 可以在逻辑上再分一倍数量的cpu core出来
逻辑CPU数量=物理cpu数量 x cpu cores 这个规格值 x 2(如果支持并开启ht)    
备注一下:Linux下top查看的CPU也是逻辑CPU个数
 ③ CPU核数
一块CPU上面能处理数据的芯片组的数量、比如现在的i5 760,是双核心四线程的CPU、而 i5 2250 是四核心四线程的CPU
一般来说,物理CPU个数×每颗核数就应该等于逻辑CPU的个数,如果不相等的话,则表示服务器的CPU支持超线程技术 
㈡ 查看CPU信息
当我们 cat /proc/cpuinfo 时、
具有相同core id的CPU是同一个core的超线程
具有相同physical id的CPU是同一个CPU封装的线程或核心
㈢ 下面举例说明
① 查看物理CPU的个数
#cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l  
2  
② Check the number of logical CPUs
#cat /proc/cpuinfo |grep "processor"|wc -l  
24  
③ Check the number of CPU cores
#cat /proc/cpuinfo |grep "cores"|uniq  
6   
I should have 2 here Cpu, each Cpu has 6 cores, it should be Intel's U, supports hyperthreading, so it shows 24 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326607987&siteId=291194637