This is a follow up to the previous post located here
Well I finally decided to get down and dirty once again and dive into the innards of real time kernel tuning. As I reported last time, I was getting some latency which was evident through the sound card as a very nasty buzzing sound. Here I’ll report some basic findings which hopefully will help anyone attempting to set up a real time system set up for use as a DAW.
My system is running Ubuntu Gutsy Gibbon. You may recall where I had some serious trouble installing the Ubuntu Studio real time Ubuntu kernel; the initrd image was severely anemic to the point where I couldn’t even boot up. Instead, I decided to download the latest kernel source and roll my own so I knew everything would be just the way I wanted.
Before I go into the step by step process of how that was done, allow me to report some updated findings that may clear up some confusion. One issue is deciding what method to use to grant realtime scheduling to users (so you don’t have to run programs as root, which is a very bad idea). The old way of doing things was to use the realtime-lsm kernel patch and module. The problem I was running into with this method along with the latest 2.6.24 kernels is the fact that you can no longer configure your kernel with CONFIG_SECURITY_CAPABILITIES as a module! The kernel maintainers have decided that it introduces some serious security vulnerabilities, so the only options now are built into the kernel or not at all. This is a serious problem when using realtime-lsm since presumably the capability module does not support stacking and needs to be unloaded when the realtime-lsm module is loaded. This is not completely true as pointed out by the Debian Kernel Team, but the realtime-lsm module patches I was using have not been modified to correct this. In any case, realtime-lsm has been deprecated in favor of the newer PAM rlimits method of granting realtime scheduling priority to userspace programs. It is important to note that realtime-lsm will still give you superior performance over the rlimits method for really heavy multimedia work, but in 99% of cases the rlimits method should suit most users just fine. The rlimits method works by configuring priority scheduling limits in /etc/security/limits.conf.
Let’s get to the meat of how I configured my system. I’m going to list all the steps in order with a very brief explanation of each.
First we get the latest kernel source tarball. In my case this was 188.8.131.52.
Then we get the latest realtime kernel patch. Make sure the patch version matches your kernel version above. Get the latest rt version if there is more than one for your kernel. In my case this was patch-184.108.40.206-rt3.bz2.
Copy the files to your kernel source tree, un-tarball them and patch the kernel. Be sure to use the proper version numbers below in place of these as applicable from your download.
tar zjfv ~/linux-220.127.116.11.tar.bz2 linux-18.104.22.168 .
ln -s linux-22.214.171.124 linux
bzcat ~/patch-126.96.36.199-rt3.bz2 | patch -p1
Get your current working config if you have one.
zcat /proc/config.gz > .config
cp /usr/src/linux-`uname -r`/.config ./.config
From the existing .config, if you have one, update the settings from it. If there are any new features from the last config file, you may be asked some configuration questions.
Get your favorite editor out and modify the config file to match the following settings. If they don’t exist just add them to the end of the config file. Another option is to make menuconfig (or xconfig, gconfig, config, etc.) and set the values that way.
Now we can recompile and install our kernel. Below is the Debian/Ubuntu way of doing it. You can use the old school make && make modules && make modules_install technique as well. The Debian way does it all for you and packages the kernel image and headers as .deb packages in /usr/src and even installs the new kernel into GRUB!
make-kpkg --initrd --append-to-version=-rt_custom kernel_image kernel_headers
dpkg -i ../*deb
Now we grant realtime scheduling to the user group audio. Be sure your user account is part of this group. Here we set a max priority of 99 (RT), nice value of -10 (not very nice ) and memlock value of 512MB.
sudo cat "@audio - rtprio 99" >> /etc/security/limits.conf
sudo cat "@audio - nice -10" >> /etc/security/limits.conf
sudo cat "@audio - memlock 512000" >> /etc/security/limits.conf
Verify everything looks good in GRUB and reboot. Verify you’re running the new kernel. Look for PREEMPT RT in the version.
Linux ubuntu 188.8.131.52-rt3-rt_custom #1 SMP PREEMPT RT Sun Mar 2 22:06:11 CST 2008 i686 GNU/Linux
Great! Now you can run qtjackctl and select the appropriate realtime setting. You can launch your other studio applications with these settings as well and modify them in real time using the chrt command. You can check on the status of a process with ps -eo rtprio,comm.
ps -eo rtprio,comm | grep jack
chrt -p 99 <process id>
I will follow up with some more details and howtos regarding working with your DAW. Feel free to comment below if you have any questions or email me using the email icon at the top of the page. Enjoy!