• Linux cpuinfo 查看cpu信息详解(转载)


    转自:http://icooke.blog.51cto.com/4123148/757555

    在Linux系统中,如何详细了解CPU的信息呢? 当然是通过cat /proc/cpuinfo来检查了,但是比如几个物理CPU/几核/几线程,这些问题怎么确定呢?

    经过查看,我的开发机器是1个物理CPU,4核8线程,Intel(R) Core(TM) i7 CPU 860  @ 2.80GHz
    记录一下,判断的过程和知识。
     
    判断依据:
    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.
     
    echo "logical CPU number:"
    #逻辑CPU个数
    cat /proc/cpuinfo | grep "processor" | wc -l
     
    echo "physical CPU number:"
    #物理CPU个数:
    cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l
     
    echo "core number in a physical CPU:"
    #每个物理CPU中Core的个数:
    cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'
    #查看core id的数量,即为所有物理CPU上的core的个数
    cat /proc/cpuinfo | grep "core id" | uniq |  wc -l
     
    #是否为超线程?
    #如果有两个逻辑CPU具有相同的”core id”,那么超线程是打开的。或者siblings数目比cpu cores数目大。
    #每个物理CPU中逻辑CPU(可能是core, threads或both)的个数:
    cat /proc/cpuinfo | grep "siblings"
     
     
    /proc/cpuinfo 文件包含系统上每个处理器的数据段落。/proc/cpuinfo 描述中有 6 个条目适用于多内核和超线程(HT)技术检查:processor, vendor id, physical id, siblings, core id 和 cpu cores。
    processor 条目包括这一逻辑处理器的唯一标识符。
    physical id 条目包括每个物理封装的唯一标识符。
    core id 条目保存每个内核的唯一标识符。
    siblings 条目列出了位于相同物理封装中的逻辑处理器的数量。
    cpu cores 条目包含位于相同物理封装中的内核数量。
    如果处理器为英特尔处理器,则 vendor id 条目中的字符串是 GenuineIntel。
     
    如果cpu cores与 siblings 相同,则说明没有使用超线程,如果siblings 是cpu cores的2倍,则说明支持2个超线程.
     
    例子: 2 x cpu时,假如每个cpu 2 核心,而每个核心又使用2个超线程.则可以看到8个实际可用的cpu.
     processor
     0
     1
     2
     3
     4
     5
     6
     7    8个实际可用的cpu.
     physical id
     0
     1
     0
     1
     0
     1
     0
     1    2个物理cpu.
     core id
     0
    2
    1
     3
     0
     2
     1
     3    每个cpu里的内核的际识.
     siblings
     4
     4
     4
     4
     4
     4
     4
     4    说明每个每个物理cpu实际有4个兄弟姐妹.实为2cpu x 2 核 x 2 超线 = 8.
     cpu cores
     2
     2
     2
     2
     2
     2
     2
     2    每个cpu是2核的
     
    1.拥有相同 physical id 的所有逻辑处理器共享同一个物理插座。每个 physical id 代表一个唯一的物理封装。
    2.Siblings 表示位于这一物理封装上的逻辑处理器的数量。它们可能支持也可能不支持超线程(HT)技术。
    3.每个 core id 均代表一个唯一的处理器内核。所有带有相同 core id 的逻辑处理器均位于同一个处理器内核上。
    4.如果有一个以上逻辑处理器拥有相同的 core id 和 physical id,则说明系统支持超线程(HT)技术。
    5.如果有两个或两个以上的逻辑处理器拥有相同的 physical id,但是 core id 不同,则说明这是一个多内核处理器。cpu cores 条目也可以表示是否支持多内核。
     
    判断CPU是否64位,检查cpuinfo中的flags区段,看是否有lm标识。(或者在命令行输入getconf LONG_BIT)
    Are the processors 64-bit?   
    A 64-bit processor will have lm ("long mode") in the flags section of cpuinfo. A 32-bit processor will not.
  • 相关阅读:
    C#之流程控制
    UML画图总结以及浅谈UNL九种图
    UML视频总结
    英语总结
    UML coming
    那天我把“小四”拆了
    first 关于文档(总结)
    机房收费需求分析文档
    梦开始的地方
    WebRTC 开发实践:为什么你需要 SFU 服务器
  • 原文地址:https://www.cnblogs.com/wangj08/p/2823469.html
Copyright © 2020-2023  润新知