diyAudio logo

History of LINUX Audio Kernel


Older Newer
Sun, 07 Dec 2008 20:00:02 . . . . (soundcheck)?


Changes by last author:

Added:
Revision 1 11/21/08 soundcheck: Intro Zen-Kernel
Revision 2 06/22/09 soundcheck: Zen-Kernel removed, 2.6.29.5 Main-line kernel + rt21-rt-patch, 2.6.30 Ubuntu easy install
Revision 3 07/06/09 soundcheck: 2.6.29.5 Main-line kernel + rt22-rt-patch
Revision 4 07/16/09 soundcheck: 2.6.29.6 Main-line kernel + rt23-rt-patch

= I. Introduction =


Why do we need a specific kernel other than the stock distro kernels for audio?

From my perspective there are two main reasons: You'll get a. most current drivers (also Alsa drivers) and b. better performance.

By introducing such a kernel you'll be usually 6 to 12 month ahead of e.g. Ubuntu.

You need to consider though, that there is a slight chance to buy-in certain instabilities when playing with unpatched
and untested mainline-kernels or prelimanary Ubuntu kernels. However usually these problems usually occur on very special
drivers. If you have a pretty Linux compliant PC, you shouldn't face that many, if any at all, problems.

For know I describe how to step up your distro kernel and how to get a custom realtime patched mainline kernel compiled.
Note that the custom kernel is purely based on mainline sources. Ubuntu usually applies a number of patches, which will
make the kernel more stable.

Both modifications you can easily revert back, by removing the respective packages with e.g. Synaptics.


As usual make a backup first.


NOTE: Below instructions don't cover GPU driver related instructions. If you use restricted/proprietary drivers uninstall them first.
You need to install a Linux GPU driver before starting the journey.


= 2. Real Time Kernel Custom installation =

The rt-kernel guys around Thomas Gleixner and Ingo Molnar are actively (since 2.6.29) working on the rt-patch
and removing this or that bug. They actually revised and have rewritten the entire patch recently.
It seems that there is quite an interest from the industry to use Linux in realtime applications to control sensitive machines.

It is always recommended to have the latest patch-set running. I try to keep below instructions up2date.

As you might have seen in the Linux Audio thread, there is a never ending debate ongoing about if there is a need for a
rt-kernel at all. I think there is. Most of the professional audio software (e.g. Jack,ecasound, brutefir) support realtime operation
to achieve lowest latency. All of them even recommend to use a realtime kernel for achieving best performance (see references Performance).
Your risk of running into XRUNS is much lower when using an rt-kernel.

Me and some other people who are using the rt-kernel experience much better sound performance by using an rt-kernel.

You decide if you want to give it a try.

The custom installation won't be that easy. Kernel hacking it's a science on its own. However - it is possible.


So, either you use the standard distro rt-kernel or you do a custom installation.

Via Synaptic you can easily install the distro-kernel: the packages are called linux-image-2.6.28-3-rt and linux-headers-2.6.28-3-rt. You
can skip below instructions up to step 8.

Since below installation works quite good on my system I'd even recommend the customized installation.

I just installed the 2.6.29.6 kernel with patch-2.6.29.6-rt23.bz2. I have to say ,it "Sounds" good to me. ;)

Some references:

RT-kernel Wiki: https://rt.wiki.kernel.org/index.php/Main_Page
Performance: https://www.osadl.org/Single-View.111+M5857ed4d9af.0.html


A Quick How-To:


1. Uninstall (admin/hardware drivers) fglrx driver first and reboot
2. Install packages

apt-get install fakeroot kernel-package build-essential libncurses5-dev git-core

3. Download sources

cd /usr/src

sudo su

rm linux
rm linux*deb

wget https://kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.6.tar.bz2
wget https://www.kernel.org/pub/linux/kernel/projects/rt/patch-2.6.29.6-rt23.bz2

mv ./linux-2.6.29.6 linux-2.6.29.6-rt23
ln -s ./linux-2.6.29.6-rt23 linux
cd linux

4. Patch the kernel

cd /usr/src/linux
sudo su
bzcat ../patch-2.6.29.6-rt23.bz2 | patch -p1

5. Setup your kernel .config

cd /usr/src/linux
sudo su

make oldconfig # using current kernel-config and just select the differences to the new kernel. Most important is choosing full preemption, Most of the other options you enter return.

then you do:

make menuconfig

set preemption mode to "complete preemption" under "processor type and features"- "Preemption mode"
set timer freqency to 1000Hz under "processor type and features"-"timer-frequency"
disable "staging" drivers under device-drivers otherwise the kernel won't compile
USB disable "Improved Transaction Translator Scheduling" under device-drivers/usb support
turn off as many debug options as possible under kernel hacking, debugging slows down the kernel

Let me know if you want to have my .config as reference.

6. Compile kernel

cd /usr/src/linux
sudo su

make-kpkg clean
INSTALL_MOD_STRIP=1 CONCURRENCY_LEVEL=2 fakeroot make-kpkg --initrd --revision=rt21 kernel_image kernel_headers


Note: Depending on your processing power and .config this will take up to 45 minutes.

cd ..


7. Install .deb

cd /usr/src
sudo su
dpkg -i linux-image*.deb
dpkg -i linux-headers*.deb


8. Now you need to assign the right to use realtime permissions to your users and/or groups


sudo echo "@audio - rtprio 99" >> /etc/security/rlimits.conf
sudo echo "@audio - nice -19" >> /etc/security/rlimits.conf
sudo echo "@audio - memlock unlimited" >> /etc/security/rlimits.conf

Instead of "@audio", which stand for "group audio" you can use your user-id e.g. mine would be "soundcheck" instead. In this case only soundcheck can use rt-priorities.


8. Reboot


9. To apply rt-priorities to a process ( e.g. fifo-scheduler and rt-prio 99 ) you need to start it e.g. with "chrt -f 99 aplay -Dplughw:0,0 -fcd mywav.wav"
rt oprimized application such as Jack, ecasound and brutefir don't need the "chrt" to run with realtime priorities.
To check if your process runs in rt-mode type "ps -eo pid,pri,ni,rtprio,command"


Enjoy.

= 2. Ubuntu 2.6.30 installation =


For some of you it might be interesting to install the preliminary stock 2.6.30 Ubuntu kernel on Jaunty,

On one hand you get a newer Alsa revision and on the other hand you get access to a lot of nice new features.

The exercise is quite trivial:

You can download ready made deb-packages from here: https://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30/

Copy them to /usr/src . Keep below sequence when installing the packages.

sudo su

cd /usr/src
dpkg -i linux-headers-2.6.30-020630_2.6.30-020630_all.deb
dpkg -i linux-headers-2.6.30-020630-generic_2.6.30-020630_i386.deb
dpkg -i linux-image-2.6.30-020630-generic_2.6.30-020630_i386.deb

shutdown -r 0

That's it.

Enjoy your new kernel.