3. ACRN cpu sharing goal
1. Fully utilize the physical cpu resource to support more virtual machines.
2. Keep small footprint for hypervisor, and satisfy FuSa requirements.
3. No impact on real time and FuSa workloads.
4. Simple tiny scheduler algorithm to satisfy embedded device requirements.
9. Schedule API architecture
vcpu layer
thread_obj
Functionality component layers
schedulers
layer
schedule framework
layer
scheduler
callbacks
API for vcpu
vcpu API
• vcpu derived from thread_obj.
• thread_obj is the schedule entity from schedule framework perspective
• scheduler is abstracted from schedule framework, several callbacks need to be implemented by
each scheduler.
API for
scheduler
Hardware management
layer
10. Schedule object state transition
THREAD_STS_BLOCKED
THREAD_STS_RUNNINGTHREAD_STS_RUNNABLE
init
Scheduler pick to running
run out of timeslice /
yield / be preempted
12. Context Switch
Vcpu layer will register the switch_in/switch_out for platform architecture level
context switch handling.
MSRs IA32_STAR, IA32_LSTAR, IA32_FMASK,
IA32_KERNEL_GS_BASE
xsave/xrstors X87 state, SSE state and platform specific state components.
vmcs switch
General registers flags, rbx, rbp, r12, r13, r14, r15, rdi, rsp
13. VCPU Power management
• Vcpu C/P state
• For noop, pass through then controlled by guest itself.
• Hardcode p-state and c-state data table in HV, export to guest through ACPI table by DM.
• Forward MSR_IA32_PERF_CTL msr writing of guests to hardware by HV for p-state.
• Passthrough c-state IO port writing for c-state.
• For BVT, consider to disable C/P-state capability for guest.
• Disable p-state and c-state table for guest through virtual ACPI table.
• disable mwait capability of guest in CPUID emulation.
• MSR_IA32_PERF_CTL emulation will reject the request.
14. FuSa/Security requirements
• FuSa
• The schedule architecture can guarantee pcpu sharing scheduler will not
impact the pcpu which bind with noop scheduler.
• Every scheduler will only effect its vcpu_affinity limited pcpu resource.
• There has no shared resource between different schedulers.
• Schedule/scheduler architecture follows modularization rules.
• Security
• L1TF and Spectre are needn’t care because they will be handled during
VMEXIT&VMENTRY. And hypervisor only support ring0, so needn’t do extra
operations during context switching.
16. cpu_affinity
• Currently, we do not support vCPU migration; the assignment of vCPU
mapping to pCPU is fixed at the time the VM is launched. The statically
configured cpu_affinity in the VM configuration defines a superset of pCPUs
that the VM is allowed to run on. One bit in this bitmap indicates that one pCPU
could be assigned to this VM, and the bit number is the pCPU ID. A pre-
launched VM is supposed to be launched on exact number of pCPUs that are
assigned in this bitmap. The vCPU to pCPU mapping is implicitly indicated:
vCPU0 maps to the pCPU with lowest pCPU ID, vCPU1 maps to the second
lowest pCPU ID, and so on.
• For post-launched VMs, acrn-dm could choose to launch a subset of pCPUs
that are defined in cpu_affinity by specifying the assigned pCPUs (--
cpu_affinity option). But it can’t assign any pCPUs that are not included in the
VM’s cpu_affinity.
17. cpu_affinity - example
Use the following settings to support this configuration in the industry
scenario:
• Define the default pCPU pool for each VM:
#define VM1_CONFIG_CPU_AFFINITY (AFFINITY_CPU(0U) | AFFINITY_CPU(1U))
#define VM2_CONFIG_CPU_AFFINITY (AFFINITY_CPU(2U) | AFFINITY_CPU(3U))
• Offline pcpu2-3 in Service VM.
• launch WaaG with “--cpu_affinity 0,1”
• launch RT with “--cpu_affinity 2,3”
• The devicemodel option “--cpu_affinity” is not a must because they define
same pCPU pool with the default value in hypervisor configuration.
pCPU0 pCPU1 pCPU2 pCPU3
Service VM + Waag RT Linux