IBM Support

Dynamically Adding or Removing CPUs in a Linux z/VM Guest

How To


Summary

This document shows how to add or remove a CP or IFL (Integrated Facility for Linux) dedicated processor to a Linux guest running on the IBM Z mainframe platform under z/VM.
Please see the warning below regarding removing a CPU from a running Linux guest.

Steps

Adding CPUs to our Linux guest hosted under z/VM on the IBM Z mainframe.


You can dynamically add CPUs to your guest and have them available to Linux.   
* If you manually add CPUs to the guest, and reboot Linux, they will be seen again when Linux is up.
* If you manually add CPUs to the guest, but do not define them in the guest’s USER DIRECT, they will go away when the guest logs out.

First define the cpus at the z/VM level.  If you'd like to do this with the Linux guest up, use the "vmcp" tool in Linux.  This is supplied by the s390-tools package.
In this example I'm adding 2 CP processors.  If you are adding IFLs you will set the "type" to "ifl".
There are other types also but Linux uses CP or IFL processors
s390linux# vmcp define cpu 02 type cp
CPU 02 defined
s390linux# vmcp define cpu 03 type cp
CPU 03 defined
or from the console:
00: CP DEFINE CPU 02 TYPE CP
00: CPU 02 defined
00: CP DEFINE CPU 03 TYPE CP
00: CPU 03 defined
Now query z/VM to find out if the CPUs show up:
s390linux# vmcp q v cpus
CPU 01  ID  FF0288F728288000 CP   CPUAFF ON
CPU 02  ID  FF0288F728288000 STOPPED CP   CPUAFF ON
CPU 03  ID  FF0288F728288000 STOPPED CP   CPUAFF ON
CPU 00  ID  FF0288F728288000 (BASE) CP   CPUAFF ON
Notice 2 and 3 are stopped right now.
They won’t show up in Linux lscpu -ae yet until we online them
Use chcpu -r to rescan the guest for the new cpus.  In recent versions of the s390 utilities package the rescan will also cause the new CPU to go online:
s390linux# chcpu -r
Triggered rescan of CPUs
You may see messages on the console for the cpus that go online

03: HCPGSP2627I The virtual machine is placed in CP mode due to a SIGP initial C
PU reset from CPU 01.
Now they show up in Linux and are online:

s390linux:~ # lscpu -ae
CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2d:L2i ONLINE CONFIGURED POLARIZATION ADDRESS
0   0    0      0    0      0    0:0:0:0         yes    yes        horizontal   0
1   0    1      1    1      1    1:1:1:1         yes    yes        horizontal   1
2   0    2      2    2      2    2:2:2:2         yes    yes        horizontal   2
3   0    3      3    3      3    3:3:3:3         yes    yes        horizontal   3
They also show online at the z/VM level:

s390linux:~ # vmcp q v cpus
CPU 02  ID  FF0288F728288000 CP   CPUAFF ON
CPU 03  ID  FF0288F728288000 CP   CPUAFF ON
CPU 00  ID  FF0288F728288000 (BASE) CP   CPUAFF ON
CPU 01  ID  FF0288F728288000 CP   CPUAFF ON
You may have to manually set them online:

# chcpu -e 02
CPU 2 enabled
You’ll see a message on the console if you do this:
02: HCPGSP2627I The virtual machine is placed in CP mode due to a SIGP initial C
PU reset from CPU 00.
# chcpu -e 03

# cd /sys/devices/system/cpu
s390linux:/sys/devices/system/cpu # cat online
0-3

Disabling and removing CPUs

You can stop the cpus (disable them) from Linux if you do not want to use them any more:
s390linux:~ # vmcp q v cpus
CPU 00  ID  FF0288F728288000 (BASE) CP   CPUAFF ON
CPU 01  ID  FF0288F728288000 CP   CPUAFF ON
CPU 02  ID  FF0288F728288000 CP   CPUAFF ON
CPU 03  ID  FF0288F728288000 CP   CPUAFF ON
s390linux:~ # chcpu -d 03
CPU 3 disabled

on the console you’ll see:
03: HCPGSP2629I The virtual machine is placed in CP mode due to a SIGP stop from
 CPU 03.
s390linux:~ # chcpu -d 02
CPU 2 disabled
Notice they still show up in lscpu, just they are offline:

s390linux:~ # lscpu -e
CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2d:L2i ONLINE CONFIGURED POLARIZATION ADDRESS
0   0    0      0    0      0    0:0:0:0         yes    yes        horizontal   0
1   0    1      1    1      1    1:1:1:1         yes    yes        horizontal   1
2   0    -      -    -      -    :::             no     yes        horizontal   2
3   0    -      -    -      -    :::             no     yes        horizontal   3
At the z/VM level they are also stopped:

s390linux:~ # vmcp q v cpus
CPU 00  ID  FF0288F728288000 (BASE) CP   CPUAFF ON
CPU 01  ID  FF0288F728288000 CP   CPUAFF ON
CPU 02  ID  FF0288F728288000 STOPPED CP   CPUAFF ON
CPU 03  ID  FF0288F728288000 STOPPED CP   CPUAFF ON

At this point they are seen by Linux but are not processing. 

IMPORTANT WARNING:

If you want to remove them completely from the guest, that will reset the system.  This will take the guest down immediately to a CP level.  So if Linux or another OS is running in the guest, it will immediately stop without a clean shut down.
So make sure your guest OS is not running when you detach any of the CPUs.
00: DETACH CPU 02
00: CPU 02 detached
00: Storage cleared - system reset.

00: DETACH CPU 03
00: CPU 03 detached
00: Storage cleared - system reset.

00: Q V CPUS
00: CPU 00  ID  FF0288F728288000 (BASE) STOPPED CP   CPUAFF ON
00: CPU 01  ID  FF0288F728288000 STOPPED CP   CPUAFF ON

Document Location

Worldwide

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SGMV168","label":"SUSE Linux Enterprise Server"},"Component":"","Platform":[{"code":"PF051","label":"Linux on IBM Z Systems"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
01 April 2021

UID

ibm10964670