逻辑核心数量超出预期

逻辑核心数量超出预期

我有一个基于 I3-3220 的系统英特尔的信息有 2 个内核,每个内核可支持 4 个线程(或总共支持 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

这似乎表明总线信息:cpu@0 上有 16 个逻辑 CPU,总线信息:cpu@1 上有 16 个逻辑 CPU,并且只启用了 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 个同级 CPU,因此有 16 个逻辑 CPU

为什么这些结果看起来差异如此之大并且哪一个是可信的?

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

答案1

“根据英特尔的信息,它有 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

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

“为什么这些结果看起来差异如此之大,哪一个结果值得信赖?”

它们没有什么不同,只是显示信息的方式不同,我只会使用lscpu最“可信”的,因为它最容易阅读,并且应该包含您需要的任何信息,但它们都是正确的。

“附加问题:如果我确实只启用了 2 个核心中的 1 个,我该如何启用第二个核心?”

您的两个核心都处于活动状态并且超线程已启用,您可以在bios硬件部分关闭超线程,这应该可以很好地将 CPU 数量减半,以便您可以在终端中轻松检查差异lscpu

要禁用和启用单个核心,请使用以下命令

禁用:

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

使能够:

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

该部分是中的cpu0第一行,只需将 0 替换为您要禁用的核心/线程。processorcat /proc/cpuinfo

相关内容