Setting CPUs online or offline

6.10 LPAR mode z/VM guest KVM guest

Use the chcpu command or the online sysfs attribute of a logical CPU to set a CPU online or offline.

Before you begin

Daemon processes like cpuplugd can change the state of any CPU at any time. Such changes can interfere with manual changes.

Procedure

  1. Optional: Rescan the CPUs to ensure that Linux® has a current list of configured CPUs.
    To initiate a rescan, issue the chcpu command with the -r option.
    # chcpu -r
    Alternatively, you can write 1 to /sys/devices/system/cpu/rescan.

    You might need a rescan for Linux on z/VM® after one or more CPUs have been added to the z/VM guest virtual machine by the z/VM hypervisor.

    Linux on KVM and Linux in LPAR mode automatically detect newly available CPUs.

  2. Change the online state of a CPU by issuing a command of this form:
    # chcpu -e|-d <N>
    where
    <N>
    is the number of the logical CPU.
    -e
    sets an offline CPU online. Only CPUs that are in the configuration state configured can be set online. For Linux on z/VM, all CPUs are in the configured state.
    -d
    sets an online CPU offline.
    Alternatively, you can write 1 to the online sysfs attribute of a CPU to set it online, or 0 to set it offline.
    Examples:
    • The following chcpu commands force a CPU rescan, and then set the logical CPU with number 2 online.
      # chcpu -r
      # chcpu -e 2
      The following commands achieve the same results by writing 1 to the online sysfs attribute of the CPU.
      # echo 1 > /sys/devices/system/cpu/rescan
      # echo 1 > /sys/devices/system/cpu/cpu2/online
    • The following chcpu command sets the logical CPU with number 2 offline.
      # chcpu -d 2
      The following command achieves the same results by writing 0 to the online sysfs attribute of the CPU.
      # echo 0 > /sys/devices/system/cpu/cpu2/online