查看cpu信息有什么用呢,我們來看看到底有哪些用處:
1、和雲服務提供商核算成本,現在基本是cpu和內存的費用最大,硬盤大小幾乎被忽略了 2、我們寫程序時候是會關注多核還是單核的,否則不能充分利用多線程等特性 3、cpu和內存大小直接決定了,我們在部署應用環境時候是否能滿足整體運行的要求。 另外有些架構都有自己的指令集,所以必須要了解清楚機器的情況和配置,才能更好的調整我們的架構體系 很多比較強大的軟件都有根據cpu架構對應的版本比如: ibm,amd,intel等。運維工作更應該關注的不僅僅只是使用和安裝 特別是調優和調試錯誤的時候,我們有時候知識的貯備明顯就顯得不足了。當然我們這個時代都是大部分是雲主機,只有量級達到一定水平才會 使用物理機來有針對性的構建我們的架構和應用。暫且不說,但是要想做一個有深度的專家實際我們更應該關注一些底層的內容。 畢竟技術如何變,最終是靠要底層的支撐。
1)查看cpu信息
[root@fp-web-126 ~]# cat /proc/cpuinfo 信息包括有 cpu型號 Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz,2個cpu,8核 指令集是64bit 機器配置8核、16G
2)查看cpu運行模式
[root@fp-web-126 ~]# getconf LONG_BIT 64
3)查看cpu是否支持64bit
[root@fp-web-126 ~]# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l 8 (結果大於0, 說明支持64bit計算. lm指long mode, 支持lm則是64bit)
4)查看cpu信息概要
[root@ht2 src]# lscpu Architecture: x86_64 #x86架構下的64位 CPU op-mode(s): 32-bit, 64-bit #表示支持運行模式,getconf LONG_BIT 命令可以得到當前CPU運行在什么模式下,如果是64,但不代表CPU不支持32bi Byte Order: Little Endian #Intel的機器(X86平台)一般都采用小端,Little Endian代表小段字節對齊 CPU(s): 80 #邏輯cpu顆數 On-line CPU(s) list: 0-79 #正在運行的cpu邏輯內核 Thread(s) per core: 2 #每個核的線程數(每個 Core 的硬件線程數) Core(s) per socket: 10 #多少核 Socket(s): 4 #服務器面板上有4個cpu槽位 NUMA node(s): 4 #numa nodes的數量 Vendor ID: GenuineIntel #cpu廠商ID CPU family: 6 #CPU產品系列代號 Model: 62 #CPU屬於其系列中的哪一代的代號 Model name: Intel(R) Xeon(R) CPU #cpu型號 E7-4830 v2 @ 2.20GHz //型號 Stepping: 7 #步長 CPU MHz: 2180.664 #CPU的時鍾頻率(主頻),是指CPU運算時的工作的頻率,決定計算技術的運行速度,單位是Hz CPU max MHz: 2700.0000 #cpu時鍾最大頻率 CPU min MHz: 1200.0000 #cpu時鍾最小頻率 BogoMIPS: 4389.73 #BogoMips 是衡量 CPU 速度的方法,它衡量的是“ CPU 每秒鍾什么都不能做的百萬次數” Virtualization: VT-x #cpu支持的虛擬化技術,需要進入進入bios設置 //要結合着理解L1d cache和L1i cache,他們兩個差一個字母d和i L1d cache: 32K #ld cache 內容緩存 L1i cache: 32K #li cache 指令緩存,L1是最靠近CPU核心的緩存。 L2 cache: 256K #CPU未命中L1的情況下繼續在L2尋求命中,L2二級緩存比L1一級緩存的容量要更大,但是L2的速率要更慢,離cpu遠 L3 cache: 20480K # #這里看到,cpu是采用numa硬件體系架構,首先確認看到cpu硬件是否支持numa的. #通過lscpu 、numactl --hardware、grep -i numa /var/log/dmesg等命令可以看到相關配置。 #緩存速度上 L1 > L2 > L3 > DDR NUMA node0 CPU(s): 0-9,40-49 #0-9和40-49 是由numa node0 來管理的 NUMA node1 CPU(s): 10-19,50-59 #... NUMA node2 CPU(s): 20-29,60-69 #... NUMA node3 CPU(s): 30-39,70-79 #... Flags: fpu ..... #cpu支持的技術特征 這里省略了.另外章節介紹
查看cpu相關信息
5)[root@fp-web-126 ~]# cat /proc/cpuinfo -------------------------------------cpu1,4核------------------------------------------------------------ processor : 0 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz 英特爾至強處理器,主頻:2.6 GHz, 產品型號 E5-2660 stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 1 ####邏輯id vendor_id : GenuineIntel ###因特爾原裝CPU cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 0 siblings : 4 core id : 1 cpu cores : 4 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 2 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 0 siblings : 4 core id : 2 cpu cores : 4 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 3 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 0 siblings : 4 core id : 3 cpu cores : 4 apicid : 3 initial apicid : 3 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: -------------------------------------cpu2,4核------------------------------------------------------------ processor : 4 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 1 ##單個CPU的標號 siblings : 4 ##單個CPU邏輯物理核數 core id : 0 ##當前物理核在其所處CPU中的編號,這個編號不一定連續 cpu cores : 4 ##該邏輯核所處CPU的物理核數 apicid : 4 ##用來區分不同邏輯核的編號,系統中每個邏輯核的此編號必然不同,此編號不一定連續 initial apicid : 4 fpu : yes ##是否具有浮點運算單元 fpu_exception : yes ##是否支持浮點計算異常 cpuid level : 15 ##執行cpuid指令前,eax寄存器中的值,根據不同的值cpuid指令會返回不同的內容 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 5 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 1 siblings : 4 core id : 1 cpu cores : 4 apicid : 5 initial apicid : 5 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 6 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 microcode : 0x38 cpu MHz : 2593.993 cache size : 25600 KB physical id : 1 siblings : 4 core id : 2 cpu cores : 4 apicid : 6 initial apicid : 6 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: processor : 7 #系統中邏輯處理核的編號 vendor_id : GenuineIntel cpu family : 6 #CPU產品系列代號 model : 63 #CPU屬於其系列中的哪一代的代號 model name : Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz stepping : 2 #CPU屬於制作更新版本 microcode : 0x38 cpu MHz : 2593.993 ##CPU的實際使用主頻 cache size : 25600 KB ##CPU二級緩存大小 physical id : 1 ##單個CPU的標號 siblings : 4 core id : 3 cpu cores : 4 apicid : 7 initial apicid : 7 fpu : yes fpu_exception : yes cpuid level : 15 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt bogomips : 5187.98 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 以上輸出項的含義如下: processor :系統中邏輯處理核的編號。對於單核處理器,則課認為是其CPU編號,對於多核處理器則可以是物理核、或者使用超線程技術虛擬的邏輯核 vendor_id :CPU制造商 cpu family :CPU產品系列代號 model :CPU屬於其系列中的哪一代的代號 model name:CPU屬於的名字及其編號、標稱主頻 stepping :CPU屬於制作更新版本 cpu MHz :CPU的實際使用主頻 cache size :CPU二級緩存大小 physical id :單個CPU的標號 siblings :單個CPU邏輯物理核數 core id :當前物理核在其所處CPU中的編號,這個編號不一定連續 cpu cores :該邏輯核所處CPU的物理核數 apicid :用來區分不同邏輯核的編號,系統中每個邏輯核的此編號必然不同,此編號不一定連續 fpu :是否具有浮點運算單元(Floating Point Unit) fpu_exception :是否支持浮點計算異常 cpuid level :執行cpuid指令前,eax寄存器中的值,根據不同的值cpuid指令會返回不同的內容 wp :表明當前CPU是否在內核態支持對用戶空間的寫保護(Write Protection) flags :當前CPU支持的功能 bogomips :在系統內核啟動時粗略測算的CPU速度(Million Instructions Per Second) clflush size :每次刷新緩存的大小單位 cache_alignment :緩存地址對齊單位 address sizes :可訪問地址空間位數 power management :對能源管理的支持