SafeMC: A System for the Design and Evaluation of Mode Change...

27
SafeMC : A System for the Design and Evaluation of Mode Change Protocols Tianyang Chen Linh Thi Xuan Phan University of Pennsylvania RTAS – April 2018

Transcript of SafeMC: A System for the Design and Evaluation of Mode Change...

Page 1: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

SafeMC: A System for the Design and Evaluation of Mode

Change Protocols

Tianyang Chen Linh Thi Xuan PhanUniversity of Pennsylvania

RTAS – April 2018

Page 2: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Scenario: Self-driving cars

• Mode: a functionality, a system configuration– a set of tasks that need to execute – e.g., adaptive cruise control, lane keeping assistance, …

• Mode transition: a change in the system mode – triggered by a mode change request (MCR)– e.g., a driver’s request to take back control of the vehicle

2

AutonomousMCR0 Manual

MCR1 …

[Gom

ez e

t al.

Tran

sitio

ning

a m

ixed-

mod

e ve

hicle

to a

uton

omou

s mod

e, D

ec 2

011.

US

Pate

nt 8

,078

,349

]

Software has complete control

Driver maintains control

Safety tests forcontrol handover

Decision

Page 3: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Problems with mode transitions

• Need to execute:– Unfinished jobs of the old mode– Newly released jobs of the new mode

• Result: Potential overloads and deadline misses

3

Autonomous Decision

MCR0

Essential control: ACC, LKA

Navigation, environment,and infotainment

Essential control: ACC, LKA

Navigation, environment,and infotainment

Handover safety check

unchanged changed

new

Page 4: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Solution: Mode-change protocol

• Specify execution semantics of a mode transition – How to handle unfinished jobs? – When to release new jobs? – When to apply the modified parameters? etc.

• Goal: Timing guarantees and safety during a transition

4

Autonomous Decision

MCR0

Essential control: ACC, LKA

Navigation, environment,and infotainment

Essential control: ACC, LKA

Navigation, environment,and infotainment

Handover safety check

unchangedmodified

new

Page 5: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Limitations of existing work• Lack experimental evaluations

– Timing may be violated in practice due to overheads

• Evaluations performed on different environments– Hard to compare between protocols

• Focus on relatively simple protocols– Agnostic of mode transitions and tasks’ safety criticality– Require customizations in practice

5

How to determine which MCP is the best-fit for a given system?

Page 6: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Contributions• An extensible set of mode change primitives

– implement a broad spectrum of mode change behaviors

• SafeMC system design– enables efficient specification and evaluation of MCPs

• A prototype implementation of SafeMC in Xen

• Experimental evaluations– comparisons of existing MCPs – case study: design of novel protocols specific for an

application

6

Page 7: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Outline

• Introduction

• Mode change primitives

• SafeMC design and implementation

• Evaluation

• Case study

7

Page 8: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

transition type (global)

job type task type conditionaction

Insight

8

• MCPs are built on a common set of key primitives – Operate on the smallest scheduling entity (a job)– Specify the actions that the MCP must perform – Specify conditions under which the actions to be invoked

• Primitives are composed at different levels of granularity to form MCPs– Job type, task, task type, or transition

• Example: Maximum Period Offset – For all transitions:

New jobs of changed tasks: released after an offset

Page 9: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Types of tasks and jobs

• Job type– Pending: Unfinished jobs that are not currently executing– Executing: Currently executing jobs– New: New jobs to be released after the MCR instant

9

MCR1

Steering and throttle

Navigation control

Adaptive cruise control

Navigation control

Handover safety check

Infotainment Infotainment……

new task unchangedtask

changedtask

old task

Decision Manual

Page 10: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Basic primitives• Describe actions for jobs of a specific type, for a

particular task, or for all tasks of a specific type

• Compose primitives to form an MCP for the system

10

Primitive = [Action; Guard]

Action to be applied tothe considered jobs(e.g., abort)

Conditions for when the action should be applied

(e.g., after a certain offset)

Page 11: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Action Description Use

CONTINUE The jobs are continued to be scheduled with current timing attributes (WCET, deadline, period, criticality)

Pend

ing

or E

xecu

ting

job

type

sUPDATE The jobs continued to be scheduled but timing attributes are changed to that of the new mode

ABORT The jobs are aborted and removed from the system

ABORT[K] The oldest K jobs are aborted and removed from the system

