|
|
Log in / Subscribe / Register

Using steal time to moderate CPU demands

By Jonathan Corbet
August 27, 2026
Virtualization can increase CPU utilization by allowing a large number of virtual CPUs to share a smaller number of physical CPUs. The amount of CPU time that is actually available does not change, though, so heavy activity on too many virtual CPUs can lead to contention and significant performance loss. The steal governor patch series from Shrikanth Hegde is an attempt to address that problem with a mechanism that allows virtual machines to voluntarily reduce the number of virtual CPUs they use when contention is high.

From a virtual machine's point of view, contention for a physical CPU is clearly an undesirable thing. When contention occurs, the physical CPU will be unavailable at times when the virtual machine is trying to make use of it; that slows the execution of the workload. The situation can be worse than that, though, if a virtual CPU is preempted while holding locks needed elsewhere in the same virtual machine. At that point, threads that do still have access to a physical CPU may waste their execution time spinning on locks that the preempted CPU is no longer able to free, with possibly severe effects on performance. That is the sort of situation that causes customers to reconsider shared hosting.

Hegde's solution calls for virtual machines to take notice of when contention for physical CPUs is high and to reduce their demands to alleviate that contention.

Steal time and preferred CPUs

The amount of time that a virtual CPU spends waiting for access to a physical CPU is known as "steal time" — execution time that was "stolen" from the virtual machine by somebody else. On a Linux system, the amount of steal time experienced in a virtual machine can be read from /proc/stat, or seen with utilities like top or vmstat. The level of steal time seen by a virtual CPU can be used as a measure of how much contention for the physical CPU is being experienced.

Hegde's patch set uses steal time to help maintain (in ways that will be described shortly) a "preferred CPU" set. The preferred CPUs are a subset of the active virtual CPUs available to the virtual machine; as much as possible, the kernel on that virtual machine will try to schedule its tasks only on the preferred CPUs, leaving the others idle. When the virtual machine starts, the preferred set contains all of the active CPUs. Should the level of steal time experienced become too high, one or more CPUs will be removed from the preferred set. When steal time goes below a lower threshold, CPUs can be restored to the preferred set.

The scheduler makes use of the preferred set in few small but significant ways:

  • Whenever the time comes to wake a sleeping task, that task will be placed on one of the preferred CPUs if possible.
  • At each regular scheduler tick, the kernel checks whether the current CPU is in the preferred set. If not, the running task, if any, will be pushed out of the current CPU to run on one of the preferred CPUs instead.
  • Load balancing will avoid moving tasks onto CPUs that are not in the preferred set.

One important exception to these rules is that a task's CPU affinities will be honored. If a task is only eligible to run on non-preferred CPUs, it will be placed on one of those CPUs. Other than that, though, this machinery will cause any CPUs that are removed from the preferred set to go mostly idle, concentrating the virtual machine's tasks on the preferred set and reducing the number of physical CPUs that the virtual machine is contending for.

One might argue that the result is simply to move the problem around. Contention arises because there is more load on the system than its physical CPUs are able to handle; that load will not go away just because the set of virtual CPUs available to a virtual machine has been reduced. What does happen, though, is that the preemption decisions are moved into the virtual machine, which has more information about the workload and which tasks should be allowed to run first. That can allow the virtual machine to run high-priority tasks, or tasks holding contended locks, before others, leading to better decisions overall.

Policy

The policy part of this system is encapsulated in a "driver" called the steal_governor. It is not actually implemented as a driver, though; it runs as a workqueue item that continually resubmits itself. It is controlled by three parameters: interval_ms regulates how often it checks the experienced steal time, while low_threshold and high_threshold set (as percentages) the amount of steal time that should lead to an increase or decrease in the number of preferred CPUs, respectively. Interestingly, these parameters do not appear in sysfs; instead, they are implemented as module parameters, a configuration method that has been discouraged in recent years. Changing any of these parameters requires unloading and reloading the steal_governor module. The default value for interval_ms is 1000ms; the low and high thresholds default to 2% and 5%, respectively.

