SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
Realtime Audio vs. Linux 2.6
                                              Lee Revell
                                            Mindpipe Audio
                                          305 S. 11th St. 2R
                                        Philadelphia, PA, 19107
                                                 USA,
                                         rlrevell@joe-job.com


Abstract                                                (and therefore good audio performance) with-
From the beginning of its development kernel 2.6        out custom patches, as kernel preemption was
promised latency as low as a patched 2.4 kernel.        available by default. However early 2.6 ker-
These claims proved to be premature when testing of     nels (2.6.0 through approximately 2.6.7) were
the 2.6.7 kernel showed it was much worse than 2.4. I   tested by the Linux audio development com-
present here a review of the most significant latency    munity and found to be a significant regres-
problems discovered and solved by the kernel devel-     sion from 2.4+ll. These concerns were com-
opers with the input of the Linux audio community       municated privately to kernel developer Ingo
between the beginning of this informal collaboration    Molnar and 2.6 kernel maintainer Andrew Mor-
in July 2004 around kernel 2.6.7 through the most re-
cent development release, 2.6.16-rc5. Most of these
                                                        ton; Molnar and Arjan van de Ven responded
solutions went into the mainline kernel directly or     in July 2004 with the ”Voluntary Kernel Pre-
via the -mm, voluntary-preempt, realtime-preempt,       emption patch” (Molnar, 2004). The name is
and -rt patch sets maintained by Ingo Molnar (Mol-      actually misleading - ’Voluntary’ only refers to
nar, 2004) and many others.                             the feature of turning might sleep() debugging
                                                        checks into scheduling points if preemption is
Keywords                                                disabled. The interesting features for realtime
Latency, Preemption, Kernel, 2.6, Realtime              audio users, who will always enable preemption,
                                                        are the additional rescheduling points with lock
1   Introduction                                        breaks that Molnar and van de Ven added wher-
                                                        ever they found a latency over 1ms.
In mid-2004 Paul Davis, and other Linux au-
dio developers found that the 2.6 kernel, despite       3   Latency debugging mechanisms
promises of low latency without custom patches,         The first requirement to beat Linux 2.6 into
was essentially unusable as an audio platform           shape as an audio platform was to develop a
due to large gaps in scheduling latency. They           mechanism to determine the source of an xrun.
responded with a letter to the kernel developers        Although kernel 2.6 claims to be fully pre-
which ignited intense interest among the kernel         emptible, there are many situations that pre-
developers (Molnar, 2004) in solving this prob-         vent preemption, such as holding a spinlock, the
lem. Massive progress was made, and recent 2.6          BKL, or explicitly calling preempt disable(), or
releases like 2.6.14 provide latency as good or         any code that executes in hard or soft interrupt
better than the proprietary alternatives. This          context (regardless of any locks held).
is a review of some of the problems encountered            The first method used was ALSA’s ”xrun de-
and how they were solved. . . .                         bug” feature, about the crudest imaginable la-
                                                        tency debugging tool, by which ALSA simply
2   Background                                          calls dump stack() when an xrun is detected, in
The main requirements for realtime audio on a           the hope that some clue to the kernel code path
general purpose PC operating system are appli-          responsible remains on the stack. This crude
cation support, driver support, and low schedul-        mechanism found many bugs, but an improved
ing latency. Linux audio began in earnest               method was quickly developed.
around 2000 when these three requirements                  In the early days of the voluntary preemp-
were met by (respectively) JACK, ALSA, and              tion patch, Molnar developed a latency trac-
the low latency patches for Linux 2.4 (”2.4+ll”).       ing mechanism. This causes the kernel to trace
The 2.6 kernel promised low scheduling latency          every function call, along with any operation


                                                LAC2006
                                                  21
that affects the ”preempt count”. The pre-           duration of the console switch to prevent dis-
empt count is how the kernel knows whether          play corruption. This problem which had been
preemption is allowed - it is incremented or        known since the 2.4 low latency patches was
decremented according to the rules above (tak-      also resolved with the introduction of the pre-
ing spinlock or BKL increments it, releasing        emptible BKL.
decrements, etc) and preemption is only allowed
when the count is zero. The kernel tracks the       6   Hardirq context
maximum latency (amount of time the preempt         Another issue discovered in the very early test-
count is nonzero) and if it exceeds the previous    ing of the voluntary preemption patches was ex-
value, saves the entire call stack from the time    cessive latency caused by large IO requests by
the preempt count became positive to when it        the ATA driver. It had previously been known
became negative to /proc/latency trace).            that with IDE IO completions being handled
   So rather than having to guess which kernel      in hard IRQ context and a maximum request
