如何用Linux的命令正确识别cpu的个数和核数

     如何在Linux下cpu的个数和核数呢?googel了一下,网上总结的很多办法都是错的或者混淆视听,没办法,靠自己了。

判断依据:

1.具有相同core id的cpu是同一个core的超线程。
2.具有相同physical id的cpu是同一颗cpu封装的线程或者cores。
英文版:
1.Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.
2.Any cpu with the same physical id are threads or cores in the same physical socket.

以自己的惠普DL380G6为例说明:

①物理cpu个数:
[root@localhost ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
2
②每个物理cpu中core的个数(即核数)
[root@localhost ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq 
cpu cores : 4
③每个物理cpu中逻辑cpu(可能是core、threads或both)的个数
[root@localhost ~]# cat /proc/cpuinfo | grep "siblings" | uniq 
siblings : 8

※这款服务器的cpu蛮强悍的,难怪在许多linux命令中,如iostat中显示有16个cpu之多,这里也请大家注意区分物理cpu和逻辑cpu的区别,不要混淆了。最后能过查询服务器清单发现此款服务器用的cpu是英特尔至强E5540@2.53GHz,四核(Gainestown),二级缓存8MB,正好通过结果验证以上命令。

文章来自: hi.baidu.com
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 1 | 引用: 0 | 查看次数: 1482
发表评论
昵 称:
密 码: 游客发言不需要密码.
验证码: 10+5=?
内 容:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册账号.
字数限制 500 字 | UBB代码 关闭 | [img]标签 关闭