RELEASE New jobs whose attributes are defined in the new mode will be released when the associated guard becomes true

New

jo

b ty

pe

RELEASE_O New jobs whose attributes are defined in the old mode will be released as usual while the associated guard is true

Basic primitive: Actions

11

*If an action has no guard, it will be applied immediately

Page 12: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Basic primitive: Offset guards

• Apply the action after an offset ∆ from MCR or LR instant – ∆ is a constant threshold, or based on task’s parameters

• Example: [ RELEASE; OffsetLR: MAX_PERIOD ] – The first new job is released after a delay equal to the max period of

tasks in old and new modes from the last release

12

MCRLast release (LR)

apply actionOffsetLR: ∆

OffsetMCR: ∆

Page 13: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Basic primitive: Backlog guards

• Specify a formula on the backlog of the job queue– Op ∈ { ≤, ≥, =, <, >} – ∆: a constant, or based on the queue size

• Example: [ ABORT; Backlog: (≥, 0.5 ⋅ MAX_VAL) ] – Abort old/pending jobs of the task if its queue is at least half full

• Example: [ RELEASE; BacklogGlobal: (=, 0) ]– Release new jobs when the global queue is empty

13

MCR

apply action

BacklogGlobal: (Op, ∆) holds

Backlog (per task)

BacklogGlobal

Page 14: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Basic primitive: Criticality guards

• Specify a formula on the task’s old and new criticality

• Example: [ RELEASE; Criticality: (<, OLD_VAL, NEW_VAL) ] – Release new jobs immediately if the task’s criticality is increased

• Example: [ ABORT; Criticality: (≤, OLD_VAL, 2) ]– Abort all existing jobs with criticality less than or equal to 2

14

1

MCR

apply action if guard holds

1 3 3

More primitives are available in the paper

Page 15: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Examples of MCP specs

15

JOB TYPE New (Action = RELEASE) Exec/Pending

TASK TYPE UNCHANGED CHANGED NEW ALL (except NEW)

Max Period Offset OffsetLR: OLD_PERIOD OffsetMCR: MAX_PERIOD

CONTINUE

Min Offset w/ Periodicity OffsetLR: OLD_PERIOD BacklogGlobal: (=, 0)

Min Offset w/o Periodicity BacklogGlobal: (=, 0)

Asyn. with Periodicity OffsetLR: OLD_PERIOD OffsetMCR: ∆

Asyn. w/o Periodicity OffsetMCR: ∆i

[Real and Crespo. Mode Change Protocols for Real-Time Systems: A Survey and a New Proposal. RTS 2004.]

Page 16: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Outline

• Introduction

• Mode change primitives

• SafeMC design and implementation

• Evaluation

• Case study

16

Page 17: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

SafeMC Design

17

MCP-specific algorithmic-core

MCP-independent common runtime

§ Define mode change primitives

§ Easily customized or re-written from scratch

§ Implement the algorithm§ Simplify experimentation§ Enable fair comparisons

on a real platform

Page 18: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

SafeMC spec language

initi

aliza

tion

SafeMC Runtime

18

System Parser

Mode Change Manager

Transition-level protocol

Task-level protocol per transition

MCR Dispatcher

[domID, cpuID, transID]

Run-time input from the command line,an automatic script, a user domain, …

triggerMCR(domID, cpuID, transID)

Mode Change Initializer

load MC structures

UserInput

UserInput

Multi-mode system model

System-level protocol(globally for all transitions, or for each transition ID)

Page 19: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Prototype

19

xenalyze.c

Tracing tool

sched_rt.c schedude.c xc_rt.c

Mode Change ManagerHypervisor

System Parser MC Initializer MCR Dispatcher Test GeneratorUser space

run_*.shRun a specific test

proc_trace.shParse traces for post processing

load_scriptsInvoke parser and load transitions to hypervisor

trigger_scriptsTrigger an

existing transition

Dom0 toolset

• Xen-based implementation of SafeMC– Support mode changes at the hypervisor level– Rationale: substantial interests in real-time virtualization,

potential applications to beyond traditional RT systems,…

Page 20: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Outline

• Introduction

• Mode change primitives

• SafeMC design and implementation

• Evaluation

• Case study

20

Page 21: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Evaluation setup & goals• Platform: Xen with SafeMC enabled

• Workload: Randomly-generated multi-mode systems – Each mode has 4/8/16/32 VCPUs and utilization ≤ 96%– VCPU’s WCET in [1.5ms,12ms], max period = 50ms

