A resposta anterior é muito interessante.
Depois de algumas pesquisas, encontrei alguns assuntos relacionados:
No último link, o script python não funciona quando seu host possui muitos IDs físicos. Tentei modificá-lo com uma condição diferente no final:
Mudando:
if p > 0:
para
if p % 2 == 1:
Mas não funciona como esperado, com base na mensagem anterior. By the way, você pode fazer algo mais abrangente do que:
grep . /sys/devices/system/cpu/cpu{,1}?/topology/thread_siblings | tr : \\t | sed -r 's,^,\s\s\s\s,'
com:
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
[...]
O que é interessante em muitos hosts de núcleo com hyperthreading enable é a distribuição de núcleos lógicos no hardware.
Por exemplo, em um dos meus computadores (48 núcleos lógicos, 2 processadores físicos, 24 (12 * 2) 'núcleos reais' (portanto, também 24 núcleos virtuais)):
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
Isso significa que cpu0 e cpu24 compartilham o mesmo "endereço" de hardware físico.
Mesma coisa para cpu1 e cpu25 ...
Então, basicamente, se eu gostaria de desabilitar o hyperthreading do meu sistema operacional Linux, eu deveria colocar '0' em cpu {24..47} / online com
for fake_cpu in {24..47}; do echo 0 > /sys/devices/system/cpu/cpu$fake_cpu/online;done
Você notará o quão interessante meu sistema está contando os núcleos.