SlideShare a Scribd company logo
Title: RT Linux
Seyed Navid Ashrafi
Telecommunication Networks Group
Technische Universität Berlin
Summer Semester 2018
35-minute presentation
NES SS2018 1
Over view
>> Introduction to RTOS
- Definitions and history
- Usages & requirements
NES SS2018 2
>> PREEMPT_RT patch
- Overview
- Features
>> Latency measurement test
>> Conclusion
>> Different approaches
- Xenomai
- PREEMPT_RT
- Cons & pros
What is real time?
• It is about fast operation time
• It is about performance
• Its about DETERMINISM
- You need to execute an operation in a specific time frame and you need a
guarantee for that.
- As fast as specified, not as fast as possible
- RT-Linux: Deterministic timing behavior in Linux.
- Depends on the system
NES SS2018 3
Usage and requirements of RT-Linux
• Usages:
- Industrial applications
- Multimedia systems
- Aerospace system
- Automative
- Financial services
• Requirements:
- Deterministic timing behavior
- Preemption
- priority inheritance
NES SS2018 4
Soft Realtime??
• It is in contrast with deterministic behavior
• We concentrate on 100% and 95% hard RT.
• 100% hard RT: Realtime requirements should be met 100% otherwise
it will lead to an error condition (industry)
• 95% hard RT: Realtime requirements should be met 95% (data
collection)
NES SS2018 5
Critical section
• Concurrent access to a shared resource can lead to
unexpected or error condition
• There are over 10,000 individual critical section in a
typical Linux 2.6 kernel
• In the non-preemptible design of Linux 2.6
kernel, any critical section can block preemption
• In the Preemptible design the effort was to reduce the total size and
number of non-preemptible critical sections.
NES SS2018 6
Approaches
Dual-kernel / Co-kernel
Single-kernel / In-kernel
NES SS2018 7
Dual-kernel approach
• First approaches which are still existing.
• Linux is running on top of a microkernel as a low priority real time task.
• The microkernel does the real time stuff.
• You need to maintain the microkernel and a hardware abstraction layer on Linux
to make it run on the microkernel:
- Big, time consuming effort.
- Reason why most of these approaches
are always one step behind
Linux fast development
NES SS2018 8
Single-kernel approach
• A way to make Linux it self real-time capable.
• You would have to touch every single file in the kernel.
• No microkernel or hardware abstraction layer (you can just work with
Linux standard tools).
NES SS2018 9
Xenomai
Xenomai 1.0
• Announced in 2001 – as portability framework for RTOS applications
• Required a real-time basis
• Development of ADEOS layer for Linux and RTAI
• Merged with RTAI
Xenomai 2.0
• Departed from RTAI in 2005 – incompatible design goals
• Evolved ADEOS to I-pipe layer (also used by RTAI)
• Ported to 6 architectures
Xenomai 3.0
• Released in 2015 after 5 years of development
• Rework of in-kernel core (now POSIX-centric)
• Support for native Linux
NES SS2018 10
Xenomai
NES SS2018 11
microkernel preempts Linux
Xenomai architecture
NES SS2018 12
Migration between schedulers
• creating realtime task in application, over a normal Linux task
• 2 threads for one task which share a lot of states
• only one of them can run at the same time
• Migration to RT: suspend Linux task, resume Cobalt thread
• Migration to Linux (on syscall, fault/trap, signal):
suspend Cobalt thread, resume Linux task
• Every things that we do not handle in Xenomai will be directed
to Linux
NES SS2018 13
Hardware abstraction layer
I-pipe Core
NES SS2018 14
Issues of dual-kernel approach
• Special API
• Special tools and libraries
• Microkernel needs to be ported for new HW and new Linux versions
• Bad scaling on big platforms
• Various number of not palatable patches
• Changes to critical subsystems regularly cause regressions
• Porting efforts consume core developer resources
-Most work done by Philippe and Gilles so far
-Time would be better spent on feature improvements...
NES SS2018 15
Xenomai application
• Machine control systems, PLCs
• Printing machines (manroland)
• Printers / copying machines
• Network switches (e.g. Ruggedcom)
• Magnetic resonance tomographs (Siemens Healthcare)
• OROCOS (OSS robotics framework)
• Robotic research projects
• … (many, many incognito applications)
NES SS2018 16
Preempt_RT
• Founded 14 years ago by: Thomas Gleixner & Ingo Molnar
• Huge community
• In-kernel approach
• Main idea: only code that, absolutely must be non-preemptible, is allowed
to be non-preemptible
• Most of the features already made it into the “mainline”
• Interrupt handlers run in a kernel thread which has two advantages:
- The kernel thread is interruptible
- It shows up in a process list with a PID
• First mainline integration 2006
NES SS2018 17
Preempt_RT Goals
• 100% Preemptible kernel
- not possible yet, but let’s try regardless
- Removal of interrupts and preemption disabling
- Fast “worst case” time.
• Quick reaction time
- Bring latencies down to a minimum
• Minimize non-Preemptible kernel code
- at the meantime Minimize code changing amount
NES SS2018 18
Evolution of RT-Linux
NES SS2018 19
PREEMPT_RT architecture
NES SS2018 20
Fully Preemptible kernel (the RT patch)
• Preemption almost everywhere
• Spinlocks turn into mutexes
• No hard interrupt context
• Preemptible critical section
• Preemptible interrupt handlers
• Preemptible “interrupt disable” code sequence
• Priority inheritance
• Deferred operation
• Latency reduction
NES SS2018 21
Mutex
• Critical sections are still protected without disabling preemption
• A Mutex guarantees data integrity while extending the operation of the
spinlock
- we have priority inheritance
- All locks are assumed to be preemptible
- This design eliminates the possibility that an inefficient locking
implementation in a driver can introduce un-detected latency into
the system.
- Only a small subset of locks stay unpreemptible which are manageable.
NES SS2018 22
Priority inversion
• When a high priority task wants to run but it can not because a lower
priority task is holding that lock
• It is bad but we can not get rid of it, what we can get rid of is
unbounded priority inversion
NES SS2018 23
Unbounded priority inversion
NES SS2018 24
A
B
C
Priority inheritance
NES SS2018 25
A
B
C
local_irq_disable
asmlinkage void
do_entInt(unsigned long type, unsigned long vector,
unsigned long la_ptr, struct pt_regs *regs)
{
struct pt_regs *old_regs;
local_irq_disable();
switch (type) {
case 0:
#ifdef CONFIG_SMP
NES SS2018 26
handle_ipi(regs);
return;
#else
irq_err_count++;
printk(KERN_CRIT "Interprocessor interrupt?
"You must be kidding!n");
#endif
break;
1 2
Preempt_disable
NES SS2018 27
• Local_irq_disable younger sibling
• Also does not give a hint to what does it do!
• Has the exact same problems of local_irq_disable
• Preempt_enable_no_resched
- only should be used within preempt_disable locations
Why do we still need Co-kernel?
Functional limitations of In-kernel
• Emulation of RTOS scheduling behavior limited
by Linux scheduler
• Not all kernel+libc code paths used by In-kernel approaches
are necessarily hard real-time under PREEMPT-RT
• No detection of non-RT behavior of your application
Performance limitations of In-kernel
• Co-kernel is usually more light-weight on low-end platforms
(limited caches vs. code path lengths)
• PREEMPT-RT can have unwanted impact
co-located non-RT workloads
Xenomai adds value to Linux
• it keeps the realtime stuff away from the complexities
of Linux kernel
• Co-kernel approach can be beneficial
for low latencies and real-time application architecture
NES SS2018 28
Latency measurement on xenomai & preempt_RT
• Made by Jan Altenberg from Linutronix GmbH
• On two ARM Cortex A9 SOC platforms
• IRQ test with 10KHz frequency with the latency box
• 100% CPU load with “hackbench”
• They did the test in usespace and kernelspace
• 12-hour duration
NES SS2018 29
Hackbench
• Starts n groups of 20 clients and 20 servers
• Each client sends 100 messages to each server via a socket
connection
NES SS2018 30
Latency box
NES SS2018 31
Xenomai latency userspace task
NES SS2018 32
PREEMPT_RT latency userspace task
NES SS2018 33
PREEMPT_RT latency userspace task (isolated CPU)
NES SS2018 34
Latency: userspac- Comparison
NES SS2018 35
Xenomai latency in kernelspace
NES SS2018 36
PREEMPT_RT latency in kernelspace
NES SS2018 37
PREEMPT_RT latency in kernelspace (isolated)
NES SS2018 38
PREEMPT_RT latency in kernelspace (using FIQ)
NES SS2018 39
Latency: Kernel - Comparison
NES SS2018 40
Test results
• Which approach to choose?
- If timing is vital, choose Xenomai, it separates the realtime interrupt
handling from complexities of Linux kernel
• You can go with PREEMPT_RT using FIQ
• Xenomai kernelspace is the best for 100% hard performance
• Xenomai userspace is slower than it’s kernelspace
• Tests only can help you in the field of latency which is dependent on
the hardware
• No guarantee for results repeatation
NES SS2018 41
Conclusion
• PREEMPT_RT is getting integrated in Linux mainline
- Download here: https://www.kernel.org/
• PREEMPT_RT Increases Linux stability and quality
• PREEMPT_RT is simple to use
• Xenomai has it’s own advantages over PREEMPT_RT
• Microkernels are hard to handle
• For the most use cases the latency of the both approaches is almost
the same
• FIQ offers very fast latency but brings limitations
NES SS2018 42
Thank you
NES SS2018 43

More Related Content

What's hot (20)

PPTX
Linux Boot Process
darshhingu
 
PPTX
Bootloaders (U-Boot)
Omkar Rane
 
PDF
Uboot startup sequence
Houcheng Lin
 
PPTX
Threads in Operating System | Multithreading | Interprocess Communication
Shivam Mitra
 
PDF
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Tushar B Kute
 
PDF
So-mod-2
diogoa21
 
PDF
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Linaro
 
PDF
Scheduling in Android
Opersys inc.
 
PPTX
Linux booting process
Prashant Hegde
 
PPT
Bootstrap process of u boot (NDS32 RISC CPU)
Macpaul Lin
 
PPTX
Linux
shamxsa
 
PDF
Bootloaders
Anil Kumar Pugalia
 
PDF
WALT vs PELT : Redux - SFO17-307
Linaro
 
PPTX
U-Boot Porting on New Hardware
RuggedBoardGroup
 
PPTX
Sistemas Operacionais - Aula 6 - Estrutura do Sistema Operacional
Charles Fortes
 
PDF
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
The Linux Foundation
 
PDF
Reducing boot time in embedded Linux
Chris Simmonds
 
PPTX
Tarjeta de sonido modulo 11
Uriel Mathieu
 
PDF
Xvisor: embedded and lightweight hypervisor
National Cheng Kung University
 
Linux Boot Process
darshhingu
 
Bootloaders (U-Boot)
Omkar Rane
 
Uboot startup sequence
Houcheng Lin
 
Threads in Operating System | Multithreading | Interprocess Communication
Shivam Mitra
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Tushar B Kute
 
So-mod-2
diogoa21
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Linaro
 
Scheduling in Android
Opersys inc.
 
Linux booting process
Prashant Hegde
 
Bootstrap process of u boot (NDS32 RISC CPU)
Macpaul Lin
 
Linux
shamxsa
 
Bootloaders
Anil Kumar Pugalia
 
WALT vs PELT : Redux - SFO17-307
Linaro
 
U-Boot Porting on New Hardware
RuggedBoardGroup
 
Sistemas Operacionais - Aula 6 - Estrutura do Sistema Operacional
Charles Fortes
 
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
The Linux Foundation
 
Reducing boot time in embedded Linux
Chris Simmonds
 
Tarjeta de sonido modulo 11
Uriel Mathieu
 
Xvisor: embedded and lightweight hypervisor
National Cheng Kung University
 

Similar to Real time Linux (20)

PDF
Trends in Systems and How to Get Efficient Performance
inside-BigData.com
 
PPTX
Værktøjer udviklet på AAU til analyse af SCJ programmer
InfinIT - Innovationsnetværket for it
 
PDF
淺談 Live patching technology
SZ Lin
 
PDF
PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...
Puppet
 
PPTX
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
MayaData Inc
 
PDF
“Meeting the Critical Needs of Accuracy, Performance and Adaptability in Embe...
Edge AI and Vision Alliance
 
PDF
Testing real-time Linux. What to test and how
Chirag Jog
 
PPT
Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Michael Christofferson
 
ODP
Realtime
Mark Veltzer
 
PPT
운영체제론 Ch22
Jongmyoung Kim
 
PDF
RISC V in Spacer
klepsydratechnologie
 
PDF
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
PDF
Embedded systems introduction
Sagar Adroja
 
PDF
Embedded Systems Introduction
Sagar Adroja
 
PDF
"Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese...
Edge AI and Vision Alliance
 
PPTX
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
InfinIT - Innovationsnetværket for it
 
PPTX
Intro to HPC
Wendi Sapp
 
PDF
Linux Kernel Security Overview - KCA 2009
James Morris
 
PDF
Update on Trinity System Procurement and Plans
inside-BigData.com
 
PPTX
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Adam Dunkels
 
Trends in Systems and How to Get Efficient Performance
inside-BigData.com
 
Værktøjer udviklet på AAU til analyse af SCJ programmer
InfinIT - Innovationsnetværket for it
 
淺談 Live patching technology
SZ Lin
 
PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...
Puppet
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
MayaData Inc
 
“Meeting the Critical Needs of Accuracy, Performance and Adaptability in Embe...
Edge AI and Vision Alliance
 
Testing real-time Linux. What to test and how
Chirag Jog
 
Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Michael Christofferson
 
Realtime
Mark Veltzer
 
운영체제론 Ch22
Jongmyoung Kim
 
RISC V in Spacer
klepsydratechnologie
 
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
Embedded systems introduction
Sagar Adroja
 
Embedded Systems Introduction
Sagar Adroja
 
"Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese...
Edge AI and Vision Alliance
 
Towards "write once - run whenever possible" with Safety Critical Java af Ben...
InfinIT - Innovationsnetværket for it
 
Intro to HPC
Wendi Sapp
 
Linux Kernel Security Overview - KCA 2009
James Morris
 
Update on Trinity System Procurement and Plans
inside-BigData.com
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Adam Dunkels
 
Ad

Recently uploaded (20)

PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
July Patch Tuesday
Ivanti
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Ad

Real time Linux

  • 1. Title: RT Linux Seyed Navid Ashrafi Telecommunication Networks Group Technische Universität Berlin Summer Semester 2018 35-minute presentation NES SS2018 1
  • 2. Over view >> Introduction to RTOS - Definitions and history - Usages & requirements NES SS2018 2 >> PREEMPT_RT patch - Overview - Features >> Latency measurement test >> Conclusion >> Different approaches - Xenomai - PREEMPT_RT - Cons & pros
  • 3. What is real time? • It is about fast operation time • It is about performance • Its about DETERMINISM - You need to execute an operation in a specific time frame and you need a guarantee for that. - As fast as specified, not as fast as possible - RT-Linux: Deterministic timing behavior in Linux. - Depends on the system NES SS2018 3
  • 4. Usage and requirements of RT-Linux • Usages: - Industrial applications - Multimedia systems - Aerospace system - Automative - Financial services • Requirements: - Deterministic timing behavior - Preemption - priority inheritance NES SS2018 4
  • 5. Soft Realtime?? • It is in contrast with deterministic behavior • We concentrate on 100% and 95% hard RT. • 100% hard RT: Realtime requirements should be met 100% otherwise it will lead to an error condition (industry) • 95% hard RT: Realtime requirements should be met 95% (data collection) NES SS2018 5
  • 6. Critical section • Concurrent access to a shared resource can lead to unexpected or error condition • There are over 10,000 individual critical section in a typical Linux 2.6 kernel • In the non-preemptible design of Linux 2.6 kernel, any critical section can block preemption • In the Preemptible design the effort was to reduce the total size and number of non-preemptible critical sections. NES SS2018 6
  • 8. Dual-kernel approach • First approaches which are still existing. • Linux is running on top of a microkernel as a low priority real time task. • The microkernel does the real time stuff. • You need to maintain the microkernel and a hardware abstraction layer on Linux to make it run on the microkernel: - Big, time consuming effort. - Reason why most of these approaches are always one step behind Linux fast development NES SS2018 8
  • 9. Single-kernel approach • A way to make Linux it self real-time capable. • You would have to touch every single file in the kernel. • No microkernel or hardware abstraction layer (you can just work with Linux standard tools). NES SS2018 9
  • 10. Xenomai Xenomai 1.0 • Announced in 2001 – as portability framework for RTOS applications • Required a real-time basis • Development of ADEOS layer for Linux and RTAI • Merged with RTAI Xenomai 2.0 • Departed from RTAI in 2005 – incompatible design goals • Evolved ADEOS to I-pipe layer (also used by RTAI) • Ported to 6 architectures Xenomai 3.0 • Released in 2015 after 5 years of development • Rework of in-kernel core (now POSIX-centric) • Support for native Linux NES SS2018 10
  • 13. Migration between schedulers • creating realtime task in application, over a normal Linux task • 2 threads for one task which share a lot of states • only one of them can run at the same time • Migration to RT: suspend Linux task, resume Cobalt thread • Migration to Linux (on syscall, fault/trap, signal): suspend Cobalt thread, resume Linux task • Every things that we do not handle in Xenomai will be directed to Linux NES SS2018 13
  • 14. Hardware abstraction layer I-pipe Core NES SS2018 14
  • 15. Issues of dual-kernel approach • Special API • Special tools and libraries • Microkernel needs to be ported for new HW and new Linux versions • Bad scaling on big platforms • Various number of not palatable patches • Changes to critical subsystems regularly cause regressions • Porting efforts consume core developer resources -Most work done by Philippe and Gilles so far -Time would be better spent on feature improvements... NES SS2018 15
  • 16. Xenomai application • Machine control systems, PLCs • Printing machines (manroland) • Printers / copying machines • Network switches (e.g. Ruggedcom) • Magnetic resonance tomographs (Siemens Healthcare) • OROCOS (OSS robotics framework) • Robotic research projects • … (many, many incognito applications) NES SS2018 16
  • 17. Preempt_RT • Founded 14 years ago by: Thomas Gleixner & Ingo Molnar • Huge community • In-kernel approach • Main idea: only code that, absolutely must be non-preemptible, is allowed to be non-preemptible • Most of the features already made it into the “mainline” • Interrupt handlers run in a kernel thread which has two advantages: - The kernel thread is interruptible - It shows up in a process list with a PID • First mainline integration 2006 NES SS2018 17
  • 18. Preempt_RT Goals • 100% Preemptible kernel - not possible yet, but let’s try regardless - Removal of interrupts and preemption disabling - Fast “worst case” time. • Quick reaction time - Bring latencies down to a minimum • Minimize non-Preemptible kernel code - at the meantime Minimize code changing amount NES SS2018 18
  • 21. Fully Preemptible kernel (the RT patch) • Preemption almost everywhere • Spinlocks turn into mutexes • No hard interrupt context • Preemptible critical section • Preemptible interrupt handlers • Preemptible “interrupt disable” code sequence • Priority inheritance • Deferred operation • Latency reduction NES SS2018 21
  • 22. Mutex • Critical sections are still protected without disabling preemption • A Mutex guarantees data integrity while extending the operation of the spinlock - we have priority inheritance - All locks are assumed to be preemptible - This design eliminates the possibility that an inefficient locking implementation in a driver can introduce un-detected latency into the system. - Only a small subset of locks stay unpreemptible which are manageable. NES SS2018 22
  • 23. Priority inversion • When a high priority task wants to run but it can not because a lower priority task is holding that lock • It is bad but we can not get rid of it, what we can get rid of is unbounded priority inversion NES SS2018 23
  • 26. local_irq_disable asmlinkage void do_entInt(unsigned long type, unsigned long vector, unsigned long la_ptr, struct pt_regs *regs) { struct pt_regs *old_regs; local_irq_disable(); switch (type) { case 0: #ifdef CONFIG_SMP NES SS2018 26 handle_ipi(regs); return; #else irq_err_count++; printk(KERN_CRIT "Interprocessor interrupt? "You must be kidding!n"); #endif break; 1 2
  • 27. Preempt_disable NES SS2018 27 • Local_irq_disable younger sibling • Also does not give a hint to what does it do! • Has the exact same problems of local_irq_disable • Preempt_enable_no_resched - only should be used within preempt_disable locations
  • 28. Why do we still need Co-kernel? Functional limitations of In-kernel • Emulation of RTOS scheduling behavior limited by Linux scheduler • Not all kernel+libc code paths used by In-kernel approaches are necessarily hard real-time under PREEMPT-RT • No detection of non-RT behavior of your application Performance limitations of In-kernel • Co-kernel is usually more light-weight on low-end platforms (limited caches vs. code path lengths) • PREEMPT-RT can have unwanted impact co-located non-RT workloads Xenomai adds value to Linux • it keeps the realtime stuff away from the complexities of Linux kernel • Co-kernel approach can be beneficial for low latencies and real-time application architecture NES SS2018 28
  • 29. Latency measurement on xenomai & preempt_RT • Made by Jan Altenberg from Linutronix GmbH • On two ARM Cortex A9 SOC platforms • IRQ test with 10KHz frequency with the latency box • 100% CPU load with “hackbench” • They did the test in usespace and kernelspace • 12-hour duration NES SS2018 29
  • 30. Hackbench • Starts n groups of 20 clients and 20 servers • Each client sends 100 messages to each server via a socket connection NES SS2018 30
  • 32. Xenomai latency userspace task NES SS2018 32
  • 33. PREEMPT_RT latency userspace task NES SS2018 33
  • 34. PREEMPT_RT latency userspace task (isolated CPU) NES SS2018 34
  • 36. Xenomai latency in kernelspace NES SS2018 36
  • 37. PREEMPT_RT latency in kernelspace NES SS2018 37
  • 38. PREEMPT_RT latency in kernelspace (isolated) NES SS2018 38
  • 39. PREEMPT_RT latency in kernelspace (using FIQ) NES SS2018 39
  • 40. Latency: Kernel - Comparison NES SS2018 40
  • 41. Test results • Which approach to choose? - If timing is vital, choose Xenomai, it separates the realtime interrupt handling from complexities of Linux kernel • You can go with PREEMPT_RT using FIQ • Xenomai kernelspace is the best for 100% hard performance • Xenomai userspace is slower than it’s kernelspace • Tests only can help you in the field of latency which is dependent on the hardware • No guarantee for results repeatation NES SS2018 41
  • 42. Conclusion • PREEMPT_RT is getting integrated in Linux mainline - Download here: https://www.kernel.org/ • PREEMPT_RT Increases Linux stability and quality • PREEMPT_RT is simple to use • Xenomai has it’s own advantages over PREEMPT_RT • Microkernels are hard to handle • For the most use cases the latency of the both approaches is almost the same • FIQ offers very fast latency but brings limitations NES SS2018 42