Linux Hotplug a CPU and Disable CPU Cores At Run Time
Hotplugging a CPU involves adding or removing a CPU from a running system without shutting down the system. In Linux, you can hotplug a CPU and disable CPU cores at run time using the following steps:
- Check if your system supports CPU hotplugging:
cat /sys/devices/system/cpu/cpu*/onlineThis command will show the current status of all CPUs in the system. If your system supports hotplugging, you should see a file named "hotplug" under each CPU directory.
- Disable a CPU core:
echo 0 > /sys/devices/system/cpu/cpuX/onlineReplace "cpuX" with the CPU core number you want to disable. For example, to disable CPU core 3, use "cpu3".
- Check if the CPU core is disabled:
cat /sys/devices/system/cpu/cpuX/onlineThis command should return "0", indicating that the CPU core is disabled.
- Enable a CPU core:
echo 1 > /sys/devices/system/cpu/cpuX/onlineThis will enable the CPU core that you disabled in step 2.
