AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 730952
Accepted
Elder Geek
Elder Geek
Asked: 2016-02-08 11:53:06 +0800 CST2016-02-08 11:53:06 +0800 CST 2016-02-08 11:53:06 +0800 CST

逻辑核心数超出预期

  • 772

我有一个带有 I3-3220 的系统,它基于Intel 的信息,有 2 个内核,每个内核(或总共)有 4 个线程。但是,我在观看编码运行时注意到htop分配avconv了 16 个逻辑线程。我在这里和 U&L 上搜索并阅读了许多帖子,并根据我阅读的内容我尝试过

sudo dmidecode |egrep "Socket Designation: Proc|((Thread|Core) Count)"

这导致:

Core Count: 2
Thread Count: 2

所以总共有 4 个逻辑 CPU。

但是lscpu给了我:

Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 58
Stepping:              9
CPU MHz:               3300.000
BogoMIPS:              6606.60
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K

所以总共有 8 个逻辑 CPU。

但sudo lshw -C cpu返回:

  *-cpu:0
       description: CPU
       product: Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
       vendor: Intel Corp.
       physical id: 43
       bus info: cpu@0
       version: 6.10.9
       serial: 0003-06A9-0000-0000-0000-0000
       slot: Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
       size: 3300MHz
       capacity: 3300MHz
       width: 64 bits
       clock: 100MHz
       capabilities: x86-64 boot fpu fpu_exception wp 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 nx rdtscp constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx f16c lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms cpufreq
       configuration: cores=2 enabledcores=1 id=0 threads=2
     *-logicalcpu:0
          description: Logical CPU
          physical id: 0.1
          width: 64 bits
          capabilities: logical
     *-logicalcpu:1
          description: Logical CPU
          physical id: 0.2
          width: 64 bits
          capabilities: logical
     *-logicalcpu:2
          description: Logical CPU
          physical id: 0.3
          width: 64 bits
          capabilities: logical
     *-logicalcpu:3
          description: Logical CPU
          physical id: 0.4
          width: 64 bits
          capabilities: logical
     *-logicalcpu:4
          description: Logical CPU
          physical id: 0.5
          width: 64 bits
          capabilities: logical
     *-logicalcpu:5
          description: Logical CPU
          physical id: 0.6
          width: 64 bits
          capabilities: logical
     *-logicalcpu:6
          description: Logical CPU
          physical id: 0.7
          width: 64 bits
          capabilities: logical
     *-logicalcpu:7
          description: Logical CPU
          physical id: 0.8
          width: 64 bits
          capabilities: logical
     *-logicalcpu:8
          description: Logical CPU
          physical id: 0.9
          width: 64 bits
          capabilities: logical
     *-logicalcpu:9
          description: Logical CPU
          physical id: 0.a
          width: 64 bits
          capabilities: logical
     *-logicalcpu:10
          description: Logical CPU
          physical id: 0.b
          width: 64 bits
          capabilities: logical
     *-logicalcpu:11
          description: Logical CPU
          physical id: 0.c
          width: 64 bits
          capabilities: logical
     *-logicalcpu:12
          description: Logical CPU
          physical id: 0.d
          width: 64 bits
          capabilities: logical
     *-logicalcpu:13
          description: Logical CPU
          physical id: 0.e
          width: 64 bits
          capabilities: logical
     *-logicalcpu:14
          description: Logical CPU
          physical id: 0.f
          width: 64 bits
          capabilities: logical
     *-logicalcpu:15
          description: Logical CPU
          physical id: 0.10
          width: 64 bits
          capabilities: logical
  *-cpu:1
       physical id: 1
       bus info: cpu@1
       version: 6.10.9
       serial: 0003-06A9-0000-0000-0000-0000
       size: 3GHz
       capacity: 3GHz
       capabilities: vmx ht cpufreq
       configuration: id=0
     *-logicalcpu:0
          description: Logical CPU
          physical id: 0.1
          capabilities: logical
     *-logicalcpu:1
          description: Logical CPU
          physical id: 0.2
          capabilities: logical
     *-logicalcpu:2
          description: Logical CPU
          physical id: 0.3
          capabilities: logical
     *-logicalcpu:3
          description: Logical CPU
          physical id: 0.4
          capabilities: logical
     *-logicalcpu:4
          description: Logical CPU
          physical id: 0.5
          capabilities: logical
     *-logicalcpu:5
          description: Logical CPU
          physical id: 0.6
          capabilities: logical
     *-logicalcpu:6
          description: Logical CPU
          physical id: 0.7
          capabilities: logical
     *-logicalcpu:7
          description: Logical CPU
          physical id: 0.8
          capabilities: logical
     *-logicalcpu:8
          description: Logical CPU
          physical id: 0.9
          capabilities: logical
     *-logicalcpu:9
          description: Logical CPU
          physical id: 0.a
          capabilities: logical
     *-logicalcpu:10
          description: Logical CPU
          physical id: 0.b
          capabilities: logical
     *-logicalcpu:11
          description: Logical CPU
          physical id: 0.c
          capabilities: logical
     *-logicalcpu:12
          description: Logical CPU
          physical id: 0.d
          capabilities: logical
     *-logicalcpu:13
          description: Logical CPU
          physical id: 0.e
          capabilities: logical
     *-logicalcpu:14
          description: Logical CPU
          physical id: 0.f
          capabilities: logical
     *-logicalcpu:15
          description: Logical CPU
          physical id: 0.10
          capabilities: logical

