Building your own real-time kernel

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Building your own real-time kernel

Post by autostatic »

Anyone building their own real-time kernels here? If so I'd like to know if people make any changes to the kernel config and if those changes improve the Linux audio experience.

Thanks!

Jeremy
User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: Building your own real-time kernel

Post by khz »

. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

Thanks khz!

Code: Select all

Processor type and features  --->
[*] Tickless System (Dynamic Ticks)
What does using a tickless kernel actually do?
User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: Building your own real-time kernel

Post by khz »

good question ^^
current @ my box i have

Code: Select all

[ ] Tickless System (Dynamic Ticks)
Tickless System (Dynamic Ticks) wrote:CONFIG_NO_HZ: │
│ │
│ This option enables a tickless system: timer interrupts will │
│ only trigger on an as-needed basis both when the system is │
│ busy and when the system is idle. │
│ │
│ Symbol: NO_HZ [=n] │
│ Type : boolean │
│ Prompt: Tickless System (Dynamic Ticks) │
│ Defined at kernel/time/Kconfig:7 │
│ Depends on: !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS [=y] │
│ Location: │
│ -> Processor type and features │
│ Selects: TICK_ONESHOT [=y]
http://elinux.org/Kernel_Timer_Systems#Dynamic_ticks
http://lwn.net/Articles/223185/
. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

Ah, it's actually a power saving thingamajig! I thought so already but the links made it clearer, thanks. So it's got almost nothing to do with performance.
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: Building your own real-time kernel

Post by raboof »

AutoStatic wrote:Ah, it's actually a power saving thingamajig! I thought so already but the links made it clearer, thanks. So it's got almost nothing to do with performance.
Well, that's a bit of a bold statement :). For example frequency scaling can have a massive effect on xruns.

I haven't heard of problems with the tickless timer, but I haven't really done any measurements myself either.
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

raboof wrote:Well, that's a bit of a bold statement :).
He he true, but I don't think it has such an impact as CPU frequency scaling.
raboof wrote:I haven't heard of problems with the tickless timer, but I haven't really done any measurements myself either.
There probably aren't problems with it (rg42 uses it for instance) but I get the idea that people mainly use it on {note,net,ultra}books.
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: Building your own real-time kernel

Post by raboof »

AutoStatic wrote:I get the idea that people mainly use it on {note,net,ultra}books.
All the recent (3.x) debian kernels are built with it enabled, so it can't be too bad :).
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

Good to know. TIme to check the Debian config :)
User avatar
bluebell
Established Member
Posts: 1909
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 111 times
Been thanked: 116 times

Re: Building your own real-time kernel

Post by bluebell »

Some days ago I built a realtime kernel using the instructions at
http://joegiampaoli.blogspot.de/2011/06 ... linux.html

I didn't notice a difference to my old kernel (3.0.0 with HZ1000 as the only modification) exept for

- m-audio Fast Track Pro operated in 24 bit mode (but not more reliable). Since I switched to Focusrite Scarlett 2i2 this wasn't important for me.

- I had crashes in the VirtualBox-module. Since I use my PC to start virtual machines this new kernel was useless to me.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

Thanks for bringing that one up bluebell! The instructions to build a kernel are exactly the same but the article does contain some useful information.
User avatar
Michael Z Freeman
Established Member
Posts: 43
Joined: Thu Dec 17, 2009 1:49 pm
Location: England
Contact:

Re: Building your own real-time kernel

Post by Michael Z Freeman »

Did this recently. Spent some time thrashing around as I was approaching the build based on the last time I did this, in 1999 ! Eventually I followed the "Debian way" (see the official docs) of building a kernel based on their patched kernel code retrieved through the Debian package manager.

sudo apt-get source linux
sudo apt-get install build-essential fakeroot
sudo apt-get build-dep linux


(Above may differ depending on Debian OS version, check the official Debian kernel build docs)

Applying patches is easy using "test-patches". Any extra needed kernel symbols are set in "debian/config/featureset-rt/config" - no need to go through xconfig or whatever. I think "test-patches" can be used to build the kernel even if you don't have to apply patches.

bash debian/bin/test-patches -f 686-pae -s rt -j 4 ../alsa-snd-usb-audio-Replace-mixer-for-Electrix-Ebox-44.patch ../alsa-snd-usb-audio-Skip-un-parseable-mixer-units.patch