On each iteration, the governor compares the amount of steal time to the high threshold. If that threshold is exceeded, the governor will look for a core that contains no housekeeping CPUs; all CPUs in that core will be removed from the preferred set (subject to the obvious restriction that at least one CPU must remain in the preferred set). No other immediate action is taken; the scheduler tweaks described above will eventually cause tasks to move away from the non-preferred CPUs. If, instead, the steal time drops below the low threshold, one core's worth of CPUs will be added back to the preferred set (until the point where all CPUs are preferred).

The policy implementation may be enough for a proof of concept, but it may end up falling short for real deployments. At a minimum, the ability to change the governor's parameters without unloading and reloading a module would be a clear improvement. There does not seem to be a reason why these values could not be changed directly using sysfs or sysctl knobs. Even then, though, it seems inevitable that somebody will want the ability to control the preferred CPU set from user space, or, even more inevitably, with a BPF program.

Another potential problem, of course, is the entirely voluntary nature of this mechanism; it is nice that each virtual machine can react independently, and that there is no need for an overall control or communication mechanism, but the result is a system that is dependent on universal cooperation. If only some virtual machines reduce their preferred CPU count, they will be penalized relative to those that do not. That may limit the applicability of this mechanism on multi-tenant systems where some users may not feel inclined (or may be unable) to cooperate.

On systems where cooperation can be expected, though, the results would appear to be good. The cover letter includes data from a number of benchmark runs showing improvements from about 2% for schbench to over 44% for some hackbench runs. Hegde summarizes the results as: "Many improvement across archs especially with real life workloads".

This patch series has been circulating since the first RFC version in May 2025. It has been through 11 revisions — after several RFC versions — and has evolved considerably over that time. It has not, as yet, acquired the Acked-by or Reviewed-by tags that might indicate readiness for merging into the mainline, but Hegde nonetheless said that "I believe the series has now converged and is ready for merge consideration". Whether the scheduler maintainers agree will likely become clear sometime after the close of the merge window.

This work was discussed at the 2026 Power Management and Scheduling in the Linux Kernel Summit; the video from that session is available.

Index entries for this article
KernelScheduler
KernelVirtualization


to post comments

Penalizing cooperating systems?

Posted Aug 27, 2026 19:23 UTC (Thu) by matthias (subscriber, #94967) [Link] (1 responses)

> If only some virtual machines reduce their preferred CPU count, they will be penalized relative to those that do not.

Is this necessarily the case? If the host scheduler is fair, then the system that reduces its preferred CPU count should still get the same share of the physical CPUs. The non-cooperating systems should exhaust their time slices and their virtual CPUs should be preempted to let other systems run while the cooperating system will not exhaust its time slices and the preferred set can keep running.

Of course this depends on the host scheduler and host configuration regarding cgroups. But it should be possible to configure the host system in a way that cooperating guests are not penalized. Or do I miss something here?

Penalizing cooperating systems?

Posted Sep 9, 2026 13:26 UTC (Wed) by sshegde (guest, #156500) [Link]

Hi matthias,

It is not necessarily the case. As you said. it depends on the host scheduler and the VM configuration.

The documentation says that a VM which does not enable the feature "may end up with more CPUs than others" to cover host-dependent cases and to recommend cooperative deployment as the best practise.

For example, with PowerVM, each VM has an minimum guaranteed capacity (EC) in addition to its number of vCPUs (VPs). The hypervisor guarantees the EC worth of CPU time even when there are non-coperative VMs.

However, an uncapped VM may also receive capacity above its entitlement when spare capacity is available. How that excess capacity is distributed, and whether a non-cooperating VM benefits from keeping more vCPUs runnable, depends on the host scheduler and partition configuration. Therefore, I used "may" rather than saying that cooperating VMs are necessarily penalized.


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds