Linux 中的 CPU 排序(使用超线程)
我很好奇 Linux 中的 CPU 顺序是什么。假设我在超线程系统上将一个线程绑定到 cpu0,另一个线程绑定到 cpu1,它们是否都位于同一个物理核心上。给定具有 4 个核心和超线程的 Core i7 920,/proc/cpuinfo 的输出让我认为 cpu0 和 cpu1 是不同的物理核心,而 cpu0 和 cpu4 位于同一物理核心上。
谢谢。
I'm curious what the CPU ordering is in Linux. Say I bind a thread to cpu0 and another to cpu1 on a hyperthreaded system, are they both going to be on the same physical core. Given a Core i7 920 with 4 cores and hyperthreading, the output of /proc/cpuinfo has me thinking that cpu0 and cpu1 are different physical cores, and cpu0 and cpu4 are on the same physical core.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
物理 CPU/插槽列为
物理 ID
。物理核心列为
核心 ID
。由于超线程,处理器条目将获得自己的处理器,但与另一个处理器共享核心 ID 和物理 ID。
请注意,每个物理 cpu (
physical id
) 可以有多个核心 (core id
),这些核心可以通过超线程进一步分解为额外的逻辑 cpu。逻辑 cpu 总体上按处理器 ID
排序。这里有详细的解释和示例: archive.richweb.com /cpu_info 来自 web.archive.org
The physical cpu/socket is listed as
physical id
.The physical core is listed as
core id
.A processor entry due to hypherthreading will get its own
processor
, but sharecore id
andphysical id
with another.Note that each physical cpu (
physical id
) can have multiple cores (core id
), which can further be broken up into additional logical cpus by hyperthreading. The logical cpus are overall ordered byprocessor id
.There's a detailed explanation with examples here: archive.richweb.com/cpu_info via web.archive.org
您可以使用 likwid-topology -g 来获取 CPU 的图形拓扑。它显示每个 cpu 主核心以及同级核心。
You can use
likwid-topology -g
to get graphical topology of the cpu. It shows each cpu primary cores along with the sibling core.请参阅此链接中提供的指针。有关物理处理器、内核和超线程的信息全部位于 /proc/cpuinfo 中,但您必须匹配该文件中多个条目的信息,以识别哪些条目组合在一起。
See the pointer provided in this link. The information is all in /proc/cpuinfo with regards to physical processors, cores, and hyperthreading, but you have to match info from multiple entries in that file to identify which ones group together.