mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
Doc: Content edit to cpu-sharing page
Signed-off-by: Deb Taylor <deb.taylor@intel.com>
This commit is contained in:
parent
fa5922c8bf
commit
3e45d5e301
@ -5,13 +5,13 @@ ACRN CPU Sharing
|
||||
|
||||
Introduction
|
||||
************
|
||||
|
||||
|
||||
The goal of CPU Sharing is to fully utilize the physical CPU resource, to support more virtual machines. Current ACRN only supports partition mode, which is a strict 1 to 1 mapping mode between vCPUs and pCPUs. Because of the lack of CPU sharing ability, the number of VM is limited. To support the CPU Sharing, we introduce a schedule framework and implement two simple tiny scheduling algorithms to satisfy embedded device requirements.
|
||||
|
||||
Schedule Framework
|
||||
******************
|
||||
|
||||
To satisfy the modularization design conception, the schedule framework layer isolates the vcpu layer and scheduler algorithm. It has not vCPU concept and can only be aware of the thread object instance. The thread object state machine will be maintained in the framework. The framework abstracts the scheduler algorithm object, so this architecture can easily extend new scheduler algorithms.
|
||||
To satisfy the modularization design conception, the schedule framework layer isolates the vcpu layer and scheduler algorithm. It has not vCPU concept and can only be aware of the thread object instance. The thread object state machine will be maintained in the framework. The framework abstracts the scheduler algorithm object, so this architecture can easily extend new scheduler algorithms.
|
||||
|
||||
.. figure:: images/cpu_sharing_framework.png
|
||||
:align: center
|
||||
@ -34,6 +34,7 @@ Here is an example for affinity:
|
||||
- VM0: 2 vCPUs, pinned to pCPU0 and pCPU1
|
||||
- VM1: 2 vCPUs, pinned to pCPU2 and pCPU3
|
||||
- VM2: 2 vCPUs, pinned to pCPU2 and pCPU3
|
||||
|
||||
.. figure:: images/cpu_sharing_affinity.png
|
||||
:align: center
|
||||
|
||||
@ -45,26 +46,26 @@ There are three states for thread object, RUNNING, RUNNABLE and BLOCK. States tr
|
||||
.. figure:: images/cpu_sharing_state.png
|
||||
:align: center
|
||||
|
||||
After a new vCPU is created, the corresponding thread object is initiated. The vcpu layer will invoke a wakeup operation. After wakeup, the state for the new thread object is set to RUNNABLE, then follow its algorithm to determine to preempt the current running thread object or not. If yes, it will turn to RUNNING state. In RUNNING state, the thread object may turn back to RUNNABLE state when it runs out of its timeslice, or it yields the pCPU by itself, or be preempted. The thread object under RUNNING state may trigger sleep to transfer to BLOCKED state.
|
||||
After a new vCPU is created, the corresponding thread object is initiated. The vcpu layer will invoke a wakeup operation. After wakeup, the state for the new thread object is set to RUNNABLE, then follow its algorithm to determine to preempt the current running thread object or not. If yes, it will turn to RUNNING state. In RUNNING state, the thread object may turn back to RUNNABLE state when it runs out of its timeslice, or it yields the pCPU by itself, or be preempted. The thread object under RUNNING state may trigger sleep to transfer to BLOCKED state.
|
||||
|
||||
Scheduler
|
||||
*********
|
||||
|
||||
Below block diagram shows the basic concept for the scheduler. There are two kinds of scheduler in the diagram, one is NOOP(No-Operation) scheduler and the other is IORR (IO sensitive Round-Robin) scheduler.
|
||||
Below block diagram shows the basic concept for the scheduler. There are two kinds of scheduler in the diagram, one is NOOP (No-Operation) scheduler and the other is IORR (IO sensitive Round-Robin) scheduler.
|
||||
|
||||
|
||||
- **No-Operation scheduler**:
|
||||
|
||||
The NOOP(No-operation) scheduler has the same policy with original partition mode, every pCPU can run only two thread objects, one is idle thread, and another is the thread of the assigned vCPU. With this scheduler, vCPU work in work-conserving mode, and will run once it’s ready. idle thread could run when the vCPU thread blocked.
|
||||
The NOOP (No-operation) scheduler has the same policy with original partition mode, every pCPU can run only two thread objects, one is idle thread, and another is the thread of the assigned vCPU. With this scheduler, vCPU work in work-conserving mode, and will run once it’s ready. idle thread could run when the vCPU thread blocked.
|
||||
|
||||
- **IO sensitive round-robin scheduler**:
|
||||
|
||||
IORR(IO sensitive round-robin) scheduler is implemented with per-pCPU runqueue and per-pCPU tick timer, it supports more than one vCPU running on a pCPU. The scheduler schedule thread objects in round-robin policy basically, and support preemption by timeslice counting.
|
||||
IORR (IO sensitive round-robin) scheduler is implemented with per-pCPU runqueue and per-pCPU tick timer, it supports more than one vCPU running on a pCPU. The scheduler schedule thread objects in round-robin policy basically, and support preemption by timeslice counting.
|
||||
|
||||
+ Every thread object has an initial timeslice (ex: 10ms)
|
||||
+ timeslice is consumed with time and be counted in context switch and tick handler
|
||||
+ If timeslice is positive or zero, then switch out current thread object and put it to tail of runqueue.Then, pick next runnable one from runqueue to run.
|
||||
+ Threads who has IO request will preempt current running thread on the same pCPU.
|
||||
- Every thread object has an initial timeslice (ex: 10ms)
|
||||
- Timeslice is consumed with time and be counted in context switch and tick handler
|
||||
- If timeslice is positive or zero, then switch out current thread object and put it to tail of runqueue.Then, pick next runnable one from runqueue to run.
|
||||
- Threads who has IO request will preempt current running thread on the same pCPU.
|
||||
|
||||
Scheduler configuration
|
||||
***********************
|
||||
@ -74,21 +75,20 @@ There are two place in the code decide the usage for scheduler.
|
||||
* The option in Kconfig decides the only scheduler used in runtime.
|
||||
``hypervisor/arch/x86/Kconfig``
|
||||
|
||||
.. literalinclude:: ../hypervisor/arch/x86/Kconfig
|
||||
.. literalinclude:: ../../../../hypervisor/arch/x86/Kconfig
|
||||
:name: Kconfig for Scheduler
|
||||
:caption: Kconfig for Scheduler
|
||||
:caption: Kconfig for Scheduler
|
||||
:linenos:
|
||||
:lines: 40-58
|
||||
:emphasize-lines: 42
|
||||
:language: c
|
||||
|
||||
The default scheduler is **SCHED_NOOP**. To use the IORR, only need to set **SCHED_IORR** in **ACRN Scheduler**.
|
||||
The default scheduler is **SCHED_NOOP**. To use the IORR, only need to set **SCHED_IORR** in **ACRN Scheduler**.
|
||||
|
||||
* The affinity for VMs are set in ``hypervisor/scenarios/<scenario_name>/vm_configurations.h``
|
||||
|
||||
.. literalinclude:: ../hypervisor/scenarios/industry/vm_configurations.h
|
||||
.. literalinclude:: ../../../..//hypervisor/scenarios/industry/vm_configurations.h
|
||||
:name: Affinity for VMs
|
||||
:caption: Affinity for VMs
|
||||
:caption: Affinity for VMs
|
||||
:linenos:
|
||||
:lines: 31-32
|
||||
:language: c
|
||||
@ -121,10 +121,10 @@ You should change three files:
|
||||
.. code-block:: none
|
||||
|
||||
#define CONFIG_MAX_VM_NUM (4U)
|
||||
|
||||
|
||||
#define DM_OWNED_GUEST_FLAG_MASK (GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH | \
|
||||
GUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)
|
||||
|
||||
|
||||
#define SOS_VM_BOOTARGS SOS_ROOTFS \
|
||||
"rw rootwait " \
|
||||
"console=tty0 " \
|
||||
@ -137,7 +137,7 @@ You should change three files:
|
||||
"i915.domain_plane_owners=0x011111110000 " \
|
||||
"i915.enable_gvt=1 " \
|
||||
SOS_BOOTARGS_DIFF
|
||||
|
||||
|
||||
#define VM1_CONFIG_VCPU_AFFINITY {AFFINITY_CPU(0U)}
|
||||
#define VM2_CONFIG_VCPU_AFFINITY {AFFINITY_CPU(1U), AFFINITY_CPU(2U)}
|
||||
#define VM3_CONFIG_VCPU_AFFINITY {AFFINITY_CPU(3U)}
|
||||
@ -194,13 +194,13 @@ You should change three files:
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
.load_order = POST_LAUNCHED_VM,
|
||||
.uuid = {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
|
||||
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U},
|
||||
|
||||
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.vcpu_num = 2U,
|
||||
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
|
||||
@ -232,9 +232,9 @@ You should change three files:
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
After you start all the VMs, you can check the vcpu affinities from Hypervisor console:
|
||||
@ -242,7 +242,7 @@ After you start all the VMs, you can check the vcpu affinities from Hypervisor c
|
||||
.. code-block:: none
|
||||
|
||||
ACRN:\>vcpu_list
|
||||
|
||||
|
||||
VM ID PCPU ID VCPU ID VCPU ROLE VCPU STATE
|
||||
===== ======= ======= ========= ==========
|
||||
0 0 0 PRIMARY Running
|
||||
|
Loading…
Reference in New Issue
Block a user