SlideShare a Scribd company logo
1 of 17
Download to read offline
Understanding Real Time Linux
Alex Shi
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Agenda
● What’s real time OS
● RTL project status
● RT testing and tracing
● Reasons of latency and solutions for them
● Resources
● Summary
ENGINEERS
AND DEVICES
WORKING
TOGETHER
What’s real time OS
● Real time and high performance
○ Fastest? Max throughput? Average latency?
○ No, predictable latency!
● Types:
○ Hard real time
■ Car engine, Nuclear power plant
○ Firm real time
■ Between hard/soft
○ Soft real time
■ Live audio/video
● RTOS list link
ENGINEERS
AND DEVICES
WORKING
TOGETHER
RTL project status
● RTL project
○ Linux Foundation plan to merge all RT code into upstream
○ Main team member of RT: Thomas Gleixner, Sebastian Siewior,
Richard Cohran, Anna-Maria Gleixner, Benedikt Spranger
○ David Long, Mathieu Poirier and Alex also work on it.
● Much of code merged into upstream
○ High res timer
○ Threaded interrupt
○ Lock dep / Ftrace
● A few code out of kernel
○ 400+ patches, < 20,000 lines
○ Sleep locking
○ Interrupt preemptable -- transfer to local lock
○ Optimized for Cpu hotplug Timers; memory alloc; Softirq; Rcu
ENGINEERS
AND DEVICES
WORKING
TOGETHER
RT testing and tracing
● Kernel setting
○ # CONFIG_PREEMPT_NONE
○ # CONFIG_PREEMPT_VOLUNTARY
○ # CONFIG_PREEMPT__LL
○ # CONFIG_PREEMPT_RTB
○ CONFIG_PREEMPT_RT_FULL=y
● Testing
○ Benchmarks: rt-tests, rt-app, ltp-realtime
○ ./cyclitest --smp -p98 -m
○ System stress: hackbench -l 10000
○ Results on my hikey620 and dragonaboard 410
■ Maximum latency less than 200 us in a busy system
● Tracing
○ Function trace
○ Latency trace
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Latency tracing
# echo 0 > options/function-trace; echo wakeup_rt > current_tracer; echo 1 > tracing_on; chrt -f 5 sleep 1; echo 0 > tracing_on
# cat trace
# tracer: wakeup_rt
#
# wakeup_rt latency trace v1.1.5 on 4.11.12-rt13
# --------------------------------------------------------------------
# latency: 786 us, #4/4, CPU#5 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:8)
# -----------------
# | task: irq/38-f72c0000-1321 (uid:0 nice:0 policy:1 rt_prio:50)
# -----------------
#
# _--------=> CPU#
# / _-------=> irqs-off
# | / _------=> need-resched
# || / _-----=> need-resched_lazy
# ||| / _----=> hardirq/softirq
# |||| / _---=> preempt-depth
# ||||| / _--=> preempt-lazy-depth
# |||||| / _-=> migrate-disable
# ||||||| / delay
# cmd pid |||||||| time | caller
#  / ||||||||  | /
<idle>-0 0d..h4.. 1us : 0:120:R + [005] 1321: 49:R irq/38-f72c0000
<idle>-0 0d..h4.. 3us!: try_to_wake_up <-wake_up_process
<idle>-0 5d...3.. 780us : __schedule <-schedule
<idle>-0 5d...3.. 784us : 0:120:R ==> [005] 1321: 49:R irq/38-f72c0000
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● CPU Capacity and System load
● Memory
● Devices
● Interrupt
● Schedule
● Firmware/BIOS routines
● Power management side effect
● SMP sync up
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● CPU Capacity and System load
○ 1 Ghz CPU freq required*
○ Busy system load
● Way to make real time friendly ENV
○ Isolated cpu
○ Dedicated resource for RT tasks
○ System tuning
■ Documentation/kernel-per-CPU-kthreads.txt
■ Taskset etc
■ isolcpus=
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● Memory
○ Page fault/reclaim cost a lots
○ Swap cause disk level response time
○ Fragment issue for larger memory allocation
● Workaround
○ Pre-allocate memory
○ Use slub for defragmentation
○ Reduce the page alloc locking region
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● Devices/interrupt
○ DMA may holding bus for long time
○ Interrupt:
■ time cost to trap into kernel and stay long
■ break the RT task;
■ Interrupt disable region -- irq_save
● solutions
○ threaded interrupt,
■ Prioritize
■ preemptable
○ Irq disable -> local spin lock.
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● Firmware/BIOS
○ Some device routine defined in firmware/bios
○ Secure system, Trust zone
● Power management cost
○ Cpu/clusters c-status, p-state -- use PM QoS or don’t use them
○ Thermal setting -- cooling system
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● Schedule cost
○ tlb/cache flush
○ Page table refill
○ System load
● Optimize
○ Priority tasks: FIFO, RR, deadline
○ Control normal task preempt
■ Preempt in spin_lock -- lazy preempt
○ Lazy mm replace
○ TLB/Cache flush range
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Reasons/Solutions of latencies
● SMP sync up
○ Spin_lock, rw_lock etc.
● Solution:
○ Sleepable/preemptable spin_lock/rwlock: rt_mutex
■ Migration disable
○ Rwlock: reader bias rwlock or use rcu instead.
ENGINEERS AND DEVICES
WORKING TOGETHER
Priority inversion
● Priority of RT task
○ Necessary to preempt normal task
● Priority inversion
○ Priority inherit
grab lock L1 (owned by C)
|
A ---+
C preempted by B
|
C +----+
B +-------->
B now keeps A from running.
E->L4->D->L3->C-+
+->L2-+
| |
G-+ +->B->L1->A
|
F->L5-+
ENGINEERS AND DEVICES
WORKING TOGETHER
Resource links
● RT tree
○ git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
● Real time wiki
○ https://wiki.linuxfoundation.org/realtime/start
○ https://rt.wiki.kernel.org/index.php/Main_Page
● RT mailing list
○ https://wiki.linuxfoundation.org/realtime/communication/mailinglists
● RT testing
○ https://git.linaro.org/power/rt-app.git
● IRC
○ #linux-rt on irc.oftc.net
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Summary
● RTL status
○ All upstream is on the way
● Kernel changes for latency
○ Sleepable spin_lock/rwlock
○ preemptable Irq_save
● Resources of RT
○ https://wiki.linuxfoundation.org/realtime/start
Thank You
Alex Shi <alex.shi@linaro.org>
#SFO17
BUD17 keynotes and videos on: connect.linaro.org
For further information: www.linaro.org

