Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Alternatives for Scheduling Virtual Machines inReal-Time Embedded Systems
Robert Kaiser
Distributed Systems LabUniversity of Applied Sciences
Wiesbaden, Germany
IIES 08, Glasgow, 1-Apr-2008
Robert Kaiser [email protected]
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Outline
1 Introduction
2 Timing properties of virtual machinesHierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
3 Supporting real-time systemsWorkload classificationRequirements of different load classesScheduling infrastructure
4 Conclusion
Robert Kaiser [email protected] 1 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Outline
1 Introduction
2 Timing properties of virtual machinesHierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
3 Supporting real-time systemsWorkload classificationRequirements of different load classesScheduling infrastructure
4 Conclusion
Robert Kaiser [email protected]
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Motivation(1)
Embedded systems are becoming morepowerful
Disproprotionate relation of performancevs. cost (e.g. 2 x cost⇒ 10 x performance)
Using this potential makes sense ..
.. economically: same/moreperformance at lower cost.. technically: fewer components
⇒ fewer points of failure
⇒ More functionality per controller
Complexity must be managed, though...
Robert Kaiser [email protected] 2 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Motivation(2)
Software of embedded systemsbecomes more complex
Applications from different suppliers .... may serve different(unrelated) purposes.. may not be aware of each other.. need to be securely isolated(liability, safety, security)
⇒ A case for virtualisation!
Robert Kaiser [email protected] 3 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
A Case for Virtualisation
Complex embedded systems need managementApplications must be kept from interfering with each other
→ Need fault containmentApplications may be programmed against different OS APIs
→ Need to support multiple OSs in parallel
⇒ Similar requirements as server consolidation
Many embedded systems already have the necessary resources(e.g. MMU/MPU)
But can virtualisation be applied to embedded systems ”as is”?Workload is often known in advance
→ Dynamic resource management is less importantMany applications have soft/hard timing requirements
⇒ Need to support real-time guest systems!
Robert Kaiser [email protected] 4 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Outline
1 Introduction
2 Timing properties of virtual machinesHierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
3 Supporting real-time systemsWorkload classificationRequirements of different load classesScheduling infrastructure
4 Conclusion
Robert Kaiser [email protected]
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Hierarchical scheduler
Virtual machine monitor acts as ascheduler
Virtual machines host guest OSswhich –again– act as schedulers
→ VMM is the first level in ascheduler hierarchy
VMM is unaware of this:”VMs are just processes”
Goal: share the CPU among VMs
Processes
Hardware
VM−Scheduler
Scheduler Scheduler Scheduler
Local Local Local
Guest OS Guest OS Guest OS
VMM/Hypervisor
60 % CPU 30 % CPU 10 % CPU
Robert Kaiser [email protected] 5 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
VM exec time
VM
VM
VM
VM
real world time
33%
66%CPU share
1
2
1
2
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
real world time
VM
VM
1
2active VM
VM exec time 1
2
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
VM exec time VM
VM
active VM2
1
real world time
2
1
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
VM exec time VM
VM
active VM2
1
real world time
2
1
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
VM exec time VM
VM
active VM2
1
real world time
2
1
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Proportional share scheduling
Ideal: VMs continuouslyshare CPU
Reality: approximationby time multiplexing
Smaller quanta:→ better approximation
... but also: more overhead- Scheduler invocations- Cache & TLB losses
VM exec time VM
VM
active VM2
1
real world time
2
1
Robert Kaiser [email protected] 6 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Effect on latency
Comparing RT process running on real hardware vs. virtual machine
Virtual machine may experience a ”blackout”
Worst case delay: Tdel = (N−1) ·Tvm +N ·Tsw
�������������� ������������������ ������
��������������
��������������������������������������������������������
������ ����
������������
r j sj
r j sj
l j
vmT Tvm Tvm Tsw Tsw Tsw Tsw
Tvm
Tsw
VM0 VM1 VM2 VM0
pvm
Case I: noVirtualisation
Case II: Proc. inVM0 (worst case)
Robert Kaiser [email protected] 7 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Effect on latency
Comparing RT process running on real hardware vs. virtual machine
Virtual machine may experience a ”blackout”
Worst case delay: Tdel = (N−1) ·Tvm +N ·Tsw
�������������� ������������������ ������
��������������
��������������������������������������������������������
������ ����
������������
r j sj
r j sj
l j
vmT Tvm Tvm Tsw Tsw Tsw Tsw
Tvm
Tsw
VM0 VM1 VM2 VM0
pvm
BLACKOUT!
Case I: noVirtualisation
Case II: Proc. inVM0 (worst case)
Robert Kaiser [email protected] 7 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Effect on latency
Comparing RT process running on real hardware vs. virtual machine
Virtual machine may experience a ”blackout”
Worst case delay: Tdel = (N−1) ·Tvm +N ·Tsw
�������������� ������������������ ������
��������������
��������������������������������������������������������
������ ����
������������
r j sj
r j sj
l j
vmT Tvm Tvm Tsw Tsw Tsw Tsw
Tvm
Tsw
VM0 VM1 VM2 VM0
pvm
BLACKOUT!
Case I: noVirtualisation
Case II: Proc. inVM0 (worst case)
Robert Kaiser [email protected] 7 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Hierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
Simulated overheads as function of quantum
Simulateda Scheduler:VTRR (proportional share)
0
20
40
60
80
100
10 100 1000 10000 0 5 10 15 20 25 30 35 40 45 50 55
Ove
rhea
d [%
]
Del
ay b
ound
[ms]
Quantum [µs]
ffloodfavg delay
(3 VMs, CPU: [email protected], 64k WSS)
aSee: Kaiser: Empirische ErmittlungCache-bedingter Umschaltverluste
⇒ Observation: for quanta ≤ 1 ms:overhead becomes significant
Delay: proportional to quantumand number of VMs
Here: for quanta ≥ 1 ms
⇒ Delay ≥ 5 ms
Contemporary RTOS: ∼5-10µs
Robert Kaiser [email protected] 8 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Outline
1 Introduction
2 Timing properties of virtual machinesHierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
3 Supporting real-time systemsWorkload classificationRequirements of different load classesScheduling infrastructure
4 Conclusion
Robert Kaiser [email protected]
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Upshot
Using proportional share scheduling, thedelay/jitter imposed by virtualisation is severe,but bounded.
For many practical real-time applications, a tento hundred millisecond delay or jitter is entirelyacceptable.
⇒ For these, virtualisation is applicable ”as is”
But: there also exist applications for which suchdelay/jitter is unacceptable.
How to support these, too?
How to integrate this variety of requirements?
Robert Kaiser [email protected] 9 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Mixture of workloads to support
Real-time: must1 or should2 meet deadlines
Two subclasses:Time-driven: static schedule, typically periodicEvent-driven: scheduled in response to (unpredictable) events,assumed to be sporadic
Non real-time: no need to meet deadlines, instead, try to utilise allresources
Assumption: Each class uses a specific OS API
⇒ Guests and their VMs as a whole can be classified as one of:1 Time-driven, real-time2 Event-driven, real-time3 Non real-time
1= ”hard’ real-time2= ”soft” real-time
Robert Kaiser [email protected] 10 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Supporting non real-time VMs
No deadlines to meet→ VM delay not a problem
If multiple non-RT VMs exist: must share CPU evenly
Should utilise all available resources→ self-suspend when not ready
(→ VMM schedule becomes unpredictable)
Allocation of time to real-time VMs is designed for the worst case
Worst case occurs rarely (if at all)
In the average case, real-time VMs will not use all of their allocated time
⇒ Dynamically re-assign unused time to non real-time VMs
Real-time VMs take priority over non real-time VMs
May need provisions to avoid starvation, though..
Robert Kaiser [email protected] 11 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Supporting time-driven VMs
Cause of VM delay: VMM schedule andlocal schedules not correlated
⇒ Synchronise VMM schedule and localschedules of time-driven VMs
Define VMM schedule to ”enclose” alltime-driven local schedules
Restrictions:Local schedules must not overlapLocal schedules must use same(or harmonic) periods
Low jitter (e.g. for PLCs)
123
(t)1
(t)2
321
t
t
t
(t)3
321
(t)vm
321
t
σ
σ
σ
σ
Resulting ”super schedule” is strictly a function of time
Robert Kaiser [email protected] 12 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Supporting event-driven VMs
Event-driven VMs need access to CPU at arbitrary times
⇒ Need ability to preempt current VM
Conflicts with time-driven VMs
Two choices:Give event-driven VMs precedence over time-driven VMs→ Time-driven VMs experience jitter and delaysGive time-driven VMs precedence over event-driven VMs→ Event-driven VMs are delayed
Classical dilemma: no generic solution (for uniprocessor architectures)
Approach must be flexible enough to allow both choices on a case bycase basis
Robert Kaiser [email protected] 13 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Combining time-driven, priority-based and prop. share
Assign static priorities to VMs
Assign VMs to time domains (τi )(represented by a set of readyqueues, one per priority)
A VM is scheduled iff
- its time domain is active, and- it has the highest priority
prio
prio
prio
τ0
τ1
τN−1
.................
..................
.....
..................
.....
..................
.....
0
1
2
N−2.....N−1
Ready queues
(t)σvm
dispatchprio>?
Up to two time domains can be active at a time:τ0: background domain, always activeτi , i = 0..N: foreground domain, cyclically switched
VMs from foreground and background domain compete by priority
VMs of same domain and priority are scheduled to proportional share
Robert Kaiser [email protected] 14 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Semantics of priorities and time domain
time-driven VMs:Foreground domain,individual, high priorities⇒ individual, time-drivenschedules
event-driven VMs:Background domain,individual, high priorities⇒ can request CPU any time(iff sufficient priority)
non real-time VMs:Background domain,common, low priority⇒ share all unusedCPU resources
t
prio
1
2
3
123
σvm(t)
Robert Kaiser [email protected] 15 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Semantics of priorities and time domain
time-driven VMs:Foreground domain,individual, high priorities⇒ individual, time-drivenschedules
event-driven VMs:Background domain,individual, high priorities⇒ can request CPU any time(iff sufficient priority)
non real-time VMs:Background domain,common, low priority⇒ share all unusedCPU resources
1
42
3
t
prio
123
σvm(t)
5
Robert Kaiser [email protected] 15 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Semantics of priorities and time domain
time-driven VMs:Foreground domain,individual, high priorities⇒ individual, time-drivenschedules
event-driven VMs:Background domain,individual, high priorities⇒ can request CPU any time(iff sufficient priority)
non real-time VMs:Background domain,common, low priority⇒ share all unusedCPU resources
3
4
prio
t
6 7
1
25
123
σvm(t)
Robert Kaiser [email protected] 15 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Workload classificationRequirements of different load classesScheduling infrastructure
Implementation details
First implementation: ”PikeOS”µKernel (Sysgo AG)
(Round robin instead ofproportional share)
Use cases so far: RTOS & Linux,PLC & Linux
Priorities control (individually)precedence of time-driven vs.event-driven VMs
→ O(1) complexity
High priority VMs trusted not toexceed their budgets
prio
prio
prio
τ0
τ1
τN−1
.................
..................
.....
..................
.....
..................
.....
0
1
2
N−2.....N−1
Ready queues
(t)σvm
dispatchprio>?
Robert Kaiser [email protected] 16 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Outline
1 Introduction
2 Timing properties of virtual machinesHierarchical schedulingProportional share schedulingEffect on latencyOverhead vs. Latency
3 Supporting real-time systemsWorkload classificationRequirements of different load classesScheduling infrastructure
4 Conclusion
Robert Kaiser [email protected]
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Summary
Applying virtualisation to embedded systems makes sense
Current virtualisation approaches have limited real-time support
Proposed approach can improve it (with some restrictions)
Coexistence of time-driven and event-driven subsystems remainsproblematic
Proposed approach can be implemented efficiently by means of theoutlined scheduler infrastructure
Robert Kaiser [email protected] 17 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
Further work
Use Xen as testbed
Introduce budgets to limit high priority time consumption
Multiprocessor (MultiCore) supportMultiCore CPUs are attractive for embedded systemsDecouple time-driven and event-driven VMsEnable parallel programming (”coscheduling”) under guest OS control
Apply schedulability analysis to guest OSsRMS: already covered (though not in this paper)EDF: TBD
Improve estimates for cache-related switch overheadsValidate simulation-based estimation under realistic workloadsEstimates should also be applicable processor migration cost
Robert Kaiser [email protected] 18 / 18
IntroductionTiming properties of virtual machines
Supporting real-time systemsConclusion
The End
Thank you for your attention!
Any Questions?
Robert Kaiser [email protected] 18 / 18