Home » Linux

How to Hot plug CPU in RHEL 5

4 August 2009 by Manuj Mohla No Comment

Red Hat Enterprise Linux 5 supports the cpu-hotplug mechanism, which allows for CPUs to be dynamically disabled and re-enabled on a system without requiring a system reboot. Note: CPU hot-plugging will only work if physical hotplug is supported by the hardware. A more novel use of CPU-hotplug support is its use in suspend resume support for SMP. Dual-core and HT support makes even a laptop run SMP kernels which didn’t support these methods.

In order to disable a CPU core in a running machine, use the file /sys/devices/system/cpu/cpuX/online.

The following command will disable a CPU:

# echo 0 > /sys/devices/system/cpu/cpuX/online

Where X is the ID of the CPU as determined from /proc/cpuinfo.

To re-enable the CPU, run:

# echo 1 > /sys/devices/system/cpu/cpuX/online

Example:

The following output from /proc/cpuinfo shows two processors on a system:

root@xen # grep “processor” /proc/cpuinfo
processor       : 0
processor       : 1

In order to disable CPU 1, echo “0″ to /sys/devices/system/cpu/cpu1/online:

root@xen# echo 0 > /sys/devices/system/cpu/cpu1/online
cpu0/ cpu1/

Check /proc/cpuinfo to see if the cpu is disabled .

root@xen # grep “processor” /proc/cpuinfo
processor       : 0

Notice that there is now only one processor shown (CPU 0) instead of two.

Note: There are some architectures in which a CPU cannot be disabled due to a dependency on a certain CPU. In such cases you will notice that the /sys/devices/system/cpu/cpuN/online file is missing.

For further details on CPU hotplugging, see this file:

/usr/share/doc/kernel-doc-2.6.18/Documentation/cpu-hotplug.txt

The documentation files are in the kernel-doc package, which can be installed from RHN.

logo_rh_home

Blog Widget by LinkWithin

Random Posts

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.