[original file is CABI_CELF_JapanTechnicalJamboree17.pdf by Yuasa, Tripeaks]
[translated by ikoma]
CELF Technical Jamboree #17
Oct. 25, 2007
CABI Supporting SMP
==(Common resource Accounting and Blocking Interfaces)
2
Background
[see original file for pictures]
* Embedded systems getting more diversified and complicated
- Larger size of applications
- More processes
- Simultaneous execution with audio/video replay
- Want to receive mail while replaying multimedia
- Want to assure respnse to input while replaying media
- Preventing resouce occupation
- Want to prevent CPU being occupied
- Want to limit the behavior of real time applications
- Downloaded application may not be safe
==> To keep quality while running various application simultaneously, resource management is essential
3
What is CABI?
[See original file for figure]
* Resource Management System
- Restrict execution time of application programs
- Restriction on execution time and cycles; controllable in minute granularity
- Grouping applications (processes)
- Resources can be allocated to groups
* Effects
- Better response
- Better response to key input
- Prevent resource occupation
- Prevent high priority process from occupying a resource
+------------------+
| Applications |
|+------+ +-------+|
|| MPEG | |Mailer ||
|+------+ +-------+|
|+------+ +-------+|
|| Game | |Browser||
|+------+ +-------+|
+------------------+
+-----------------+---------------+
| Audio and Video | Downloaded |
| Applications | Applications |
| 60% | 40% |
+-----------------+---------------+4
Time Specification in CABI
[See original file for figures]
* Execution time of a process is specified as cycle and execution time
Execution Time
CPU usage of proces (%) = ---------------- x 100
cycle
e.g. Set usage as 60% (Execution Time: 60ms; Cycle: 100ms)
block block
| |
V V
| Exec Time | | Exec Time |
| 60ms | | 60ms |
|<---------->| |<---------->|
process|============|--------|============|--------|--------> t
0 60 100 160 200
|<------------------->|<------------------->|<---
cycle cycle
100ms 100ms5
CABI Usage
[See original file for figures]
* Resource allocation for process/thread group
- Accounting Object (AO)
- Interface to handle single process and multiple processes uniformly
- Set CPU usage(%) (Cycle(T) and Exec Time(c)) and action at end (signal or block) for AO
- Bind process for which you want to restrict or assure resources to AO
AO 1 AO 2
60% 30%
c=60ms c=30ms Bind bash program
T=100ms T=100ms to the account object 2
and run it
TS TS RT RT
process process process process # ./cabi_exec_bind 2 /bin/bash6
CABI System Specification
[See original file for screenshot]
* Emblix
http://www.emblix.org/ [in Japanese]
7
System Architecture
[See original file for figures]
* Simple
- Simple structure
- Interface
- -- user / kernel
* Correct
- Original time management mechanism
- Use high resolution timer
* Independent
- No change in scheduler
- Minimal hooks to kernel
+-------+ +-------+ +-------+
|Process| |Process| |Process|
+-------+ +-------+ +-------+
| | |
+-------V------------V------------V---------+
| Accounting API Library | User
+--------------------|----------------------+ Mode
---------------------|---------------------------------------
+--------------------V----------------------+ Kernel
| System Call Interfaces | Mode
+-------------------------------------------+
| CABI |
| +---------------------------------------+ |
| | Time Management Functions | |
| +---------------------------------------+ |
| |
| +----+ +----+ +----+ +--------+ |
| | AO |-| AO |-| AO | |Overload| |
| | |-| |-| | | AO | |
| +----+ +----+ +----+ +--------+ |
+-------------------------------------------+
| callback hooks |
+----^-----------^---------^---------^------+
+----|-----------|---------|---------|------+
|+---V---++------V---------V---------V-----+|
|| || +--------++--------++--------+ ||
|| Timer || |schedule|| fork || exit | ||
|| ISR || +--------++--------++--------+ ||
|| || ||
|| || Process Management System ||
|| || ||
|+-------++--------------------------------+|
+-------------------------------------------+
| Linux Kernel |
+-------------------------------------------+8
Implementation Published
[See original file for screen shot]
* Published on sourceforge
http://sourceforge.jp/projects/cabi/ [in Japanese]
http://osrg.dcl.info.waseda.ac.jp/~doly/cabi/ [in English]
9
Use of SMP
[See original file for figures]
* sched_setaffinity
- Separate Non-Realtime (NRT) and Realtime (RT) processes per CPU
- While assuring realtime-ness, other processes can also be served
- Resources of NRT-allocated CPU are wasted
+-----+ +-----+ +-----+ +-----+
| | +=====+ +=====+ +=====+
| | | | | | | |
| | | RT | | RT | | RT |
+=====+ | | | | | |
| NRT | | | | | | |
+=====+ +=====+ +=====+ +=====+
CPU0 CPU1 CPU2 CPU310
CABI Supporting SMP
[See original file for figures]
* Manages execution time of processes per CPU
* Restricts execution time of RT processes
- Can assure run time for NRT
- RT and NRT can be allocated on a single CPU
+-----+ +-----+ +-----+ +-----+
| | | | +=====+ +=====+
+=====+ +=====+ | | | |
| NRT | | | | RT | | RT |
Resricts+=====+ | RT | | | | |
RT->| RT | | | | | | |
+=====+ +=====+ +=====+ +=====+
CPU0 CPU1 CPU2 CPU311
Changes from Conventional CABI
* At building AO
- Associate AO to a single CPU
- Specify CPU ID
* At binding a process to AO
- Processes belonging to a single AO
- Executed on a single CPU
- cpumask of process set with sched_setaffinity
12
Relation among AOs, CPUs and processes
[See original file for figures]
* At building AO
- Specify CPU ID at building AO
- Add CPU ID to the structure used by user interface
P1 AO P2
30%
+----+ +----+ +----+ +----+
|CPU0| |CPU1| |CPU2| |CPU3|
+----+ +----+ +----+ +----+13
Binding Process to AO
[See original file for figures]
* Transfer the process to the CPU associated with AO
- Execute sched_setaffinity to the process to be bound
P1 AO P2
30%
+----+ +----+ +----+ +----+
|CPU0| |CPU1| |CPU2| |CPU3|
+----+ +----+ +----+ +----+14 [See original file for screen shot]
15
Implementation Status
* Kernel
- 2.6.18.1
- High resolution timer
- 2.6.18-rt (now evaluating)
- High resolution timer
- Preemption mode Complete Preemption (real-time)
- Thread softirqs
- Thread hardirqs
16
Problem Occurred with RT Kernel
* Unable to call scheduler while interrupt disabled
- Changed hook point for blocking
- Hook point changed from interrupt handling to scheduler
- Changed blocking method from sleep_on to deactive_task
17
Remaining Issues 1
* Handling the case when a process bound to an AO is set sched_setaffinity
* Building AO without being associated with a single CPU
18
Remaining Issues 2
* Change of interface
- Management of other resources taken into account
- Task Control Groups (cgroups) introduced since 2.6.24
- Application grouping functions to Task Control Groups
* Evaluation assuming more realistic situation
