GagA// 0n D nEt

It is currently Sun Feb 25, 2018 12:01 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux: Dynamically enable or disable a CPU (Hot Plug CPU)
PostPosted: Sun Apr 05, 2009 3:22 pm 
Offline

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
You may find a need to dynamically enable or disable a CPU for a few mission critical servers without a reboot. This can be achieved on a linux system. The linux kernel do support the ability to enable or disable a CPU on a running system, this is also called hot plugging a CPU.

This feature works well on a mission critical servers which cannot be taken down. It can also be used to replace the failed components of a CPU at the same time be used to increase the productivity for the system. You can also take an example of setting up a new server which is having additional CPUs attached to it, but not activated. The only reason to have them was to serve better for growth of load and other process utilization taking into consideration the future growth. Also, in the case of a single system running multiple Linux partitions, as the workloads change it would be extremely useful to be able to move CPUs from one partition to the next as required without rebooting or interrupting the workloads. This is known as dynamic partitioning.

Listing the current CPU present on a Linux system

You need to go to following location to find the list of currently attached CPUs:

Quote:
[[email protected] ~]# cd /sys/devices/system/cpu

List the content of this folder to get a list of all the CPU present
Quote:

Output:
Code:
total 0
drwxr-xr-x 4 root root    0 Mar  2 10:07 cpu0
drwxr-xr-x 4 root root    0 Mar  2 10:07 cpu1
drwxr-xr-x 4 root root    0 Apr 1  09:08 cpu2

You can see above the different CPUs attached to the system. In each of these directories/folders there is a file called "online" which controls to enable/disable a processor.

You can also check the presently active/enabled CPUs by using the following command:
Quote:
[[email protected] ~]# grep "processor" /proc/cpuinfo

Output:
Code:
processor   : 0
processor   : 1
processor   : 2


Disabling a CPU Dynamically

In order to disable a CPU (say the 3rd CPU which is cpu2) you will need to use the following command:
Quote:
[[email protected] ~]# echo 0 > /sys/devices/system/cpu/cpu2/online

You have just disabled the third CPU of the system. Verify it using the following command:
Quote:
[[email protected] ~]# grep "processor" /proc/cpuinfo

Output:
Code:
processor   : 0
processor   : 1


Enabling a CPU Dynamically

The following is the command that you can use to enable a CPU again (cpu2 again):
Quote:
[[email protected] ~]# echo 1 > /sys/devices/system/cpu/cpu2/online

Verify the result
Quote:
[[email protected] ~]# grep "processor" /proc/cpuinfo

Output:
Code:
processor   : 0
processor   : 1
processor   : 2


Once you have disabled a CPU, you can then physically remove the disabled CPU, in case the BIOS or the server model supports such operation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group