chcpu
Manage CPU online/offline status
TLDR
Disable one or more CPUs by their IDs
Enable one or more ranges of CPUs by their IDs
SYNOPSIS
chcpu [options] [cpulist] command
PARAMETERS
-h, --help
Display help and exit
-V, --version
Output version information
-v, --verbose
Enable verbose output
-i, --ignore-offline
Ignore offlined CPUs in operations
-p, --cpu-list cpulist
Specify comma-separated CPU list (alternative to positional arg)
--disable[=cpulist]
Disable listed CPUs (prevent onlining)
--enable[=cpulist]
Enable listed CPUs (allow onlining)
--offline[=cpulist]
Take listed CPUs offline
--online[=cpulist]
Bring listed CPUs online
--status[=cpulist]
Print status of listed CPUs (online/offline)
DESCRIPTION
The chcpu command is a utility from the util-linux package used to dynamically change the state of CPUs in a running Linux system. It supports enabling or disabling CPUs, bringing them online or offline, and querying their status. This is particularly useful for power management, performance tuning, testing multi-CPU configurations, or handling hardware faults.
chcpu interacts with the Linux kernel's CPU hotplug subsystem via sysfs (/sys/devices/system/cpu/). Offlining a CPU migrates its tasks to other CPUs and stops scheduling new ones on it, while onlining reverses this. Disabling prevents a CPU from being brought online, and enabling allows it.
Requires root privileges (use sudo). Not all systems support CPU hotplug; it depends on kernel configuration (CONFIG_HOTPLUG_CPU) and hardware (e.g., SMP systems). CPU 0 (bootstrap processor) typically cannot be offlined. Verbose mode provides detailed output on operations.
cpulist format: comma-separated ranges like 0-3,7,9-11. Use lscpu to list available CPUs.
CAVEATS
Requires root privileges. CPU 0 usually cannot be offlined. Hotplug support varies by kernel/hardware. Offlining may fail if CPU has critical tasks or dependencies.
CPULIST SYNTAX
Format: cpu[,cpu]... or cpu-cpu[,cpu]... (e.g., 0-3,7)
SYSFS PATHS
Operates on /sys/devices/system/cpu/cpu*/online and /sys/devices/system/cpu/cpu*/uevent
HISTORY
Introduced in util-linux 2.26 (March 2014) to simplify CPU hotplug management via sysfs. Builds on kernel CPU hotplug feature added in Linux 2.6 (2003). Widely used in enterprise servers and HPC for dynamic resource control.


