Overview of Linux realtime challengesJune 1, 2013
Daniel StenbergEmail: firstname.lastname@example.orgTwitter: @bagderWeb: daniel.haxx.seBlog: daniel.haxx.se/blog●Free Software●Network hacker●Embedded developer●Consultant
AgendaWhats real-time in this context?Why is real-time still a concern?Ways to deal with the problem• Off to secondary hardware• Hypervisor or AMP• PREEMPT_RT• CPU isolation and dynamic tickFuture?
RealtimeReal-time can mean a lot of differentthings to different audiences• Low maximum latency: below 100 us,sometimes down to 20us• Very low risk of every breaking that
Why is this a concern 2013?• Plain Linux wasnt designed to deal with low latency• A move towards "commodity" hardware - lessspecial stuff means solving the problems in generalCPUs• Linux everywhere: RTOS-solutions get moved overfrom legacy systems to Linux-based• Still a lot of stacks and applications that act in CPUbut needs to respond fast and accurately• Sometimes a bit more requested than perhaps canbe technically motivated
What are the options?Linux is a given.What magic can you apply to a systemto address the problem of a lowmaximum latency?
Separate dedicated HW• A tested and proven way• A separate small chip (with anRTOS?) for just the time critical stuff• ... or an FPGA• But it adds system complexity andprice
Hypervisor with RTOS• Isnt pure Linux• Adds complexity• Usually proprietary• May reach really low latenciesOne or more cores
AMP with RTOS• Isnt pure Linux• Adds complexity• Often proprietary• May reach really low latenciesCore 0 Core 1 Core 2 Core 3
The more pure Linux solutions1 Address and lower the worst case2 Avoid hitting the worst case
PREEMPT_RT●An offmainline patch since 10+ years!●Add preemption to lower max latency●replace kernel spinlocks with mutexes●move interrupts and software interrupts to kernel threads●works on single core systems●Changes behavior and requires drivers to be tested●Userspace is the same
CPU isolation 1/2●NOHZ, dynamic tick●Isolated cores == without ticks do nothing!●Only one thread allowed!●Avoiding the kernel is hard●Approaching mainline (3.10)●Requires rethinking userspace