code path caused an xrun we receive an ex-          size of 32MB (depending on whether LBA48
act record of the code path. This mechanism         is in effect which in turn depends on the size
has persisted more or less unchanged from the       of the drive), scheduling latencies of many mil-
beginning of the voluntary preemption patches       liseconds occurred when processing IO in IRQ
(Molnar, 2004) to the present, and within a         context.
week of being ported to the mainline kernel            This was fixed by adding the sysfs tunables:
had identified at least one latency regression          /sys/block/hd*/queue/max sectors kb
(from 2.6.14 to 2.6.15, in the VM), and has            which can be used to limit the amount of IO
been used by the author to find another (in          processed in a single disk interrupt, eliminating
free swap cache()) in the past week. Dozens of      excessive scheduling latencies at a small price in
latency problems have been fixed with Molnar’s       disk throughput.
tracer (everything in this paper, unless other-        Another quite humorous hardirq latency bug
wise noted); it is the one of the most successful   occurred when toggling Caps, Scroll, or Num
kernel debugging tools ever.                        Lock - the PS/2 keyboard driver actually spun
                                                    in the interrupt handler polling for LED status
4   The BKL: ReiserFS 3                             (!). Needless to say this was quickly and quietly
One of the very first issues found was that Reis-    fixed.
erFS 3.x was not a good choice for low la-
tency systems. Exactly why was never really         7   Process context - VFS and VM
established, as the filesystem was in mainte-            issues
nance mode, so any problems were unlikely to        Several issues were found in the VFS and VM
be fixed. One possibility is that reiser3’s exten-   subsystems of the kernel, which are invoked
sive use of the BKL (big kernel lock - a coarse     quite frequently in process context, such as
grained lock which dates from the first SMP im-      when files are deleted or a process exits. These
plementations of Linux, where it was used to        often involve operations on large data struc-
provide quick and dirty locking for code with       tures that can run for long enough to cause
UP assumptions which otherwise would have to        audio dropouts and were most easily triggered
be rewritten for SMP). ReiserFS 3.x uses the        by heavy disk benchmarks (bonnie, iozone,
BKL for all write locking. The BKL at the           tiobench, dbench).
time disabled preemption, which is no longer           One typical VFS latency issue involved
the case, so the suitability of ReiserFS 3.x for    shrinking the kernel’s directory cache when a
low latency audio systems may be worth revisit-     directory with thousands of files was deleted;
ing. Hans Reiser claims that ReiserFS 4.x solves    a typical VM latency problem would cause au-
these problems.                                     dio dropouts at process exit when the kernel
                                                    unmapped all of that processes virtual mem-
5   The BKL: Virtual console                        ory areas with preemption disabled. The sync()
    switching                                       syscall also caused xruns if large amounts of
One of the oldest known latency issues involved     dirty data was flushed.
virtual console (VC) switching (as with Alt-Fn),       One significant process-context latency bug
as like ReiserFS 3.x this process relies on the     was discovered quite accidentally, when the au-
BKL for locking which must be held for the          thor was developing an ALSA driver that re-


                                            LAC2006
                                              22
quired running separate JACK instances for          quires limiting the amount of time spent in
playback and capture. A large xrun would be         softirq context. Softirqs are used heavily by the
induced in the running JACK process when an-        networking system, for example looping over a
other was started. The problem was identified        list of packets delivered by the network adapter,
as mlockall() calling into make pages present()     as well as SCSI and for kernel timers (Love,
which in turn called get user pages() causing       2003). Fortunately the Linux networking stack
the entire address space to be faulted in with      provides numerous sysctls that can be tuned to
preemption disabled.                                limit the number of packets processed at once,
  Process-context latency problems were fortu-      and the block IO fixes described elsewhere for
nately the easiest to solve, by the addition of a   IDE also apply to SCSI, which does IO comple-
reschedule with lock break within the problem-      tion in softirq context.
atic loop.                                             Softirqs are the main source of excessive
                                                    scheduling latencies that, while rare, can still
