linux 中cpu信息,你知道多少呢?

查找一個linux服務器中CPU核數

接到這個任務第一反應是打開百度,輸入“linux核數”關鍵字
不用查了,我直接告訴你:
拿我一臺用作redis存儲的線上機器來做實驗

cat /proc/cpuinfo | grep  'physical id' | sort | uniq | wc -l  //查找linux 物理cpu個數
輸出: 2
cat /proc/cpuinfo | grep  'cpu cores' |  uniq    //位於相同物理封裝處理器中的內核數量(每顆物理cpu的核數)
輸出: cpu cores	: 24
cat /proc/cpuinfo | grep 'processor' | wc -l //邏輯處理的核數
輸出:  96

根據輸出我們得出結論是:

  • 這臺服務器 有 2 個物理cpu
  • 每個cpu有 24個物理內核
  • 每個cpu物理內核有2和邏輯處理器
  • 服務器總共有96個邏輯處理器 (96 = 2 ✖️ 24 ✖️ 2)

proc/cpuinfo 中各個參數含義

cat /proc/cpuinfo
processor	: 95
vendor_id	: GenuineIntel
cpu family	: 6
model		: 85
model name	: Intel(R) Xeon(R) Gold 6271C CPU @ 2.60GHz
stepping	: 7
microcode	: 0x5000024
cpu MHz		: 2601.000
cache size	: 33792 KB
physical id	: 1
siblings	: 48
core id		: 29
cpu cores	: 24
apicid		: 123
initial apicid	: 123
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_ppin intel_pt ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips	: 5206.70
clflush size	: 64
cache_alignment	: 64
address sizes	: 46 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     :可訪問地址空間位數

我們一定要理解每個參數含義哦,這樣就不用死記硬背命令查找cpu信息了

總結思考

查找超頻怎麼查找呢?
我們看這個參數 siblings:單個CPU邏輯物理核數
那麼超頻命令就自然誕生了

cat /proc/cpuinfo | grep -e "cpu cores"  -e "siblings" | sort | uniq
輸出:
cpu cores	: 24
siblings	: 48

如果 cpu cores 梳理 和 siblings梳理相等證明沒有啓用超頻,否則就是啓用了超頻

看到這裏相信大家完全理解了cpuinfo的信息了,想想還有哪些信息是可以通過這個配置文件找到呢?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章