Michael, quick tip: you don't need to go into the BIOS to enable/disable CPU's, both real and with HT, you can do it all with /sys.
For example, on a dual-quadcore Xeon machine (with HT) I get:
Code:
root:/sys/devices/system/cpu# cat cpu0/topology/core_siblings_list
0,2,4,6,8,10,12,14
This means that these 8 are the first node (uneven numbers are the other).
So, we have 8 cpu's. To find out which ones are paired in the same physical core by HT:
Code:
root:/sys/devices/system/cpu# cat cpu0/topology/thread_siblings_list
0,8
This means that (0,8) are a HT pair. By going through all the others I built a picture to help me when I want to test specific configurations (specific to this machine, but an example):
Code:
Package #0 Package #1
╔══════════════╗ ╔══════════════╗
║┌─────┐┌─────┐║ ║┌─────┐┌─────┐║
║│ 0 ││ 2 │║ ║│ 1 ││ 3 │║
║│ 8 ││ 10 │║ ║│ 9 ││ 11 │║
║└─────┘└─────┘║ ║└─────┘└─────┘║
║┌─────┐┌─────┐║ ║┌─────┐┌─────┐║
║│ 4 ││ 6 │║ ║│ 5 ││ 7 │║
║│ 12 ││ 14 │║ ║│ 13 ││ 15 │║
║└─────┘└─────┘║ ║└─────┘└─────┘║
╚══════════════╝ ╚══════════════╝
So now it's just a matter of doing echo 0 or 1 > /sys/devices/system/cpu/cpuN/online to enable/disable the cores.
I have a quick hackish script to do this second part, here:
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## cpucontrol.py version 0.12
## Quick hack to enable/disable cores on a linux machine
## by Ivo Anjo <knuckles@gmail.com>
import os
import sys
prefix='/sys/devices/system/cpu/'
def get_max_cpu_id():
return int(open(prefix + "present").readlines()[0].split("-")[1])
def change_cpu_state(cpu, state):
os.system("echo '" + str(state) + "' > " + prefix + "cpu" + str(cpu) + "/online")
if len(sys.argv) != 2:
print "syntax: " + sys.argv[0] + " comma-separated list of cpus to put online"
print "\t\texample: 1,2,3"
print "\t\texample: all"
print "\t\tnote: cpu0 cannot be disabled"
sys.exit(1)
# disable all cpus
for i in range(1, get_max_cpu_id()+1):
change_cpu_state(i, 0)
# hack to support 'all'
if sys.argv[1].strip().lower() == 'all':
# enable all
for i in range(1, get_max_cpu_id()+1):
change_cpu_state(i, 1)
else:
# enable the ones requested
for i in sys.argv[1].split(','):
if int(i) != 0:
change_cpu_state(i, 1)
print "Online:", open(prefix + "online").readlines()[0],
print "Possible:", open(prefix + "present").readlines()[0],