8   Process context - ext3fs                        occur in the latest 2.6 kernel as of this writ-
While ReiserFS 3.x did not get any latency          ing (2.6.16-rc5). Timer based route cache flush-
fixes as it was in maintenance mode, EXT3FS          ing can still produce latencies over 10ms, and
did require several changes to achieve accept-      is the most problematic remaining softirq as no
able scheduling latencies. At least three latency   workaround seems to be available; however the
problems in the EXT3 journalling code (a mech-      problem is known by the kernel developers and
anism for preserving file system integrity in the    a solution has been proposed (Dumazet, 2006).
event of power loss without lengthy file sys-
tem checks at reboot) and one in the reserva-       10   Performance issues
tion code (a mechanism by which the filesystem       The problems described so far mostly fit the
speeds allocation by preallocating space in an-     pattern of too much work being done at once in
ticipation that a file will grow) were fixed by the   some non-preemptible context and were solved
maintainers.                                        by doing the same work in smaller units. How-
                                                    ever several areas where the kernel was simply
9   Softirq context - the struggle                  inefficient were resolved, to the benefit of all
    continues                                       users.
Having covered process and hardirq contexts we        One such problem was kallsyms lookup(), in-
come to the stickiest problem - softirqs (aka       voked in cases like printk(), which did a lin-
”Bottom Halves”, known as ”DPCs” in the             ear search over thousands of symbols, caus-
Windows world - all the work needed to han-         ing excessive scheduling latency. Paulo Mar-
dle an interrupt that can be delayed from the       ques solved this problem by rewriting kall-
hardirq, and run later, on another processor,       syms lookup() to use a more efficient search al-
with interrupts enabled, etc). Full discussion of   gorithm. The frequent invocation of SHATrans-
softirqs is outside the scope (see (Love, 2003))    form() in non-preemptible contexts to add to
of this paper but an important feature of the       the entropy pool was another latency problem
Linux implementation is that while softirqs nor-    solved by rewriting the code to be more efficient.
mally run immediately after the hardirq that en-
abled them on the same processor in interrupt       11   Non-kernel factors
context, under load, all softirq handling can be    The strangest latency problem identified was
offloaded to a ”softirqd” thread, for scalability     found to have an origin completely outside the
reasons.                                            kernel. Testing revealed that moving windows
  An important side effect is that the kernel        on the desktop reliably caused JACK to report
can be trivially modified to unconditionally run     excessive delays. This is a worse situation than
softirqs in process context, which results in a     an xrun as it indicates the audio device stopped
dramatic improvement in latency if the audio        producing/consuming data or a hardware level
system runs at a higher priority than the softirq   timing glitch occurred, while an xrun merely
thread(s). This is the approach taken by the -rt    indicates that audio was available but JACK
kernel, and by many independent patches that        was not scheduled in time to process it. The
preceded it.                                        problem disappeared when 2D acceleration was
  The mainline Linux kernel lacks this feature,     disabled in the X configuration which pointed
however, so minimizing scheduling latency re-       clearly to the X display driver - on Linux all


                                            LAC2006
                                              23
hardware access is normally mitigated by the          soft realtime applications, like IRQ threading,
kernel except 2D XAA acceleration by the X            was pioneered by Solaris engineers in the early
server.                                               1990s (Vahalia, 1996).
   The VIA Unichrome video card used in test-
ing has a command FIFO and a status register.         14   Acknowledgements
The status register tells the X server when the       My thanks go to Ingo Molnar, Paul Davis, An-
FIFO is ready to accept more data. (Jones and         drew Morton, Linus Torvalds, Florian Schmidt,
Regehr, 1999) describes certain Windows video         and everyone who helped to evolve Linux 2.6
drivers which improve benchmark scores by ne-         into a world class realtime audio platform.
glecting to check the status register before writ-
ing to the FIFO; the effect is to stall the CPU if     References
the FIFO was full. The symptoms experienced           Jonathan Corbet.       2004.     Another look
were identical to (Jones and Regehr, 1999) - the        at     the   new      development      model.
machine stalled when the user dragged a win-            https://lwn.net/Articles/95312/.
dow. Communication with the maintainer of             Eric Dumazet.       2006.      Re:    Rcu la-
the VIA unichrome driver (which had been sup-           tency      regression       in     2.6.16-rc1.
plied by the vendor) confirmed that the driver           http://lkml.org/lkml/2006/1/28/111.
was in fact failing to check the status register      Michael B. Jones and John Regehr. 1999. The
and was easily fixed.                                    problems you’re having may not be the prob-
                                                        lems you think you’re having: Results from a
