introduction to realtime linux › sites › events › files › slides › ... · introduction to...

42
Introduction to Realtime Linux Jan Altenberg Linutronix GmbH Jan Altenberg Linutronix GmbH 1

Upload: others

Post on 08-Jun-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Introduction to Realtime Linux

Jan Altenberg

Linutronix GmbH

Jan Altenberg Linutronix GmbH 1

Page 2: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Overview

..1 What is Realtime?

..2 Linux and Realtime

..3 Results: Which latencies can be achieved with the differentapproaches?

..4 Conclusion

Jan Altenberg Linutronix GmbH 2

Page 3: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What is Realtime?

Fast execution time?

Jan Altenberg Linutronix GmbH 3

Page 4: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What is Realtime?

Performance?

Jan Altenberg Linutronix GmbH 4

Page 5: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What is Realtime?

It's all about DETERMINISM!

Jan Altenberg Linutronix GmbH 5

Page 6: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What is Realtime?

Correctness means execution at the correct timeMissing the timeslot will lead to an error condition

Jan Altenberg Linutronix GmbH 6

Page 7: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Realtime

Remember!Missing the timeslot will lead to an error condition

Jan Altenberg Linutronix GmbH 7

Page 8: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Realtime

Missing the timelinewill cause a damage to your machine or even a person might get hurt:

Jan Altenberg Linutronix GmbH 8

Page 9: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What about ''Softrealtime''?

…PLEASE PLEEAAASSEEE forget about this word!!! :)

Jan Altenberg Linutronix GmbH 9

Page 10: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Who is using it?

industry / automationmultimedia systemsaerospacefinancial services…

Jan Altenberg Linutronix GmbH 10

Page 11: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Requirements

Deterministic timing behaviourPreemptionPriority Inheritance / Priority Ceiling

Jan Altenberg Linutronix GmbH 11

Page 12: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Priority Inversion

Jan Altenberg Linutronix GmbH 12

Page 13: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Approaches

Dual-KernelIn-Kernel / Single Kernel

Jan Altenberg Linutronix GmbH 13

Page 14: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Dual-Kernel

Jan Altenberg Linutronix GmbH 14

Page 15: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Single-Kernel

Jan Altenberg Linutronix GmbH 15

Page 16: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

RTAI

Prof. Paolo Mantegazza, University of MilanoDual-Kernel approachRealtime in kernelspaceRealtime in userspace very limitedDesign goal: Lowest latenciesSupported platforms: x86, x86_64, and a couple of ARM platforms

Jan Altenberg Linutronix GmbH 16

Page 17: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

RTAI

Jan Altenberg Linutronix GmbH 17

Page 18: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Xenomai

Founded 2001Realtime in userspaceSkins can emulate the API of different RTOSesDual-Kernel approachSupported platforms: x86, x86_64, PowerPC, ARM, ia64

Jan Altenberg Linutronix GmbH 18

Page 19: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Xenomai

Jan Altenberg Linutronix GmbH 19

Page 20: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Known issues of dual-kernel approaches

Special APISpecial tools and librariesMicrokernel needs to be ported for new HW and new Linux versionsBad scaling on big platforms

Jan Altenberg Linutronix GmbH 20

Page 21: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Preempt RT

In-Kernel approachFounded by: Thomas Gleixner, Ingo MolnarHuge communityMost of the features already made it into ''Mainline''POSIX realtimeHighly accepted in the community

Jan Altenberg Linutronix GmbH 21

Page 22: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Preempt RT undMainline

''Controlling a laser with Linux is crazy, but everyone in this room is crazyin his own way. So if you want to use Linux to control an industrialwelding laser, I have no problem with your using Preempt RT'' - LinusTorvalds auf dem Kernel Summit 2006

Jan Altenberg Linutronix GmbH 22

Page 23: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

How Preempt RT brings Realtime to Linux?

Remember once again…Preemption is the most important requirement for a Realtime System

Jan Altenberg Linutronix GmbH 23

Page 24: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

How Preempt RT brings Realtime to Linux?

Locking Primitives: Spinlocks are replaced by RT Mutexes. RawSpinlocks behave like the original Spinlocks.Interrupt Handlers run in a kernel thread

Jan Altenberg Linutronix GmbH 23

Page 25: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Preempt RT

Jan Altenberg Linutronix GmbH 24

Page 26: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency Measurements on a Cortex A9 platform

ARM Cortex A9 SOC (Altera Cyclone V)System load: 100% CPU load with hackbenchIRQ tests at 10 kHz with the OSADL Latency BoxTest duration 12h

Jan Altenberg Linutronix GmbH 25

Page 27: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Load scenario: hackbench

Starts n groups of 20 clients and 20 serversEach client sends 100 messages to each server via a socketconnection

Jan Altenberg Linutronix GmbH 26

Page 28: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

What has beenmeasured?

Latency and Jitter

Jan Altenberg Linutronix GmbH 27

Page 29: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency measurement

Jan Altenberg Linutronix GmbH 28

Page 30: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Userspace Latency: The most important usecase

The most important usecase is the latency of a userspace task. Usually auserspace task needs to be synced with an external event.

Jan Altenberg Linutronix GmbH 29

Page 31: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Xenomai: latency userspace task

Jan Altenberg Linutronix GmbH 30

Page 32: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

PREEMPT_RT: latency userspace task

Jan Altenberg Linutronix GmbH 31

Page 33: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

PREEMPT_RT: latency userspace task (isolated CPU)

Jan Altenberg Linutronix GmbH 32

Page 34: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency userspace task - comparison

Jan Altenberg Linutronix GmbH 33

Page 35: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency within the Kernel

…or how to compare apples with pears!! ;-)

Jan Altenberg Linutronix GmbH 34

Page 36: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency: Kernel - Xenomai

Jan Altenberg Linutronix GmbH 35

Page 37: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency: Kernel - PREEMPT_RT

Jan Altenberg Linutronix GmbH 36

Page 38: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency: Kernel - PREEMPT_RT (isolated CPU)

Jan Altenberg Linutronix GmbH 37

Page 39: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency: Kernel - PREEMPT_RT with FIQ (fast interrupt)

Jan Altenberg Linutronix GmbH 38

Page 40: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Latency: Kernel - Comparison

Jan Altenberg Linutronix GmbH 39

Page 41: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Conclusion

PREEMPT_RT became the de-facto standard for Realtime LinuxIntegration of PREEMPT_RT in Mainline LinuxSimple usage of PREEMPT_RTMicrokernels are hard to handleFor the most common use-cases the Microkernels do NOT havebetter latenciesFIQs offer fast latencies, but are hard to handle

Jan Altenberg Linutronix GmbH 40

Page 42: Introduction to Realtime Linux › sites › events › files › slides › ... · Introduction to Realtime Linux Author: Jan Altenberg Created Date: 10/8/2016 1:03:33 PM

Questions?

Jan Altenberg Linutronix GmbH 41