[转载] Linux下判断cpu物理个数,几核,是超线程还是多核心
如果系统包含两个物理封装,每个封装中又包含两个支持超线程(HT)技术的处理器内核,则 /proc/cpuinfo 文件将包含此数据。(注:数据并不在表格中。)查看方法: less /proc/cpuinfo
|
processor |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
|
physical id |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
|
core id |
0 |
2 |
1 |
3 |
0 |
2 |
1 |
3 |
|
siblings |
4 |
4 |
4 |
4 |
4 |
4 |
4 |
4 |
|
cpu cores |
2 |
2 |
2 |
2 |
2 |
2 |
2 |
2 |
可通过如下方法查询CPU情况:
1.逻辑CPU个数:
# cat /proc/cpuinfo | grep "processor" | wc -l
2.物理CPU个数:
# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
3.每个物理CPU中Core的个数:
# cat /proc/cpuinfo | grep "cpu cores" | wc -l
是否为超线程?
如果有两个逻辑CPU具有相同的"core id",那么超线程是打开的。
4.每个物理CPU中逻辑CPU(可能是core, threads或both)的个数:
# cat /proc/cpuinfo | grep "siblings"
逻辑CPU个数:cat /proc/cpuinfo | grep "processor" | wc -l
物理CPU个数:cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
"siblings"指的是一个物理CPU有几个逻辑CPU
"cpu cores"指的是一个物理CPU有几个核
不应该按照flags里是否有 ht 标志来判断系统是否有超线程能力,而应该:
如果"siblings"和"cpu cores"一致,则说明不支持超线程,或者超线程未打开。
如果"siblings"是"cpu cores"的两倍,则说明支持超线程,并且超线程已打开。
posted on 2011-09-21 15:29 longzhao&&dilanlx 阅读(224) 评论(0) 收藏 举报
浙公网安备 33010602011771号