Virtual processor management within a partition

The kernel scheduler has been enhanced to dynamically increase and decrease the use of virtual processors in conjunction with the instantaneous load of the partition, as measured by the physical utilization of the partition.

Every second, the kernel scheduler evaluates the number of virtual processors that should be activated to accommodate the physical utilization of the partition. If the number yields a high virtual processor utilization, the base number of virtual processors required is incremented to enable the workload to expand. You can request additional virtual processors with the schedo command. The value is then used to determine whether a virtual processor needs to be enabled or disabled, as the scheduler only adjusts the number of virtual processors in use each second by one. So, if the calculated number is greater than the number of virtual processors that are currently activated, a virtual processor is activated. If the number is less than the number of virtual processors that are currently activated, a virtual processor is deactivated.

When virtual processors are deactivated, they are not dynamically removed from the partition as with DLPAR. The virtual processor is no longer a candidate to run on or receive unbound work, however it can still run bound jobs. The number of online logical processors and online virtual processors that are visible to the user or applications does not change. There are no impacts to the middleware or the applications running on the system because the active and inactive virtual processors are internal to the system.

The default value of the vpm_xvcpus tunable parameter is 0, which signifies that folding is enabled. This means that the virtual processors are being managed. You can use the schedo command to modify the vpm_xvcpus tunable parameter.

To determine whether or not the virtual processor management feature is enabled, you can use the following command:
# schedo -o vpm_xvcpus
To increase the number of virtual processors in use by 1, you can use the following command:
# schedo -o vpm_xvcpus=1
Each virtual processor can consume a maximum of one physical processor. The number of virtual processors needed is determined by calculating the sum of the physical CPU utilization and the value of the vpm_xvcpus tunable, as shown in the following equation:
Number of virtual processors needed = 
Physical CPU utilization + Number of additional virtual processors to enable

If the number of virtual processors needed is less than the current number of enabled virtual processors, a virtual processor is disabled. If the number of virtual processors needed is greater than the current number of enabled virtual processors, a disabled virtual processor is enabled. Threads that are attached to a disabled virtual processor are still allowed to run on it.

Note: You should always round up the value that is calculated from the above equation to the next integer.

The following example describes how to calculate the number of virtual processors to use:

Over the last interval, partition A is utilizing two and a half processors. The vpm_xvcpus tunable is set to 1. Using the above equation,
Physical CPU utilization = 2.5
Number of additional virtual processors to enable (vpm_xvcpus) = 1

Number of virtual processors needed = 2.5 + 1 = 3.5
Rounding up the value that was calculated to the next integer equals 4. Therefore, the number of virtual processors needed on the system is 4. So, if partition A was running with 8 virtual processors, 4 virtual processors are disabled and 4 virtual processors remain enabled. If SMT is enabled, each virtual processor yields 2 logical processors. So, 8 logical processors are disabled and 8 logical processors are enabled.
In the following example, a modest workload that is running without the folding feature enabled consumes a minimal amount of each virtual processor that is allocated to the partition. The following output from the mpstat -s tool on a system with 4 virtual CPUs, indicates the utilization for the virtual processor and the two logical processors that are associated with it:
        Proc0                    Proc2                   Proc4                         Proc6
        19.15%                   18.94%                  18.87%                       19.09%
    cpu0      cpu1           cpu2      cpu3          cpu4      cpu5               cpu6      cpu7
   11.09%   8.07%           10.97%   7.98%          10.93%   7.93%               11.08%   8.00%

When the folding feature is enabled, the system calculates the number of virtual processors needed with the equation above. The calculated value is then used to decrease the number of virtual processors to what is needed to run the modest workload without degrading performance. The following output from the mpstat -s tool on a system with 4 virtual CPUs, indicates the utilization for the virtual processor and the two logical processors that are associated with it:
        Proc0                     Proc2                   Proc4                      Proc6
        54.63%                    0.01%                   0.00%                      0.08%
    cpu0      cpu1            cpu2     cpu3           cpu4     cpu5              cpu6     cpu7
   38.89%   15.75%            0.00%    0.00%           0.00%   0.00%             0.03%    0.05%

As you can see from the data above, the workload benefits from a decrease in utilization and maintenance of ancillary processors, and increased affinity when the work is concentrated on one virtual processor. When the workload is heavy however, the folding feature does not interfere with the ability to use all the virtual CPUs, if needed.