To hotplug a CPU (add or remove a CPU while the system is running) on a Linux system, you will need to ensure that the kernel and system firmware support hotplugging, and that the system is configured to allow hotplugging.
To check if hotplugging is supported, you can use the ls /sys/devices/system/cpu/cpu*/online
command. If this command returns a list of files, then hotplugging is supported.
To check if hotplugging is enabled, you can use the cat /sys/devices/system/cpu/cpu*/online
command. If this command returns 1
for all CPUs, then hotplugging is enabled.
To enable or disable hotplugging for a specific CPU, you can use the echo 0 > /sys/devices/system/cpu/cpu<n>/online
or echo 1 > /sys/devices/system/cpu/cpu<n>/online
command, where <n>
is the CPU number.
Note: Hotplugging a CPU can be a complex operation and may require specific hardware and firmware support. It is not generally recommended to hotplug CPUs on production systems, as it can potentially cause stability issues.
To disable CPU cores on a Linux system at runtime, you can use the echo 0 > /sys/devices/system/cpu/cpu<n>/online
command, where <n>
is the CPU number. This will disable the specified CPU core.
Note: Disabling CPU cores can also potentially cause stability issues, and should generally only be done for testing or debugging purposes. It is not recommended to disable CPU cores on production systems.