Is it possible to "hotplug" a CPU on a running Red Hat Enterprise Linux?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5

Issue

  • Is it possible to hotplug a CPU on a running Red Hat Enterprise Linux system?
  • How to dynamically enable or disable a CPU on a running system.

Resolution

Red Hat Enterprise Linux 5, and subsequent releases, supports the cpu-hotplug mechanism, which allows for CPUs to be dynamically disabled and re-enabled on a system without requiring a system reboot.

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

Note: CPU hot-plugging will only work if physical hotplug is supported by the hardware.

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 or not writeable.

For further details on CPU hotplugging, see this file:

/usr/share/doc/kernel-doc-<kernel-version>/Documentation/cpu-hotplug.txt

The documentation files are in the kernel-doc package, which can be installed from the Red Hat Network via yum install kernel-doc.

SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.