More Related Content

More from Linaro

Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteLinaro
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopLinaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allLinaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorLinaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMULinaro
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MLinaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootLinaro
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...Linaro
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramLinaro
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNLinaro
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...Linaro
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...Linaro
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionLinaro
 
HKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 ServersHKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 ServersLinaro
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightLinaro
 

More from Linaro (20)

Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready Program
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NN
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: Introduction
 
HKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 ServersHKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 Servers
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
 

Recently uploaded

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Understanding Real Time kernel - SFO17-207

  • 1. Understanding Real Time Linux Alex Shi
  • 2. ENGINEERS AND DEVICES WORKING TOGETHER Agenda ● What’s real time OS ● RTL project status ● RT testing and tracing ● Reasons of latency and solutions for them ● Resources ● Summary
  • 3. ENGINEERS AND DEVICES WORKING TOGETHER What’s real time OS ● Real time and high performance ○ Fastest? Max throughput? Average latency? ○ No, predictable latency! ● Types: ○ Hard real time ■ Car engine, Nuclear power plant ○ Firm real time ■ Between hard/soft ○ Soft real time ■ Live audio/video ● RTOS list link
  • 4. ENGINEERS AND DEVICES WORKING TOGETHER RTL project status ● RTL project ○ Linux Foundation plan to merge all RT code into upstream ○ Main team member of RT: Thomas Gleixner, Sebastian Siewior, Richard Cohran, Anna-Maria Gleixner, Benedikt Spranger ○ David Long, Mathieu Poirier and Alex also work on it. ● Much of code merged into upstream ○ High res timer ○ Threaded interrupt ○ Lock dep / Ftrace ● A few code out of kernel ○ 400+ patches, < 20,000 lines ○ Sleep locking ○ Interrupt preemptable -- transfer to local lock ○ Optimized for Cpu hotplug Timers; memory alloc; Softirq; Rcu
  • 5. ENGINEERS AND DEVICES WORKING TOGETHER RT testing and tracing ● Kernel setting ○ # CONFIG_PREEMPT_NONE ○ # CONFIG_PREEMPT_VOLUNTARY ○ # CONFIG_PREEMPT__LL ○ # CONFIG_PREEMPT_RTB ○ CONFIG_PREEMPT_RT_FULL=y ● Testing ○ Benchmarks: rt-tests, rt-app, ltp-realtime ○ ./cyclitest --smp -p98 -m ○ System stress: hackbench -l 10000 ○ Results on my hikey620 and dragonaboard 410 ■ Maximum latency less than 200 us in a busy system ● Tracing ○ Function trace ○ Latency trace
  • 6. ENGINEERS AND DEVICES WORKING TOGETHER Latency tracing # echo 0 > options/function-trace; echo wakeup_rt > current_tracer; echo 1 > tracing_on; chrt -f 5 sleep 1; echo 0 > tracing_on # cat trace # tracer: wakeup_rt # # wakeup_rt latency trace v1.1.5 on 4.11.12-rt13 # -------------------------------------------------------------------- # latency: 786 us, #4/4, CPU#5 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:8) # ----------------- # | task: irq/38-f72c0000-1321 (uid:0 nice:0 policy:1 rt_prio:50) # ----------------- # # _--------=> CPU# # / _-------=> irqs-off # | / _------=> need-resched # || / _-----=> need-resched_lazy # ||| / _----=> hardirq/softirq # |||| / _---=> preempt-depth # ||||| / _--=> preempt-lazy-depth # |||||| / _-=> migrate-disable # ||||||| / delay # cmd pid |||||||| time | caller # / |||||||| | / <idle>-0 0d..h4.. 1us : 0:120:R + [005] 1321: 49:R irq/38-f72c0000 <idle>-0 0d..h4.. 3us!: try_to_wake_up <-wake_up_process <idle>-0 5d...3.. 780us : __schedule <-schedule <idle>-0 5d...3.. 784us : 0:120:R ==> [005] 1321: 49:R irq/38-f72c0000
  • 7. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● CPU Capacity and System load ● Memory ● Devices ● Interrupt ● Schedule ● Firmware/BIOS routines ● Power management side effect ● SMP sync up
  • 8. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● CPU Capacity and System load ○ 1 Ghz CPU freq required* ○ Busy system load ● Way to make real time friendly ENV ○ Isolated cpu ○ Dedicated resource for RT tasks ○ System tuning ■ Documentation/kernel-per-CPU-kthreads.txt ■ Taskset etc ■ isolcpus=
  • 9. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● Memory ○ Page fault/reclaim cost a lots ○ Swap cause disk level response time ○ Fragment issue for larger memory allocation ● Workaround ○ Pre-allocate memory ○ Use slub for defragmentation ○ Reduce the page alloc locking region
  • 10. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● Devices/interrupt ○ DMA may holding bus for long time ○ Interrupt: ■ time cost to trap into kernel and stay long ■ break the RT task; ■ Interrupt disable region -- irq_save ● solutions ○ threaded interrupt, ■ Prioritize ■ preemptable ○ Irq disable -> local spin lock.
  • 11. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● Firmware/BIOS ○ Some device routine defined in firmware/bios ○ Secure system, Trust zone ● Power management cost ○ Cpu/clusters c-status, p-state -- use PM QoS or don’t use them ○ Thermal setting -- cooling system
  • 12. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● Schedule cost ○ tlb/cache flush ○ Page table refill ○ System load ● Optimize ○ Priority tasks: FIFO, RR, deadline ○ Control normal task preempt ■ Preempt in spin_lock -- lazy preempt ○ Lazy mm replace ○ TLB/Cache flush range
  • 13. ENGINEERS AND DEVICES WORKING TOGETHER Reasons/Solutions of latencies ● SMP sync up ○ Spin_lock, rw_lock etc. ● Solution: ○ Sleepable/preemptable spin_lock/rwlock: rt_mutex ■ Migration disable ○ Rwlock: reader bias rwlock or use rcu instead.
  • 14. ENGINEERS AND DEVICES WORKING TOGETHER Priority inversion ● Priority of RT task ○ Necessary to preempt normal task ● Priority inversion ○ Priority inherit grab lock L1 (owned by C) | A ---+ C preempted by B | C +----+ B +--------> B now keeps A from running. E->L4->D->L3->C-+ +->L2-+ | | G-+ +->B->L1->A | F->L5-+
  • 15. ENGINEERS AND DEVICES WORKING TOGETHER Resource links ● RT tree ○ git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git ● Real time wiki ○ https://wiki.linuxfoundation.org/realtime/start ○ https://rt.wiki.kernel.org/index.php/Main_Page ● RT mailing list ○ https://wiki.linuxfoundation.org/realtime/communication/mailinglists ● RT testing ○ https://git.linaro.org/power/rt-app.git ● IRC ○ #linux-rt on irc.oftc.net
  • 16. ENGINEERS AND DEVICES WORKING TOGETHER Summary ● RTL status ○ All upstream is on the way ● Kernel changes for latency ○ Sleepable spin_lock/rwlock ○ preemptable Irq_save ● Resources of RT ○ https://wiki.linuxfoundation.org/realtime/start
  • 17. Thank You Alex Shi <alex.shi@linaro.org> #SFO17 BUD17 keynotes and videos on: connect.linaro.org For further information: www.linaro.org