1. Background

CPU sharing allows the virtual CPUs (vCPUs) of different VMs to run on the same physical CPU, just like how multiple processes run concurrently on a single CPU. Internally the hypervisor adopts time slicing scheduling and periodically switches among those vCPUs.

This feature can help improve overall CPU utilization when the VMs are not fully loaded. However, sharing a physical CPU among multiple vCPUs increases the worst-case response latency of them, and thus is not suitable for vCPUs running latency-sensitive workloads.

2. ACRN vCPU Scheduling Overview

Fig 1: ACRN vCPU Scheduling Overview

3. ACRN Scheduling Framework

The design principle of ACRN scheduling framework

  • Follow the principle of modularity and Decoupling vCPU layer and specific scheduling algorithms
  • Abstract the scheduling objects, new scheduler can be easily extended.
  • A scalable context switch architecture
  • Maintain the thread_object state machine

Fig 2: ACRN Scheduling Framework

Fig 3: Relationships Between Key Data Structures

Fig.4 Scheduling Object State Transition

4. Scheduling Framework API

Fig.5 Scheduling Framework API

  • vcpu derived from thread_obj
  • thread_obj is the scheduling entity from the scheduling framework perspective
  • scheduler is abstracted from the scheduling framework, several callbacks need to be implemented by each scheduler.

5. Scheduling Points and Scheduling Request Submitting Points

6. Registers Save and Restore In Context Switch

The vCPU layer will register two function switch_in and switch_out for platform architecture level context switch handling.

7. The Schedulers

The IORR Scheduler

The BVT Scheduler

The Priority Based Scheduler

This scheduler supports vCPU scheduling based on their static priorities defined in the scenario configuration. A vCPU can be running only if there is no higher-priority vCPU running on the same physical CPU.