presentation 14 09_2012

34
Design and Development of Real-Time Multi-Processor Bandwidth Control Mechanisms in General Purpose Operating Systems Youcheng Sun Graduate Program in Computer Science and Engineering September 14, 2012 Y. Sun (GPCSE) Master thesis September 14, 2012 1 / 26

Upload: youcheng-sun

Post on 18-Dec-2014

388 views

Category:

Technology


2 download

DESCRIPTION

Open-Extension Container (OXC) Framework in Linux

TRANSCRIPT

Page 1: Presentation 14 09_2012

Design and Development of Real-TimeMulti-Processor Bandwidth Control Mechanisms in

General Purpose Operating Systems

Youcheng Sun

Graduate Program in Computer Science and Engineering

September 14, 2012

Y. Sun (GPCSE) Master thesis September 14, 2012 1 / 26

Page 2: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 2 / 26

Page 3: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 3 / 26

Page 4: Presentation 14 09_2012

Four golden rules

Hierarchical CPU bandwidth distribution Tasks in a Linux systemcan be organized in a flat or hierarchy. In modern systems, thehierarchyical way is preferred. A good mechanism should be ableto distribute the CPU bandwidths hierarchically.

Serve all kinds of tasks In Linux, there are different types of tasksthat scheduled by different schedulers. A good mechanism shouldbe able to serve all kinds of tasks.

Support multi-processor platforms

Provide real-time guaruntee Linux is used to serve variousscenarios, among which some have temporal requirements. Agood mechanism should be able to provide real-time guarantee.

Y. Sun (GPCSE) Master thesis September 14, 2012 4 / 26

Page 5: Presentation 14 09_2012

Before our work, no existing mechanisms can satisfyall four golden rules

Previous work includes RT throttling, CFS bandwdith control,AQuoSA, IRMOS real-time framework, etc.

One common failure is rule 2.

Y. Sun (GPCSE) Master thesis September 14, 2012 5 / 26

Page 6: Presentation 14 09_2012

Before our work, no existing mechanisms can satisfyall four golden rules

Previous work includes RT throttling, CFS bandwdith control,AQuoSA, IRMOS real-time framework, etc.

One common failure is rule 2. Each previous mechanism canonly work for a specific type of tasks in Linux.

Y. Sun (GPCSE) Master thesis September 14, 2012 5 / 26

Page 7: Presentation 14 09_2012

Before our work, no existing mechanisms can satisfyall four golden rules

Previous work includes RT throttling, CFS bandwdith control,AQuoSA, IRMOS real-time framework, etc.

One common failure is rule 2. Each previous mechanism canonly work for a specific type of tasks in Linux.

In our work, a framework that satisfies all golden rules isproposed.

Y. Sun (GPCSE) Master thesis September 14, 2012 5 / 26

Page 8: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 6 / 26

Page 9: Presentation 14 09_2012

Resource reservation

The Constant Bandwidth Server (CBS) algorithm is used toreserve CPU bandwidth in the work.

A CBS is characterized by an ordered pair (Q, P), where Q iscalled maximum budget and P is period.

A CBS can reserve Q every P time units from a CPU.

Y. Sun (GPCSE) Master thesis September 14, 2012 7 / 26

Page 10: Presentation 14 09_2012

Linux scheduling