12    The -rt kernel and the future                     latency study of windows nt. In Proceedings
The above solutions all have in common that             of the 7th Workshop on Hot Topics in Oper-
they reduce scheduling latencies by minimiz-            ating Systems (HotOS VII), pages 96–101.
ing the time the kernel spends with a spin-           Robert Love. 2003. Linux Kernel Development.
lock held, with preemption manually disabled,           Sams Publishing, Indianapolis, Indiana.
and in hard and soft IRQ contexts, but do not         Ingo Molnar.      2004.     [announce] [patch]
change the kernels behavior regarding which             voluntary    kernel     preemption      patch.
contexts are preemptible. Modulo a few re-              http://lkml.org/lkml/2004/7/9/138.
maining, known bugs, this approach is capable         Uresh Vahalia. 1996. Unix Internals: The New
of reducing the worst case scheduling latencies         Frontiers. Prentice Hall, Upper Saddle River,
to the 1-2ms range, which is adequate for au-           New Jersey.
dio applications. Reducing latencies further re-
quired deep changes to the kernel and the rules
about when preemption is allowed. The -rt ker-
nel eliminates the spinlock problem by turning
them into mutexes, the softirq by the softirq
method previously described, and the hardirq
issue by creating a set of kernel threads, one per
interrupt line, and running all interrupt han-
dlers in these threads. These changes result in
a worst case scheduling latency close to 50 mi-
croseconds which approaches hardware limits.

13    Conclusions
One of the significant implications of the story
of low latency in kernel 2.6 is that I believe it
vindicates the controversial ”new kernel devel-
opment process” (Corbet, 2004) - it is hard to
imagine Linux 2.6 evolving into a world class au-
dio platform as rapidly and successfully as it did
under a development model that valued stabil-
ity over progress. Another lesson is that in op-
erating systems as in life, history repeats itself.
Much of the work done on Linux 2.6 to support


                                              LAC2006
                                                24

Contenu connexe

Tendances

Project of deamon process
Project of deamon processProject of deamon process
Project of deamon processAbubakr Cheema
 
Linux Kernel Library - Reusing Monolithic Kernel
Linux Kernel Library - Reusing Monolithic KernelLinux Kernel Library - Reusing Monolithic Kernel
Linux Kernel Library - Reusing Monolithic KernelHajime Tazaki
 
Kernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesKernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesAnne Nicolas
 
Linux Instrumentation
Linux InstrumentationLinux Instrumentation
Linux InstrumentationDarkStarSword
 
EBPF and Linux Networking
EBPF and Linux NetworkingEBPF and Linux Networking
EBPF and Linux NetworkingPLUMgrid
 
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...peknap
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 
Linux Preempt-RT Internals
Linux Preempt-RT InternalsLinux Preempt-RT Internals
Linux Preempt-RT Internals哲豪 康哲豪
 
OCP Engineering Workshop at UNH
OCP Engineering Workshop at UNH OCP Engineering Workshop at UNH
OCP Engineering Workshop at UNH 호용 류
 
Kdump-FUDcon-2015-Session
Kdump-FUDcon-2015-SessionKdump-FUDcon-2015-Session
Kdump-FUDcon-2015-SessionBuland Singh
 
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaum
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. TanenbaumA Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaum
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaumeurobsdcon
 
Advanced Components on Top of L4Re
Advanced Components on Top of L4ReAdvanced Components on Top of L4Re
Advanced Components on Top of L4ReVasily Sartakov
 
Packet Framework - Cristian Dumitrescu
Packet Framework - Cristian DumitrescuPacket Framework - Cristian Dumitrescu
Packet Framework - Cristian Dumitrescuharryvanhaaren
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practiceschristophm
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack eurobsdcon
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDKKernel TLV
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPThomas Graf
 

Tendances (20)

Project of deamon process
Project of deamon processProject of deamon process
Project of deamon process
 
Linux Kernel Library - Reusing Monolithic Kernel
Linux Kernel Library - Reusing Monolithic KernelLinux Kernel Library - Reusing Monolithic Kernel
Linux Kernel Library - Reusing Monolithic Kernel
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Kernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesKernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologies
 
Linux Instrumentation
Linux InstrumentationLinux Instrumentation
Linux Instrumentation
 
EBPF and Linux Networking
EBPF and Linux NetworkingEBPF and Linux Networking
EBPF and Linux Networking
 
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...
Solving Real-Time Scheduling Problems With RT_PREEMPT and Deadline-Based Sche...
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Linux Preempt-RT Internals
Linux Preempt-RT InternalsLinux Preempt-RT Internals
Linux Preempt-RT Internals
 
OCP Engineering Workshop at UNH
OCP Engineering Workshop at UNH OCP Engineering Workshop at UNH
OCP Engineering Workshop at UNH
 
Kdump-FUDcon-2015-Session
Kdump-FUDcon-2015-SessionKdump-FUDcon-2015-Session
Kdump-FUDcon-2015-Session
 
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaum
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. TanenbaumA Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaum
A Reimplementation of NetBSD Based on a Microkernel by Andrew S. Tanenbaum
 
