why did Ubuntu turn off kernel preemption in Edgy?

Karoliina Salminen karoliina.t.salminen at gmail.com
Tue Nov 28 10:01:05 GMT 2006


Hi again,

Now I am writing this from a laptop instead of using the Nokia 770
virtual keyboard, so I can elaborate a bit more:

Why low latency is needed
---------------------------------------
* It is mainly needed for being able to play software synthesizers in real time
* In audio recording it can be potentially compensated

What low latency means in audio use
------------------------------------------------------
* Latency in audio use means the length of the audio ring buffer, so
it is not really the latency by technical means. It doesn't mean the
minimum achievable latency but the maximum length required the
computer can go into any time during the playback with the software
synthesizer (and simultaneously having several other music
applications running at the same time, some recording, some playing
back stuff, some midi, some audio, all synchronized with each other).
If the ring buffer length is too short, then crackle occurs in the
playback and it can be just a short break a length of a millisecond or
so at some time in the middle of recording that occurs only once
during the recording session. However, no matter if it happens 10
times per second or once per 5 minutes, it ruins the recording and the
take has to be started all over again.

Observed functionality in Open Suse 10.1/Jacklab Linux distribution
with different kernels
--------------------------------------------------------------------------------------------------------
STOCK KERNEL:
Jacklab with stock Suse kernel achieves somewhere around 100 ms long
audio ring buffer without having buffer overruns when playing the
ZynAddSubFx software synthesizer with external midi keyboard. No other
software running than qjackctl, jackd and ZynAddSubFx
http://zynaddsubfx.sourceforge.net/
100 ms is not acceptable because notes are usually a lot shorter than
that and it is not possible to play if the music comes several notes
behind what you are playing. The ear-finger interaction don't work and
brains get confused and the playing gets so distracted that it is
easier to play without hearing anything than hearing the notes coming
several notes/bars behind.
REAL TIME KERNEL:
The required 100% reliable length for the audio ring buffer drops to
around 20 ms with the real time kernel. This is playable in my use
with non-accurate timings in ambient style music. If I was playing
some percussion instruments with high tempo, this would still be
unacceptable. This is potentially a driver issue that it is not
getting better than 20 ms. However, the drop from 100ms to 20 ms is
certainly a kernel issue. For my use, however getting even to this
level in Ubuntu would be great.

The same hardware ST-audio C-port professional audio interface in
exactly the same computer hardware in exactly the same configuration
(I mean the same configuration because this card only gets low latency
in only one of the available PCI slots) is getting happily in Windows
2 ms long ring buffer at 24 bit / 96 kHz. This occurs with special low
latency kernel streaming drivers and it bypasses all ordinary windows
audio and only works with ASIO/WDM and only in the audiosequencer
which also functions as a VST host for the software synthesizers.
However, because I am not using Windows anylonger, this is not an
option to use.

Copy-paste from jack FAQ:
---------------------------------------
http://jackaudio.org/faq
How should I configure my Linux 2.6 Operating System?
Real-time scheduling

JACK requires real-time scheduling privileges for reliable,
dropout-free operation. The server requests these privileges when
running with the -R option. Unmodified 2.6 kernels work much better,
but still require special configuration.

The simplest, and least-secure way to provide real-time privileges is
running jackd as root. This has the disadvantage of also requiring all
of JACK clients to run as root. Real-time scheduling is inherently
dangerous; a badly or maliciously coded application can hang the
system. Worse, running as root gives an intruder too many
opportunities to damage or co-opt the entire system by attacking the
JACK server or its clients. Systems connected to the Internet would be
well-advised to avoid this approach. There are safer ways to gain the
needed privileges, the exact method depends on which Operating System
you run.

For Linux 2.6, the Realtime Linux Security Module provides a
relatively easy way for non-root users to gain real-time privileges.
Some audio-oriented distributions include this module as a separate
binary package or with the kernel image. Otherwise, you will need to
download the realtime-lsm source and build it yourself.

This loadable kernel extension selectively grants real-time privileges
to user programs. If loaded with modprobe realtime gid=29, it will
permit real-time operation for all members of group 29 (the Debian
"audio" group). It provides several additional options, described in
the user documentation.

This is copy paste from AGNULA/DEMUDI FAQ:
----------------------------------------------------------------------
AGNULA's Linux kernel has been optimized for low-latency. The patches
that have been applied can dramatically reduce latency in multimedia
systems to well within professionally acceptable ranges, demonstrating
another powerful aspect of the GNU/Linux system. In addition to the
low-latency patches we have applied the preemptive kernel patch to
ensure low-latency over extended periods of time (e.g., more than 24
hours continuous performance). The realtime clock driver has been
compiled into the kernel to provide high-accuracy timing for RTC-aware
applications. Finally, kernel support for optimized hard-disk usage
has been enabled and the hdparm utility is invoked during system
start-up to ensure peak disk I/O.
http://www.agnula.org/documentation/dp_tutorials/introduction/introduction-agnula.html/view?searchterm=kernel

So please don't say that I have something wrong with my hardware
settings since it doesn't lead to anywhere since this is a real issue
that is well known and that has real solutions that are in use
elsewhere.

Best Regards,
Karoliina



More information about the ubuntu-devel mailing list