Linux adapts modular scheduling design. Each scheduler is aninstance of the struct sched_class.s t ruc t sched_class {

const s t ruc t sched_class ∗next ;

void (∗enqueue_task ) ( s t ruc t rq ∗rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;void (∗dequeue_task ) ( s t ruc t rq ∗rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;void (∗ y i e l d _ t a s k ) ( s t ruc t rq ∗rq ) ;bool (∗ y i e l d _ t o _ t a s k ) ( s t ruc t rq ∗rq , s t ruc t t a s k _ s t r u c t ∗p , bool preempt ) ;

void (∗ check_preempt_curr ) ( s t ruc t rq ∗rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;

s t ruc t t a s k _ s t r u c t ∗ (∗ p ick_next_ task ) ( s t ruc t rq ∗rq ) ;void (∗ put_prev_task ) ( s t ruc t rq ∗rq , s t ruc t t a s k _ s t r u c t ∗p ) ;. . .

} ;

These hooks are all scheduling operations for a scheduler.

Y. Sun (GPCSE) Master thesis September 14, 2012 8 / 26

Page 11: Presentation 14 09_2012

Linux scheduling

Linux adapts modular scheduling design. Each scheduler is aninstance of the struct sched_class.s t ruc t sched_class {

const s t ruc t sched_class ∗next ;

void (∗enqueue_task ) ( struct rq *rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;

void (∗dequeue_task ) ( struct rq *rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;

void (∗ y i e l d _ t a s k ) ( struct rq *rq ) ;

bool (∗ y i e l d _ t o _ t a s k ) ( struct rq *rq , s t ruc t t a s k _ s t r u c t ∗p , bool preempt ) ;

void (∗ check_preempt_curr ) ( struct rq *rq , s t ruc t t a s k _ s t r u c t ∗p , i n t f l a g s ) ;

s t ruc t t a s k _ s t r u c t ∗ (∗ p ick_next_ task ) ( struct rq *rq ) ;

void (∗ put_prev_task ) ( struct rq *rq , s t ruc t t a s k _ s t r u c t ∗p ) ;

. . .} ;

These hooks are all scheduling operations for a scheduler.

Y. Sun (GPCSE) Master thesis September 14, 2012 9 / 26

Page 12: Presentation 14 09_2012

The Linux scheduling is runqueue centered

Every hook in a scheduling class deals with the struct rq. Astruct rq instance is called runqueue in Linux.

The struct rq is a per CPU structure. That is, there is arunqueue per CPU in Linux.

A scheduling system is built around the runqueue in each CPU.Different per CPU scheduling systems cooperate with each otherthrough task migration strategy defined by schedulers.

Y. Sun (GPCSE) Master thesis September 14, 2012 10 / 26

Page 13: Presentation 14 09_2012

The scheme of per CPU scheduling in Linux

Y. Sun (GPCSE) Master thesis September 14, 2012 11 / 26

Page 14: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 12 / 26

Page 15: Presentation 14 09_2012

The Open Extension Container (OXC) structure

The idea of ox container issimple: any datastructure that contains arunqueue inside isregarded as the oxcontainer

Y. Sun (GPCSE) Master thesis September 14, 2012 13 / 26

Page 16: Presentation 14 09_2012

Pass an ox container’s local runqueue to a schedulingoperation

For a scheduler, it needs a runqueue so as to deal with its tasks.This runqueue can be the per CPU runqueue or an ox container’slocal runqueue.

When an ox container’s local runqueue is used by a scheduler,tasks will run in this local runqueue.

Now, besides per CPU scheduling system, there is the per oxcontainer scheduling system in Linux.

Y. Sun (GPCSE) Master thesis September 14, 2012 14 / 26

Page 17: Presentation 14 09_2012

Per oxc scheduling + per CPU schedulingcoexist in Linux

Y. Sun (GPCSE) Master thesis September 14, 2012 15 / 26

Page 18: Presentation 14 09_2012

The oxc scheduling can be structured in a hierarchy

Y. Sun (GPCSE) Master thesis September 14, 2012 16 / 26

Page 19: Presentation 14 09_2012

To allocate CPU bandwidth for an ox container

Different schedulers can use an ox container to enqueue, operateand dequeue their tasks.

Suppose a fraction of CPU bandiwdth is allocated to an oxcontainer, all kinds of tasks inside the container will use it as ifrunning on a less powerful CPU.

Y. Sun (GPCSE) Master thesis September 14, 2012 17 / 26

Page 20: Presentation 14 09_2012

To allocate CPU bandwidth for an ox container

Different schedulers can use an ox container to enqueue, operateand dequeue their tasks.

Suppose a fraction of CPU bandiwdth is allocated to an oxcontainer, all kinds of tasks inside the container will use it as ifrunning on a less powerful CPU.

Based on this idea, the oxc (scheduling) framework is developed tocontrol CPU bandwidth allocated to tasks, which can be any type , ina real-time way.

Y. Sun (GPCSE) Master thesis September 14, 2012 17 / 26

Page 21: Presentation 14 09_2012

A concrete ox container that can reserve CPUbandwidth

This an ox container that canreserve bandwidth from a CPUaccording to CBS rules.

s t ruc t oxc_rq {unsigned long oxc_nr_running ;i n t o x c _ t h r o t t l e d ;u64 oxc_runt ime ;k t ime_t oxc_per iod ;u64 oxc_deadl ine ;u64 oxc_time ;u64 oxc_s ta r t_ t ime ;

s t ruc t h r t ime r oxc_per iod_t imer ;raw_sp in lock_t oxc_runt ime_lock ;bool oxc_needs_resync ;

s t ruc t rq rq_ ;s t ruc t rq ∗rq ;s t ruc t rb_node rb_node ;

} ;

oxc_runtime and oxc_periodare the maximum budget and pe-riod parameters in CBS.

Y. Sun (GPCSE) Master thesis September 14, 2012 18 / 26

Page 22: Presentation 14 09_2012

A concrete ox container that can reserve CPUbandwidth

This an ox container that canreserve bandwidth from a CPUaccording to CBS rules.

s t ruc t oxc_rq {unsigned long oxc_nr_running ;i n t o x c _ t h r o t t l e d ;u64 oxc_runt ime ;k t ime_t oxc_per iod ;u64 oxc_deadl ine ;u64 oxc_time ;u64 oxc_s ta r t_ t ime ;

s t ruc t h r t ime r oxc_per iod_t imer ;raw_sp in lock_t oxc_runt ime_lock ;bool oxc_needs_resync ;

s t ruc t rq rq_ ;s t ruc t rq ∗rq ;s t ruc t rb_node rb_node ;

} ;

oxc_runtime and oxc_periodare the maximum budget and pe-riod parameters in CBS.

the local runqueue of an ox con-tainer

Y. Sun (GPCSE) Master thesis September 14, 2012 18 / 26

Page 23: Presentation 14 09_2012

SMP support

An ox container can onlyreserve CPU bandwidth from aCPU.

The hyper ox containerstructure is defined forreserving bandwidths frommultiple processors.

s t ruc t hyper_oxc_rq {cpumask_var_t cpus_allowed ;s t ruc t oxc_rq ∗∗ oxc_rq ;

} ;

cpus_allowed specifies the CPUthat bandwidths are reserved from.

Y. Sun (GPCSE) Master thesis September 14, 2012 19 / 26

Page 24: Presentation 14 09_2012

SMP support

An ox container can onlyreserve CPU bandwidth from aCPU.

The hyper ox containerstructure is defined forreserving bandwidths frommultiple processors.

s t ruc t hyper_oxc_rq {cpumask_var_t cpus_allowed ;s t ruc t oxc_rq ∗∗ oxc_rq ;

} ;

cpus_allowed specifies the CPUthat bandwidths are reserved from.

The ox containers to reserve band-widths from corresponding CPUs

Y. Sun (GPCSE) Master thesis September 14, 2012 19 / 26

Page 25: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 20 / 26

Page 26: Presentation 14 09_2012

Experiment set-ups

Candidates :

RT throttling : CPU bandwidth control work, without real-timeguarantee, for RT tasks.

CFS bandwidth control : CPU bandwidth control work, withoutreal-time guarantee, for CFS tasks.

oxc control : Our CPU bandwidth control work, with real-timeguarantee, for any type of tasks.

Experiment rules:

Two tbench connections will be set up in the system; eachconnection is dedicated to one CPU in a dual processor platform.

The CPU bandwidth allocated to tbench traffic is restricted usingthe above work individually.

Y. Sun (GPCSE) Master thesis September 14, 2012 21 / 26

Page 27: Presentation 14 09_2012

Results: oxc control vs. RT throttling

Y. Sun (GPCSE) Master thesis September 14, 2012 22 / 26

Page 28: Presentation 14 09_2012

Results: oxc control vs. CFS bandwidth control

Y. Sun (GPCSE) Master thesis September 14, 2012 23 / 26

Page 29: Presentation 14 09_2012

Results

Given that our work is still a prototype, such results are veryencouraging.

Y. Sun (GPCSE) Master thesis September 14, 2012 24 / 26

Page 30: Presentation 14 09_2012

Results

Given that our work is still a prototype, such results are veryencouraging.

In addition: we can provide real-time gurantee ;-)

Y. Sun (GPCSE) Master thesis September 14, 2012 24 / 26

Page 31: Presentation 14 09_2012

Results

Given that our work is still a prototype, such results are veryencouraging.

In addition: we can provide real-time gurantee ;-)

What I am really trying to sell :Our one-for-all solution for CPU bandwidth control in Linuxis feasible!!!

Y. Sun (GPCSE) Master thesis September 14, 2012 24 / 26

Page 32: Presentation 14 09_2012

Outline

1 What is an ideal CPU bandwidth control mechanism for Linux?

2 A brief background

3 The OXC framework

4 Game time!

5 Conclusion

Y. Sun (GPCSE) Master thesis September 14, 2012 25 / 26

Page 33: Presentation 14 09_2012

Conclusion

In mainline Linux there are two schedulers.

Numerous schedulers have been or will be implemented based onLinux for various reasons.

There exists CPU bandwidth control work dealing with some ofthese schedulers. But each such mechanism can only work withfor one scheduler (one specific type of tasks).

Y. Sun (GPCSE) Master thesis September 14, 2012 26 / 26

Page 34: Presentation 14 09_2012

Conclusion

In mainline Linux there are two schedulers.

Numerous schedulers have been or will be implemented based onLinux for various reasons.

There exists CPU bandwidth control work dealing with some ofthese schedulers. But each such mechanism can only work withfor one scheduler (one specific type of tasks).

The oxc framework can provide real-time CPU bandwidthcontrol for tasks of all these schedulers!

The project is just started; more work is coming.

Y. Sun (GPCSE) Master thesis September 14, 2012 26 / 26