先前的答案非常有趣。
经过一番谷歌搜索,我发现了一些相关的主题:
在最后一个链接上,当主机具有许多物理ID时,python脚本不起作用。我试图在最后用其他条件修改它:
变更:
if p > 0:
至
if p % 2 == 1:
但是,根据先前的消息,它不能按预期方式工作。顺便说一句,您可以做一些比以下更全面的事情:
grep . /sys/devices/system/cpu/cpu{,1}?/topology/thread_siblings | tr : \\\t | sed -r 's,^,\s\s\s\s,'
与:
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
[...]
在启用超线程的许多内核主机上,有趣的是硬件上逻辑内核的分布。
例如,在我的一台计算机上(48个逻辑内核,2个物理处理器,24个(12 * 2)“真实内核”(因此也有24个虚拟内核)):
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
/sys/devices/system/cpu/cpu0/topology/thread_siblings_list 0,24
/sys/devices/system/cpu/cpu24/topology/thread_siblings_list 0,24
/sys/devices/system/cpu/cpu1/topology/thread_siblings_list 1,25
/sys/devices/system/cpu/cpu25/topology/thread_siblings_list 1,25
/sys/devices/system/cpu/cpu26/topology/thread_siblings_list 2,26
/sys/devices/system/cpu/cpu2/topology/thread_siblings_list 2,26
/sys/devices/system/cpu/cpu27/topology/thread_siblings_list 3,27
/sys/devices/system/cpu/cpu3/topology/thread_siblings_list 3,27
/sys/devices/system/cpu/cpu28/topology/thread_siblings_list 4,28
/sys/devices/system/cpu/cpu4/topology/thread_siblings_list 4,28
/sys/devices/system/cpu/cpu29/topology/thread_siblings_list 5,29
/sys/devices/system/cpu/cpu5/topology/thread_siblings_list 5,29
/sys/devices/system/cpu/cpu30/topology/thread_siblings_list 6,30
/sys/devices/system/cpu/cpu6/topology/thread_siblings_list 6,30
/sys/devices/system/cpu/cpu31/topology/thread_siblings_list 7,31
/sys/devices/system/cpu/cpu7/topology/thread_siblings_list 7,31
/sys/devices/system/cpu/cpu32/topology/thread_siblings_list 8,32
/sys/devices/system/cpu/cpu8/topology/thread_siblings_list 8,32
/sys/devices/system/cpu/cpu33/topology/thread_siblings_list 9,33
/sys/devices/system/cpu/cpu9/topology/thread_siblings_list 9,33
/sys/devices/system/cpu/cpu10/topology/thread_siblings_list 10,34
/sys/devices/system/cpu/cpu34/topology/thread_siblings_list 10,34
/sys/devices/system/cpu/cpu11/topology/thread_siblings_list 11,35
/sys/devices/system/cpu/cpu35/topology/thread_siblings_list 11,35
/sys/devices/system/cpu/cpu12/topology/thread_siblings_list 12,36
/sys/devices/system/cpu/cpu36/topology/thread_siblings_list 12,36
/sys/devices/system/cpu/cpu13/topology/thread_siblings_list 13,37
/sys/devices/system/cpu/cpu37/topology/thread_siblings_list 13,37
/sys/devices/system/cpu/cpu14/topology/thread_siblings_list 14,38
/sys/devices/system/cpu/cpu38/topology/thread_siblings_list 14,38
/sys/devices/system/cpu/cpu15/topology/thread_siblings_list 15,39
/sys/devices/system/cpu/cpu39/topology/thread_siblings_list 15,39
/sys/devices/system/cpu/cpu16/topology/thread_siblings_list 16,40
/sys/devices/system/cpu/cpu40/topology/thread_siblings_list 16,40
/sys/devices/system/cpu/cpu17/topology/thread_siblings_list 17,41
/sys/devices/system/cpu/cpu41/topology/thread_siblings_list 17,41
/sys/devices/system/cpu/cpu18/topology/thread_siblings_list 18,42
/sys/devices/system/cpu/cpu42/topology/thread_siblings_list 18,42
/sys/devices/system/cpu/cpu19/topology/thread_siblings_list 19,43
/sys/devices/system/cpu/cpu43/topology/thread_siblings_list 19,43
/sys/devices/system/cpu/cpu20/topology/thread_siblings_list 20,44
/sys/devices/system/cpu/cpu44/topology/thread_siblings_list 20,44
/sys/devices/system/cpu/cpu21/topology/thread_siblings_list 21,45
/sys/devices/system/cpu/cpu45/topology/thread_siblings_list 21,45
/sys/devices/system/cpu/cpu22/topology/thread_siblings_list 22,46
/sys/devices/system/cpu/cpu46/topology/thread_siblings_list 22,46
/sys/devices/system/cpu/cpu23/topology/thread_siblings_list 23,47
/sys/devices/system/cpu/cpu47/topology/thread_siblings_list 23,47
这意味着cpu0和cpu24共享相同的物理硬件“地址”。对于cpu1和cpu25同样...
因此,基本上,如果我想从我的Linux操作系统中禁用超线程,则应将'0'放在cpu {24..47} / online中,
for fake_cpu in {24..47}; do echo 0 > /sys/devices/system/cpu/cpu$fake_cpu/online;done
您会注意到我的系统对内核进行编号有多么有趣。
ht
标志仅指示CPU支持多线程(HTT),而不显示是否启用。即使这样,也不能总是依靠,例如,它错误地表明,在i5 i5-6500支持HTT:ark.intel.com/content/www/us/en/ark/products/88184/...