Is it possible to disable a CPU (not a core)?
Is it possible to disable a CPU, not a core? I want to do a test to verify if the performance could make a big difference or not.
I'm using Ubuntu 10.10.
Solution 1:
Besides doing this in your BIOS grub has an option called maxcpus
.
You can edit this option in when selecting your grub boot option by adding maxcpus=1
to the parameters. Random grub picture:
Choose 'e' and you get to a command line where you can add options.
You can also create permanent boot option in grub by making a copy of your current boot option and add maxcpus=1
to the boot parameters. You can name this 'Ubuntu, kernel 2.5.12-9-386 (1 cpu)' and have it amongst the other boot options like the picture shows.
You can verify running on 1 cpu by issuing:
cat /proc/cpuinfo | grep processor
this should show something like this:
processor : 0 processor : 1
And the 2nd line should disappear after booting with 1 CPU.
Solution 2:
You can dynamically disable CPUs via /sys/devices/system/cpu/cpuN/online
, for example to disable CPU 1, use:
echo 0 | sudo tee /sys/devices/system/cpu/cpu1/online
and to re-enable, use:
echo 1 | sudo tee /sys/devices/system/cpu/cpu1/online
Solution 3:
You can always unplug the CPU from its socket. It's brute force, but you're guaranteed to get the test you want, and you don't have to worry if the kernel/BIOS/whatever switch is really doing what you hope it's doing.
My company has large installations of server farms in various locations around the world. In our lab we'll sometimes remove CPUs from sockets for just such a test.
There's an interesting variation on this test that you can do with multi-CPU NUMA systems. On those types of motherboards you can remove all of the memory DIMMs that are controlled by one physical CPU. The system will still boot just fine, and you can then run tests with your application pinned to various cores which will allow you to measure the affects of "local" or "remote" memory.