Advanced Components on Top of L4Re
Advanced Components on Top of L4ReAdvanced Components on Top of L4Re
Advanced Components on Top of L4Re
 
Packet Framework - Cristian Dumitrescu
Packet Framework - Cristian DumitrescuPacket Framework - Cristian Dumitrescu
Packet Framework - Cristian Dumitrescu
 
Memory, IPC and L4Re
Memory, IPC and L4ReMemory, IPC and L4Re
Memory, IPC and L4Re
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
Userspace networking
Userspace networkingUserspace networking
Userspace networking
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
 

En vedette

Rose Power Point
Rose Power PointRose Power Point
Rose Power PointProse91688
 
Electronic essay swg 3 version 4
Electronic essay swg 3 version 4Electronic essay swg 3 version 4
Electronic essay swg 3 version 4kevinkelly61
 
Bo modules april 2008 sioo
Bo modules april 2008 siooBo modules april 2008 sioo
Bo modules april 2008 siooGeert Buzeman
 
Electronic essay swg 3 version 42
Electronic essay swg 3 version 42Electronic essay swg 3 version 42
Electronic essay swg 3 version 42kevinkelly61
 
Lac2006 Lee Revell Slides
Lac2006 Lee Revell SlidesLac2006 Lee Revell Slides
Lac2006 Lee Revell Slidesrlrevell
 
Electronic essay swg 3 version 44
Electronic essay swg 3 version 44Electronic essay swg 3 version 44
Electronic essay swg 3 version 44kevinkelly61
 

En vedette (10)

Haley Slide
Haley SlideHaley Slide
Haley Slide
 
Haley slide
Haley slideHaley slide
Haley slide
 
Normas t568 a y b
Normas t568 a y bNormas t568 a y b
Normas t568 a y b
 
Rose Power Point
Rose Power PointRose Power Point
Rose Power Point
 
Electronic essay swg 3 version 4
Electronic essay swg 3 version 4Electronic essay swg 3 version 4
Electronic essay swg 3 version 4
 
Haley slide
Haley slideHaley slide
Haley slide
 
Bo modules april 2008 sioo
Bo modules april 2008 siooBo modules april 2008 sioo
Bo modules april 2008 sioo
 
Electronic essay swg 3 version 42
Electronic essay swg 3 version 42Electronic essay swg 3 version 42
Electronic essay swg 3 version 42
 
Lac2006 Lee Revell Slides
Lac2006 Lee Revell SlidesLac2006 Lee Revell Slides
Lac2006 Lee Revell Slides
 
Electronic essay swg 3 version 44
Electronic essay swg 3 version 44Electronic essay swg 3 version 44
Electronic essay swg 3 version 44
 

Similaire à Lac2006 Lee Revell

Similaire à Lac2006 Lee Revell (20)

Futex ppt
Futex  pptFutex  ppt
Futex ppt
 
Linux Kernel Release 2.6
Linux Kernel Release 2.6Linux Kernel Release 2.6
Linux Kernel Release 2.6
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment ppt
 
CRIU: are we there yet?
CRIU: are we there yet?CRIU: are we there yet?
CRIU: are we there yet?
 
Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2
 
Microkernels and Beyond
Microkernels and BeyondMicrokernels and Beyond
Microkernels and Beyond
 
Again music
Again musicAgain music
Again music
 
Ubuntu
UbuntuUbuntu
Ubuntu
 
MIcrokernel
MIcrokernelMIcrokernel
MIcrokernel
 
Recompile
RecompileRecompile
Recompile
 
UNIX Operating System ppt
UNIX Operating System pptUNIX Operating System ppt
UNIX Operating System ppt
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
 
Libra Library OS
Libra Library OSLibra Library OS
Libra Library OS
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
network filesystem briefs
network filesystem briefsnetwork filesystem briefs
network filesystem briefs
 
os
osos
os
 
06threadsimp
06threadsimp06threadsimp
06threadsimp
 
How VXLAN works on Linux
How VXLAN works on LinuxHow VXLAN works on Linux
How VXLAN works on Linux
 

