Change the boot arguments to use ony n number of CPU cores instead of m cores which are actually present, PROVIDED n
a) Add "maxcpus=n" in the bootargs during boot time:
linux /boot/vmlinuz-2.6.31-21-generic root=UUID=2ebbae04-b641-44e9-935f-8964159d79cb ro quiet splash maxcpus=n
This will not be persistent across subsequent boots.
b) To make it permanent, modify/edit /etc/default/grub and add "maxcpus=n" in the following line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash maxcpus=n"
Method 2: "Enable/Disable a CPU core on the fly"
On a Linux machine you can get the CPU information from /proc/cpuinfo file. On a dual core machine, you will get the output like this:
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
........
.....
processor : 1
vendor_id : GenuineIntel
........
.....
To disable a core run the following command on a Ubuntu machine:
$ sudo sh -c "echo 'n' > /sys/devices/system/cpu/cpu1/online"
Test if the core is disabled or not, check the /proc/cpuinfo file.
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
........
.....
Now which method to choose from?
Method 1. is recommended since maxcpus=n should optimize some locks and instructions.
Choose Method 2. if you can't afford to restart your machine.
Happy Hacking!!
P.S. These instructions are only tested on a Dual core machine so I have no clue how they will behave on a multi-core(>2) environment.
No comments:
Post a Comment