That will give you a nice debian package to install - your own custom kernel !
User avatar
Michael Z Freeman
Established Member
Posts: 43
Joined: Thu Dec 17, 2009 1:49 pm
Location: England
Contact:

Re: Building your own real-time kernel

Post by Michael Z Freeman »

I need to follow up on the previous post. Don't know how it is for other distro's but I've had problems finding a SANE way of building the kernel that simply gets things WORKING in my professional production music system studio. But I've cracked it. I've found a SIMPLE way of doing this on a Debian system ...

Here is my email from the debian-user list in reply to the author of the above document ...

Soon after writing this message and after studying your document I
realised I'd forgotten something. As I found there are complexities
such as the revision string that need to be known about, as are
covered in your document, and your document will certainly come in
useful for any future problems !

The thing I forgot is that I originally used test-patches (in
debian/bin). I had the problem with the conflict of revision strings;
test-patches adds "a~test". So I thought, "why not remove this string"
? I ended up editing test-patches ...

# Append 'a~test' to Debian version; this should be less than any official
# successor and easily recognisable
# version="$(dpkg-parsechangelog | sed 's/^Version: //; t; d')"
# if [ "${version%a~test}" = "$version" ]; then
# version="$version"a~test
# dch -v "$version" --distribution UNRELEASED "Testing patches $*"
#fi

I commented out lines 50 to 56. Now test-patches builds the kernel
without the revision string mismatch. I proceeded to install Nvidia
DKMS without any problems (therefore fixing my original problem).

sudo apt-get source linux
cd linux-3.2.23
sudo chown -R djbarney.djbarney *
sudo chown -R djbarney.djbarney .*
Config options added to debian/config/featureset-rt/config
bash debian/bin/test-patches -f 686-pae -s rt -j 4
../alsa-snd-usb-audio-Replace-mixer-for-Electrix-Ebox-44.patch
../alsa-snd-usb-audio-Skip-un-parseable-mixer-units.patch

This builds ...

linux-headers-3.2.0-3-rt-686-pae_3.2.23-1_i386.deb
linux-image-3.2.0-3-rt-686-pae_3.2.23-1_i386.deb
linux-image-3.2.0-3-rt-686-pae-dbg_3.2.23-1_i386.deb

After installing the RT kernel and booting on it I run ...

sudo apt-get install --reinstall nvidia-kernel-dkms

I know this actually creates (I think) a revision string conflict with
official packages. But I can live with that. I just need to reinstall
after any future updates.

Testing currently shows qjackctl (Jack Audio) reporting a working
real-time system, with my external USB audio hardware (the patches for
ebox) with ZERO X-Runs and a 10.7ms latency.

So I seem to have stumbled upon a method that seems to be reserved by
Debian kernel developers for testing patches that actually makes this
process pretty painless. Of course some of this may be dependent on
the current state of Wheezy testing and other Debian kernel policies
that seem to be in flux. Hopefully what I've discovered here can help
other people who need to patch the kernel (to get hardware working,
etc) and encourage the development and documentation of procedures to
make all this a relatively painless process.

Barney Holmes
Quoted from my document.
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Building your own real-time kernel

Post by autostatic »

User avatar
Michael Z Freeman
Established Member
Posts: 43
Joined: Thu Dec 17, 2009 1:49 pm
Location: England
Contact:

Re: Building your own real-time kernel

Post by Michael Z Freeman »

Yes, thanks. That's another way. My only comment would be that the Debian way basically avoids a lot of the little caveats and technical details that, personally start giving me tunnel vision after a while. Because I can leave most of that that to the Debian developers. The stock Debian kernel is built to run on any machine but it is carefully set up. Development decisions are made by experienced developers about things I probably don't want to know about (and might end up running from the room screaming if I did). This way the kernel is not fully optimised and cut down to size but its good enough. I'm getting good performance on my machine. No X-runs and 10.7ms latency. That's good enough for me and this way takes away a lot of the headaches that might otherwise come up. Hopefully that can help musicians just wanting to make music (and not be stuck fiddling around in config files).

Apologies if that sounds over critical in any way. Some may prefer the more technical path. But I'm concerned that I see some confusion out there about what is the major strength of Linux when it comes to music production ... real time capability, customisation, and on the most part up to date hardware support if one is prepared to wait a little for patches (or can write their own).
Post Reply