这似乎表明总线信息处有 16 个逻辑 CPU:cpu@0 + 总线信息处还有 16 个:cpu@1,并且仅启用了 1 个内核。为了进一步混淆问题cat /proc/cpuinfo返回:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
stepping    : 9
microcode   : 0x10
cpu MHz     : 2800.000
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 13
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 nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx f16c lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips    : 6606.60
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
stepping    : 9
microcode   : 0x10
cpu MHz     : 2400.000
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 1
cpu cores   : 2
apicid      : 2
initial apicid  : 2
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 13
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 nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx f16c lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips    : 6606.60
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 2
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
stepping    : 9
microcode   : 0x10
cpu MHz     : 2600.000
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 1
initial apicid  : 1
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 13
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 nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx f16c lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips    : 6606.60
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 3
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
stepping    : 9
microcode   : 0x10
cpu MHz     : 3300.000
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 1
cpu cores   : 2
apicid      : 3
initial apicid  : 3
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 13
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 nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx f16c lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips    : 6606.60
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

在我看来,这表明 CPU 0-3 各有 4 个兄弟姐妹,因此有 16 个逻辑 CPU

为什么这些结果似乎差异如此之大,哪个值得信赖?

额外的问题:如果我确实只启用了 2 个内核中的 1 个,我该如何启用第二个?

cpu
  • 1 1 个回答
  • 1573 Views

1 个回答

  • Voted
  1. Best Answer
    Mark Kirby
    2016-02-08T13:55:21+08:002016-02-08T13:55:21+08:00

    “基于英特尔的信息有 2 个内核,每个内核可以 4 个线程”

    不完全是,它说的是 2 个内核和 4 个线程,而不是每个内核 4 个线程,这意味着它有 2 个内核,每个内核有 2 个线程,总共 4 个线程。

    我有一个i3-2100双核,和你的差不多,第一个命令

    sudo dmidecode |egrep "Socket Designation: Proc|((Thread|Core) Count)"
    

    给我同样的结果,2 个 cpu 核心,每个有 2 个线程

    lscpu

    说我有

    CPU(s):                4
    On-line CPU(s) list:   0-3
    Thread(s) per core:    2
    Core(s) per socket:    2
    Socket(s):             1
    

    我认为您只是误读了,因为它说4 cpus的是总线程数,这是一个错误的术语选择,当我第一次看时我也很困惑:)。

    您有 1 个插槽、2 个内核和每个内核 2 个线程,它报告总共 4 个 CPU,所以这是正确的。

    至于cat /proc/cpuinfo我的16个逻辑核心是一样的,4个cpu,每个有4个兄弟,但我不知道这是什么意思,所以我查了一下,发现这是服务器故障

    处理器上的兄弟姐妹的数量是该处理器内的执行单元的总数。这将包括额外的核心和超线程。

    例如,

    A Core 2 Duo will list siblings : 2. Dual core, no hyperthreading.
    A Xeon E5420 will list siblings : 4. Dual core, with hyperthreading.
    A Pentium 4 with hyperthreading will list siblings : 2. Single core, with hyperthreading.
    

    所以看起来信息是正确的,你总共有 4 个线程,所以每个线程加上它siblings的总数是 4,看起来这只是为每个线程单独报告。

    至于sudo lshw -C cpu我的输出非常不同,只是

    *-cpu                   
           product: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
           vendor: Intel Corp.
           physical id: 1
           bus info: cpu@0
           size: 1614MHz
           capacity: 3100MHz
           width: 64 bits
           capabilities: fpu fpu_exception wp 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 rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid xsaveopt cpufreq
    

    你确定这是你运行的命令吗?

    “为什么这些结果似乎差异如此之大,哪个值得信赖?”

    They don't vary, they just have different ways of displaying the information, I would just use lscpu as the most "trusted" because it is the easiest to read and should have any information you need but they all are correct.

    "Bonus question: If I do indeed only have 1 of 2 cores enabled how do I enable the second one?"

    Both your cores are active and hyper threading is enabled, you can turn off hyper threading in your bios in the hardware section, this should nicely half the cpu count so you can check the difference easily in a terminal with lscpu.

    To disable and enable a single core use these commands

    Disable:

    echo 0 | sudo tee /sys/devices/system/cpu/cpu0/online
    

    Enable:

    echo 1 | sudo tee /sys/devices/system/cpu/cpu0/online
    

    The part cpu0 is the first line processor in cat /proc/cpuinfo, just swap the 0 for the core / thread you wish to disable.

    • 4

相关问题

  • 如何让“R”使用所有 CPU

  • 华硕上网本:应启用 CPUID 速度限制

  • 我可以更改/调查安装未完成的地方?

  • 如何获得 CPU 温度?

  • 禁用“按需”CPU 缩放守护程序

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve