Linux找出超线程核心ID [英] Linux find out Hyper-threaded core id
问题描述
今天上午我花了很多时间来找出如何确定哪个处理器ID是超线程内核,但是没有运气.
I spent this morning trying to find out how to determine which processor id is the hyper-threaded core, but without luck.
我希望找出这些信息,并使用set_affinity()
将进程绑定到超线程线程或非超线程线程,以描述其性能.
I wish to find out this information and use set_affinity()
to bind a process to hyper-threaded thread or non-hyper-threaded thread to profile its performance.
推荐答案
我发现了做我需要的简单技巧.
I discovered the simply trick to do what I need.
cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list
如果第一个数字等于CPU编号(在此示例中为0),则它是一个真正的内核,否则,它是一个超线程内核.
If the first number is equal to the CPU number (0 in this example) then it's a real core, if not it is a hyperthreading core.
真实的核心示例:
# cat /sys/devices/system/cpu/cpu1/topology/thread_siblings_list
1,13
超线程核心示例
# cat /sys/devices/system/cpu/cpu13/topology/thread_siblings_list
1,13
第二个示例的输出与第一个示例完全相同.但是,我们正在检查cpu13
,第一个数字是1
,因此CPU 13是超线程内核.
The output of the second example is exactly the same as the first one. However we are checking cpu13
, and the first number is 1
, so CPU 13 this is an hyperthreading core.
这篇关于Linux找出超线程核心ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!