Dernier

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Dernier (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Lac2006 Lee Revell

  • 1. Realtime Audio vs. Linux 2.6 Lee Revell Mindpipe Audio 305 S. 11th St. 2R Philadelphia, PA, 19107 USA, rlrevell@joe-job.com Abstract (and therefore good audio performance) with- From the beginning of its development kernel 2.6 out custom patches, as kernel preemption was promised latency as low as a patched 2.4 kernel. available by default. However early 2.6 ker- These claims proved to be premature when testing of nels (2.6.0 through approximately 2.6.7) were the 2.6.7 kernel showed it was much worse than 2.4. I tested by the Linux audio development com- present here a review of the most significant latency munity and found to be a significant regres- problems discovered and solved by the kernel devel- sion from 2.4+ll. These concerns were com- opers with the input of the Linux audio community municated privately to kernel developer Ingo between the beginning of this informal collaboration Molnar and 2.6 kernel maintainer Andrew Mor- in July 2004 around kernel 2.6.7 through the most re- cent development release, 2.6.16-rc5. Most of these ton; Molnar and Arjan van de Ven responded solutions went into the mainline kernel directly or in July 2004 with the ”Voluntary Kernel Pre- via the -mm, voluntary-preempt, realtime-preempt, emption patch” (Molnar, 2004). The name is and -rt patch sets maintained by Ingo Molnar (Mol- actually misleading - ’Voluntary’ only refers to nar, 2004) and many others. the feature of turning might sleep() debugging checks into scheduling points if preemption is Keywords disabled. The interesting features for realtime Latency, Preemption, Kernel, 2.6, Realtime audio users, who will always enable preemption, are the additional rescheduling points with lock 1 Introduction breaks that Molnar and van de Ven added wher- ever they found a latency over 1ms. In mid-2004 Paul Davis, and other Linux au- dio developers found that the 2.6 kernel, despite 3 Latency debugging mechanisms promises of low latency without custom patches, The first requirement to beat Linux 2.6 into was essentially unusable as an audio platform shape as an audio platform was to develop a due to large gaps in scheduling latency. They mechanism to determine the source of an xrun. responded with a letter to the kernel developers Although kernel 2.6 claims to be fully pre- which ignited intense interest among the kernel emptible, there are many situations that pre- developers (Molnar, 2004) in solving this prob- vent preemption, such as holding a spinlock, the lem. Massive progress was made, and recent 2.6 BKL, or explicitly calling preempt disable(), or releases like 2.6.14 provide latency as good or any code that executes in hard or soft interrupt better than the proprietary alternatives. This context (regardless of any locks held). is a review of some of the problems encountered The first method used was ALSA’s ”xrun de- and how they were solved. . . . bug” feature, about the crudest imaginable la- tency debugging tool, by which ALSA simply 2 Background calls dump stack() when an xrun is detected, in The main requirements for realtime audio on a the hope that some clue to the kernel code path general purpose PC operating system are appli- responsible remains on the stack. This crude cation support, driver support, and low schedul- mechanism found many bugs, but an improved ing latency. Linux audio began in earnest method was quickly developed. around 2000 when these three requirements In the early days of the voluntary preemp- were met by (respectively) JACK, ALSA, and tion patch, Molnar developed a latency trac- the low latency patches for Linux 2.4 (”2.4+ll”). ing mechanism. This causes the kernel to trace The 2.6 kernel promised low scheduling latency every function call, along with any operation LAC2006 21
  • 2. that affects the ”preempt count”. The pre- duration of the console switch to prevent dis- empt count is how the kernel knows whether play corruption. This problem which had been preemption is allowed - it is incremented or known since the 2.4 low latency patches was decremented according to the rules above (tak- also resolved with the introduction of the pre- ing spinlock or BKL increments it, releasing emptible BKL. decrements, etc) and preemption is only allowed when the count is zero. The kernel tracks the 6 Hardirq context maximum latency (amount of time the preempt Another issue discovered in the very early test- count is nonzero) and if it exceeds the previous ing of the voluntary preemption patches was ex- value, saves the entire call stack from the time cessive latency caused by large IO requests by the preempt count became positive to when it the ATA driver. It had previously been known became negative to /proc/latency trace). that with IDE IO completions being handled So rather than having to guess which kernel in hard IRQ context and a maximum request code path caused an xrun we receive an ex- size of 32MB (depending on whether LBA48 act record of the code path. This mechanism is in effect which in turn depends on the size has persisted more or less unchanged from the of the drive), scheduling latencies of many mil- beginning of the voluntary preemption patches liseconds occurred when processing IO in IRQ (Molnar, 2004) to the present, and within a context. week of being ported to the mainline kernel This was fixed by adding the sysfs tunables: had identified at least one latency regression /sys/block/hd*/queue/max sectors kb (from 2.6.14 to 2.6.15, in the VM), and has which can be used to limit the amount of IO been used by the author to find another (in processed in a single disk interrupt, eliminating free swap cache()) in the past week. Dozens of excessive scheduling latencies at a small price in latency problems have been fixed with Molnar’s disk throughput. tracer (everything in this paper, unless other- Another quite humorous hardirq latency bug wise noted); it is the one of the most successful occurred when toggling Caps, Scroll, or Num kernel debugging tools ever. Lock - the PS/2 keyboard driver actually spun in the interrupt handler polling for LED status 4 The BKL: ReiserFS 3 (!). Needless to say this was quickly and quietly One of the very first issues found was that Reis- fixed. erFS 3.x was not a good choice for low la- tency systems. Exactly why was never really 7 Process context - VFS and VM established, as the filesystem was in mainte- issues nance mode, so any problems were unlikely to Several issues were found in the VFS and VM be fixed. One possibility is that reiser3’s exten- subsystems of the kernel, which are invoked sive use of the BKL (big kernel lock - a coarse quite frequently in process context, such as grained lock which dates from the first SMP im- when files are deleted or a process exits. These plementations of Linux, where it was used to often involve operations on large data struc- provide quick and dirty locking for code with tures that can run for long enough to cause UP assumptions which otherwise would have to audio dropouts and were most easily triggered be rewritten for SMP). ReiserFS 3.x uses the by heavy disk benchmarks (bonnie, iozone, BKL for all write locking. The BKL at the tiobench, dbench). time disabled preemption, which is no longer One typical VFS latency issue involved the case, so the suitability of ReiserFS 3.x for shrinking the kernel’s directory cache when a low latency audio systems may be worth revisit- directory with thousands of files was deleted; ing. Hans Reiser claims that ReiserFS 4.x solves a typical VM latency problem would cause au- these problems. dio dropouts at process exit when the kernel unmapped all of that processes virtual mem- 5 The BKL: Virtual console ory areas with preemption disabled. The sync() switching syscall also caused xruns if large amounts of One of the oldest known latency issues involved dirty data was flushed. virtual console (VC) switching (as with Alt-Fn), One significant process-context latency bug as like ReiserFS 3.x this process relies on the was discovered quite accidentally, when the au- BKL for locking which must be held for the thor was developing an ALSA driver that re- LAC2006 22
  • 3. quired running separate JACK instances for quires limiting the amount of time spent in playback and capture. A large xrun would be softirq context. Softirqs are used heavily by the induced in the running JACK process when an- networking system, for example looping over a other was started. The problem was identified list of packets delivered by the network adapter, as mlockall() calling into make pages present() as well as SCSI and for kernel timers (Love, which in turn called get user pages() causing 2003). Fortunately the Linux networking stack the entire address space to be faulted in with provides numerous sysctls that can be tuned to preemption disabled. limit the number of packets processed at once, Process-context latency problems were fortu- and the block IO fixes described elsewhere for nately the easiest to solve, by the addition of a IDE also apply to SCSI, which does IO comple- reschedule with lock break within the problem- tion in softirq context. atic loop. Softirqs are the main source of excessive scheduling latencies that, while rare, can still 8 Process context - ext3fs occur in the latest 2.6 kernel as of this writ- While ReiserFS 3.x did not get any latency ing (2.6.16-rc5). Timer based route cache flush- fixes as it was in maintenance mode, EXT3FS ing can still produce latencies over 10ms, and did require several changes to achieve accept- is the most problematic remaining softirq as no able scheduling latencies. At least three latency workaround seems to be available; however the problems in the EXT3 journalling code (a mech- problem is known by the kernel developers and anism for preserving file system integrity in the a solution has been proposed (Dumazet, 2006). event of power loss without lengthy file sys- tem checks at reboot) and one in the reserva- 10 Performance issues tion code (a mechanism by which the filesystem The problems described so far mostly fit the speeds allocation by preallocating space in an- pattern of too much work being done at once in ticipation that a file will grow) were fixed by the some non-preemptible context and were solved maintainers. by doing the same work in smaller units. How- ever several areas where the kernel was simply 9 Softirq context - the struggle inefficient were resolved, to the benefit of all continues users. Having covered process and hardirq contexts we One such problem was kallsyms lookup(), in- come to the stickiest problem - softirqs (aka voked in cases like printk(), which did a lin- ”Bottom Halves”, known as ”DPCs” in the ear search over thousands of symbols, caus- Windows world - all the work needed to han- ing excessive scheduling latency. Paulo Mar- dle an interrupt that can be delayed from the ques solved this problem by rewriting kall- hardirq, and run later, on another processor, syms lookup() to use a more efficient search al- with interrupts enabled, etc). Full discussion of gorithm. The frequent invocation of SHATrans- softirqs is outside the scope (see (Love, 2003)) form() in non-preemptible contexts to add to of this paper but an important feature of the the entropy pool was another latency problem Linux implementation is that while softirqs nor- solved by rewriting the code to be more efficient. mally run immediately after the hardirq that en- abled them on the same processor in interrupt 11 Non-kernel factors context, under load, all softirq handling can be The strangest latency problem identified was offloaded to a ”softirqd” thread, for scalability found to have an origin completely outside the reasons. kernel. Testing revealed that moving windows An important side effect is that the kernel on the desktop reliably caused JACK to report can be trivially modified to unconditionally run excessive delays. This is a worse situation than softirqs in process context, which results in a an xrun as it indicates the audio device stopped dramatic improvement in latency if the audio producing/consuming data or a hardware level system runs at a higher priority than the softirq timing glitch occurred, while an xrun merely thread(s). This is the approach taken by the -rt indicates that audio was available but JACK kernel, and by many independent patches that was not scheduled in time to process it. The preceded it. problem disappeared when 2D acceleration was The mainline Linux kernel lacks this feature, disabled in the X configuration which pointed however, so minimizing scheduling latency re- clearly to the X display driver - on Linux all LAC2006 23
  • 4. hardware access is normally mitigated by the soft realtime applications, like IRQ threading, kernel except 2D XAA acceleration by the X was pioneered by Solaris engineers in the early server. 1990s (Vahalia, 1996). The VIA Unichrome video card used in test- ing has a command FIFO and a status register. 14 Acknowledgements The status register tells the X server when the My thanks go to Ingo Molnar, Paul Davis, An- FIFO is ready to accept more data. (Jones and drew Morton, Linus Torvalds, Florian Schmidt, Regehr, 1999) describes certain Windows video and everyone who helped to evolve Linux 2.6 drivers which improve benchmark scores by ne- into a world class realtime audio platform. glecting to check the status register before writ- ing to the FIFO; the effect is to stall the CPU if References the FIFO was full. The symptoms experienced Jonathan Corbet. 2004. Another look were identical to (Jones and Regehr, 1999) - the at the new development model. machine stalled when the user dragged a win- https://lwn.net/Articles/95312/. dow. Communication with the maintainer of Eric Dumazet. 2006. Re: Rcu la- the VIA unichrome driver (which had been sup- tency regression in 2.6.16-rc1. plied by the vendor) confirmed that the driver http://lkml.org/lkml/2006/1/28/111. was in fact failing to check the status register Michael B. Jones and John Regehr. 1999. The and was easily fixed. problems you’re having may not be the prob- lems you think you’re having: Results from a 12 The -rt kernel and the future latency study of windows nt. In Proceedings The above solutions all have in common that of the 7th Workshop on Hot Topics in Oper- they reduce scheduling latencies by minimiz- ating Systems (HotOS VII), pages 96–101. ing the time the kernel spends with a spin- Robert Love. 2003. Linux Kernel Development. lock held, with preemption manually disabled, Sams Publishing, Indianapolis, Indiana. and in hard and soft IRQ contexts, but do not Ingo Molnar. 2004. [announce] [patch] change the kernels behavior regarding which voluntary kernel preemption patch. contexts are preemptible. Modulo a few re- http://lkml.org/lkml/2004/7/9/138. maining, known bugs, this approach is capable Uresh Vahalia. 1996. Unix Internals: The New of reducing the worst case scheduling latencies Frontiers. Prentice Hall, Upper Saddle River, to the 1-2ms range, which is adequate for au- New Jersey. dio applications. Reducing latencies further re- quired deep changes to the kernel and the rules about when preemption is allowed. The -rt ker- nel eliminates the spinlock problem by turning them into mutexes, the softirq by the softirq method previously described, and the hardirq issue by creating a set of kernel threads, one per interrupt line, and running all interrupt han- dlers in these threads. These changes result in a worst case scheduling latency close to 50 mi- croseconds which approaches hardware limits. 13 Conclusions One of the significant implications of the story of low latency in kernel 2.6 is that I believe it vindicates the controversial ”new kernel devel- opment process” (Corbet, 2004) - it is hard to imagine Linux 2.6 evolving into a world class au- dio platform as rapidly and successfully as it did under a development model that valued stabil- ity over progress. Another lesson is that in op- erating systems as in life, history repeats itself. Much of the work done on Linux 2.6 to support LAC2006 24