La risposta precedente è molto interessante.
Dopo aver cercato su Google, ho trovato alcuni argomenti correlati:
Nell'ultimo collegamento, lo script python non funziona quando l'host ha molti ID fisici. Ho provato a modificarlo con una condizione diversa alla fine:
Mutevole:
if p > 0:
per
if p % 2 == 1:
Ma non funziona come previsto, in base al messaggio precedente. A proposito, puoi fare qualcosa di più completo di:
grep . /sys/devices/system/cpu/cpu{,1}?/topology/thread_siblings | tr : \\\t | sed -r 's,^,\s\s\s\s,'
con:
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
[...]
Ciò che è interessante su un host con molti core con abilitazione hyperthreading è la distribuzione di core logici sull'hardware.
Ad esempio, su uno dei miei computer (48 core logici, 2 processori fisici, 24 (12 * 2) "core reali" (quindi anche 24 core virtuali)):
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
Significa che cpu0 e cpu24 condividono lo stesso "indirizzo" fisico dell'hardware. Stessa cosa per cpu1 e cpu25 ...
Quindi, in sostanza, se desidero disabilitare l'hyperthreading dal mio sistema operativo Linux, dovrei mettere '0' in cpu {24..47} / online con
for fake_cpu in {24..47}; do echo 0 > /sys/devices/system/cpu/cpu$fake_cpu/online;done
Noterai quanto sia interessante il mio sistema numerando i core.
ht
flag indica solo che il multi-threading (HTT) è supportato dalla CPU, non se è abilitato o meno. Anche in questo caso, non si può sempre fare affidamento, ad esempio, indica erroneamente che un i5-6500 supporta HTT: ark.intel.com/content/www/us/en/ark/products/88184/…