• Goal #1: Run-time overhead of SafeMC

• Goal #2: Protocol comparisons – Release-new: How fast the new mode is activated– Finish-old: How fast the system completely leaves the old mode – Finish-old-new: How fast the system completely enters the new mode

• Goal #3: Develop novel protocols for a given application– using a self-driving case study (based on Google’s patent)

21

Page 22: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

SafeMC Run-time overhead (ns)

#VCPUs Schedule Context switch Release Mode change4 540.5 125.4 1025.0 1986.2

8 478.2 86.8 1465.5 3697.5

16 399.8 44.5 1900.8 7063.2

32 366.2 64.0 3267.0 12753.5

22

Negligible overhead(comparable to vanilla Xen’s RTDS*)

[*] Xi et al. Real-time multi-core virtual machine scheduling in Xen. EMSOFT2014

Reasonable MC overhead

Overhead averaged across 1000 measurements per protocol per multi-mode system

Page 23: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

0

10

20

30

40

50

60

70

Release-new Finish-old Finish-new-old

Number of VCPUs = 16

asyn w/ periodicity asyn w/o periodicity min offset w/ periodicity

min offset w/o periodicity max period offset

23

Asyn w/ periodicityAsyn w/o periodicity

Min offset w/ periodicity

Max period offset

Result: Protocol comparisonsMaximum mode-change delay (ms)

across 1000 runs

Min offset without periodicity

Min offset w/o periodicity

§ Delay new releases until existing jobs complete à smallest MC delay§ Suitable for applications where periodicity is not critical

Page 24: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

0

10

20

30

40

50

60

70

Release-new Finish-old Finish-new-old

Number of VCPUs = 16

asyn w/ periodicity asyn w/o periodicity min offset w/ periodicity

min offset w/o periodicity max period offset

24

Asyn w/ periodicityAsyn w/o periodicity

Min offset w/ periodicity

Min offset w/o periodicity

Max period offset

Result: Protocol comparisonsMaximum mode-change delay (ms)

across 1000 runs

Max period offset

§ Delay releases of new and changed tasks by an offset = max period§ Perform poorly in activating/completely entering the new mode§ Should be avoided if tasks in the new mode are highly critical

§ Delay releases of new and changed tasks by an offset = max period§ Perform poorly in activating/completely entering the new mode§ Should be avoided if tasks in the new mode are highly critical

Page 25: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

0

10

20

30

40

50

60

70

Release-new Finish-old Finish-new-old

Number of VCPUs = 16

asyn w/ periodicity asyn w/o periodicity min offset w/ periodicity

min offset w/o periodicity max period offset

25

Asyn w/ periodicityAsyn w/o periodicity

Min offset w/ periodicity

Min offset w/o periodicity

Max period offset

Result: Protocol comparisonsMaximum mode-change delay (ms)

across 1000 runs

Protocols with periodicity

§ Unchanged tasks are not affected by the MC§ Min offset w/ periodicity performs well in entering new mode § Good choice when periodicity is required and the new mode is critical

Page 26: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Case study: Result

• MCR0: Hybrid protocol activates and completely enter the Decision mode much more quickly

• MCR1: Hybrid protocol outperforms in all three metrics

26

Max mode change delay (ms) across 100 runs

SafeMC enables the design of novel MCPs specific to the applications

Transition Protocol Release-new Finish-old Release-new-old

MCR0

Existing 32.984 2.005 39.927

Hybrid 3.441 15.223 26.176

MCR1

Existing 46.312 8.305 51.036

Hybrid 0.005 1.908 11.947

Page 27: SafeMC: A System for the Design and Evaluation of Mode Change …2018.rtas.org/wp-content/uploads/2018/05/S4.1.pdf · 2018-05-06 · xenalyze.c Tracing tool sched_rt.c schedude.c

© 2018 Linh T.X. Phan – SafeMC: A system for the design and evaluation of MCPs

Conclusion• Choosing the right MCP is critical for safe and

efficient design of a multi-mode system

• SafeMC: a system for designing, experimentally evaluating and comparing MCPs– MCP-specific algorithmic “core” that implements a broad

extensible set of common mode change primitives– MCP-independent, shared runtime for executing and

evaluating an MCP in a multi-mode system

• Benefits – Enable side-by-side experimental comparison – Support rapid prototyping and customization

27