Do I really need an RT(Real Time) kernel

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Thanks, Pablo, but I don't fully understand. I did the things you mention but I don't see my interface anywhere in the list.

I got this:

Code: Select all

aaron@Satellite-wolf ~ $ cat /proc/interrupts
           CPU0       CPU1       
  0:      12278     200079   IO-APIC-edge      timer
  1:       1110         28   IO-APIC-edge      i8042
  7:          1          0   IO-APIC-edge    
  8:          0          1   IO-APIC-edge      rtc0
  9:       1583        236   IO-APIC-fasteoi   acpi
 12:     123582        181   IO-APIC-edge      i8042
 16:     601616        511   IO-APIC-fasteoi   hda_intel, rtlwifi
 17:         12        102   IO-APIC-fasteoi   ehci_hcd:usb1, ehci_hcd:usb2, ehci_hcd:usb3
 18:          5     140480   IO-APIC-fasteoi   ohci_hcd:usb4, ohci_hcd:usb5, ohci_hcd:usb6, radeon
 19:      14003       7173   IO-APIC-fasteoi   ahci
 40:          0          0   PCI-MSI-edge      PCIe PME
 41:          0          0   PCI-MSI-edge      PCIe PME
 42:          0          0   PCI-MSI-edge      PCIe PME, pciehp
 43:          0          0   PCI-MSI-edge      eth0
NMI:          0          0   Non-maskable interrupts
LOC:     163286      82041   Local timer interrupts
SPU:          0          0   Spurious interrupts
PMI:          0          0   Performance monitoring interrupts
IWI:          0          0   IRQ work interrupts
RES:    1015579    1166213   Rescheduling interrupts
CAL:        735        994   Function call interrupts
TLB:       9130       9220   TLB shootdowns
TRM:          0          0   Thermal event interrupts
THR:          0          0   Threshold APIC interrupts
MCE:          0          0   Machine check exceptions
MCP:          6          6   Machine check polls
ERR:          1
MIS:          0
aaron@Satellite-wolf ~ $ cat /proc/asound/modules
 0 snd_hda_intel
 1 snd_usb_audio
So the device according to modules is just "usb_audio", but I don't see that in the interrupts list.

here's what's in my rtirq file:

Code: Select all

# IRQ thread service names
# (space separated list, from higher to lower priority).
RTIRQ_NAME_LIST="firewire snd usb i8042"

# Highest priority.
RTIRQ_PRIO_HIGH=90

# Priority decrease step.
RTIRQ_PRIO_DECR=5

# Whether to reset all IRQ threads to SCHED_OTHER.
RTIRQ_RESET_ALL=0

# On kernel configurations that support it,
# which services should be NOT threaded 
# (space separated list).
RTIRQ_NON_THREADED="rtc snd"

# Process names which will be forced to the
# highest realtime priority range (99-91)
# (space separated list, from highest to lower priority).
# RTIRQ_HIGH_LIST="timer"
Finally, in htop, there are lots of irq items listed under root, I don't see the usb audio thing, and jack doesn't show up until later, under a listing for my user name (but Jackdbus is the first for my user name). Also only three items are listed under PRI as being RT (migration 0 and 1, and rtkit-daemon). But the next stuff after those RT ones all have a PRI number that is negative, that includes the IRQ processes as well as the sound-related stuff under my user name.
Aaron Wolf
Music teacher, scholar
http://wolftune.com

Pablo
Established Member
Posts: 1269
Joined: Thu Apr 17, 2008 9:57 pm

Re: Do I really need an RT(Real Time) kernel

Post by Pablo »

Hi,

You have two audio cards, the onboard and a USB one, right?

As for the onboard, this is bad:

16: 601616 511 IO-APIC-fasteoi hda_intel, rtlwifi

Whenever you want to use jack with the onboard audio card, disable the wifi card. You can do this by:

sudo modprobe -r module_name

You can identify the module name with:

lsmod
and, possibly, to double-check, also with:
lspci -k

Well, now for the USB card.

This is a bit different because you don't see the module in /proc/interrupts. So you have to identify what USB bus the audio card is connected to. Just do a:

lsusb

You want that the audio card is the only device connected to that bus. Try reconnecting/disconnecting things (USB mouse, the card itself, whatever...) to other USB sockets if the card is sharing bus with other devices.

Now, assuming your card is in bus number 1 (Bus 001), try in /etc/default/rtirq:

RTIRQ_NAME_LIST="usb1"

Save this file and restart rtirq:

sudo /etc/init.d/rtirq start

Check htop again. In jack setup, rise the priority. 60 or 70 is OK. Hopefully, you will see the relevant usb bus and jackd (or jackdbus) higher than most other processes.
Also only three items are listed under PRI as being RT (migration 0 and 1, and rtkit-daemon). But the next stuff after those RT ones all have a PRI number that is negative, that includes the IRQ processes as well as the sound-related stuff under my user name.
I don't try to understand it all because these are highly technical matters but I know that all processes with a negative number in the PRI column are realtime processes. The big the number (in absolute value) the more the priority.

Note that rtirq will raise the priorities automatically when you boot the computer, so if it all seems right this is a good moment to reboot and run htop again so you convince yourself that priorities are OK.



As for the low latency kernels: Alessio Abogani's PPA used to be a good resource but it seems off nowadays. The good news is that the presice pangolin (ubuntu 12.04 LTS) will include a low-latency kernel in their official repos, so installing it will be a breeze for all ubuntu derivatives. When it's out, I think upgrading will be a good idea and not only because of this.

Anyway, I hope you can improve the situation with the tweaks explained above.

Cheers, Pablo

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Ok, I can wait for the next system version for the kernel, that sounds good. Otherwise, this sort of advice is exactly what I needed, thanks so much.

So, looking at htop, I realized that I needed to put Jack at a priority of 86 just to be past the wifi and other irq listings. I thought about making jack higher than 90, but I read elsewhere that jack has a built-in watchdog that will be 10 higher, so I should leave room for that, right? Or should I install some other watchdog?

So now jackdbus is higher than most other irq listings, but other apps like calfjackhost are high but below ohci_hcd and radeon. Is that fine?

Incidentally, is it worth considering using smaller buffers but increasing the periods/buffer or otherwise playing with that setting?

Also for RTIRQ, I read somewhere that the rtc is still good to have, so I left that in the list, but right after it I added usb4 (because my card was on Bus 004). However, even after reboot I see nothing in htop referring to the usb or audio card, should I? How do I verify if the text "usb4" was the right thing to enter in RTIRQ? I'm not confident that it actually set my usb device correctly…

Thanks again so much!
Aaron Wolf
Music teacher, scholar
http://wolftune.com

slowpick
Established Member
Posts: 457
Joined: Mon Apr 25, 2011 10:09 am

Re: Do I really need an RT(Real Time) kernel

Post by slowpick »

http://www.thegeekstuff.com/2011/09/lin ... -examples/

89 is max priority in qjackctl, 99 is max in /etc/security/limits.config

A well weeded daw can use 89, because things hoping to supplant
your jackd setting, will have been removed, shut off in the bios, or
can wait til the audio session is over.

Have you maxed out your system, and seen if cpu load sharing is well done?
On 60 % load of two CPUs, htop shows 31 and 29 cpu ballpark average. Sweet!

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

I understand the values of weeding a DAW for absolute dedicated high-end audio, but I'm not talking about that. One day I may be dealing with that, but at the moment I am just wanting to run a minimal amount of live effects without xruns. The thing that confuses me is that I get xruns every now and then (not constant, but every few minutes) even though I have very low DSP use and very low CPU use overall. So nothing is being maxed, nothing is overloading that I can identify, not even close. So I'm trying to understand why, under this situation, xruns still occur, and how to stop them. Maybe because I still haven't set my USB audio card the right way in rtirq?

So thanks for the thoughts, slowpick, but maxing out and CPU allocation etc. is for another day. I just want things to work at a minimum first. To clarify, I'm happy to learn about optimizing, but it isn't my current priority. Again, I'm not talking about xruns that occur because of DSP or CPU overload, but xruns that occur because [I dunno… Why do they occur when CPU and DSP use are still minimal?]…
Aaron Wolf
Music teacher, scholar
http://wolftune.com

User avatar
Capoeira
Established Member
Posts: 1244
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil

Re: Do I really need an RT(Real Time) kernel

Post by Capoeira »

wolftune wrote:Maybe because I still haven't set my USB audio card the right way in rtirq?
look up how your soundcard usb port is called with

Code: Select all

cat /proc/interrupts
.
It will be something like

Code: Select all

ehci_hcd:usb4
put that instead of "usb" in rtirq config

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Thanks, Capoeira, but as I mentioned earlier in this, cat /proc/interrupts isn't showing any listing for my USB interface, even though it shows up in aplay -l

ok, maybe I am just confused. But here's the situation:

cat /proc/interrupts
does show stuff like ehci_hcd:usb1 and ohci_hcd:usb4 (and others, from 1 to 6, the first three are ehci, the last three are ohci. I have no idea what that means).

But that list doesn't change when I plug or unplug the USB Audio Interface (an Alesis io4 for reference). So it seems like that command is just not getting any name for the device.

But cat /proc/asound/modules lists it as "snd_usb_audio"

And aplay -l lists it as "card 1: [io4], device 0: USB Audio [USB Audio]

So can I use the name from that in RTIRQ? Maybe the name is "USB Audio" ? or "io4" ?

using lsusb, I determined that it was on Bus 004, but I don't know if that matters here…
Aaron Wolf
Music teacher, scholar
http://wolftune.com

User avatar
Capoeira
Established Member
Posts: 1244
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil

Re: Do I really need an RT(Real Time) kernel

Post by Capoeira »

if it's on bus 4, it's "ohci_hcd:usb4"....so you would put that in the rtirq script.

is ohci_hcd:usb4 on his own irq or is it shared?
if it's shared is one of the other port isolated on a irq?

sorry i haven't read all what was written

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Ok, so in cat /proc/interrupts
ohci_hcd:usb4
is listed in the same line (marked 18:) as usb5, usb6, and radeon

So that seems unfortunate. Not much I can do about that, I think. I don't have reason to believe that usb5 and usb6 are anything, but radeon would be the graphics card right?

So that might interfere…

But anyway, I'm setting ohci_hcd:usb4 rigtht after rtc in RTIRQ
The only weird concern is that this would, I think, set all USB devices I ever use, even if I sometime do not use the audio interface but instead am just plugging in any other USB device, because I think this is just a general listing for all the ports on the computer (when I tried switching the interface among the different USB jacks, it still always listed usb4 in lsusb)

Also, I read somewhere on some site about RTIRQ that there is some way to specify preference within a shared line like this… I'll have to find that again. Any advice or links would be appreciated, of course.

Thank you all so much for the help
Aaron Wolf
Music teacher, scholar
http://wolftune.com

User avatar
Capoeira
Established Member
Posts: 1244
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil

Re: Do I really need an RT(Real Time) kernel

Post by Capoeira »

wolftune wrote:Ok, so in cat /proc/interrupts
ohci_hcd:usb4
is listed in the same line (marked 18:) as usb5, usb6, and radeon
what about usb 1,2 and 3?

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Capoeira wrote:
wolftune wrote:Ok, so in cat /proc/interrupts
ohci_hcd:usb4
is listed in the same line (marked 18:) as usb5, usb6, and radeon
what about usb 1,2 and 3?
those are listed in their own line, and they are ehci instead of ohci

I don't know what they are, or why there are 6 USB listings for the computer. (For reference, I have two USB ports on one side and a combo USB/eSATA port on the other side. That's it. It's a cheap computer. I didn't buy it to have a professional studio. Think of it as my cheap learning machine, where I'll probably upgrade to a new machine after I really get comfortable with Linux and know what features to care about and what my plans are)
Aaron Wolf
Music teacher, scholar
http://wolftune.com

slowpick
Established Member
Posts: 457
Joined: Mon Apr 25, 2011 10:09 am

Re: Do I really need an RT(Real Time) kernel

Post by slowpick »

wolftune wrote:I understand the values of weeding a DAW for absolute dedicated high-end audio, but

Why do they occur when CPU and DSP use are still minimal?]…
Did I mention high-end audio? :? Perhaps even discussing RT and audio
does imply that :)

Is something polling the system for diskdrives, optical devices,
usb connections, bluetooth/network/skype/webcam/internet connections?
Is something monitoring cpu cycles, memory use, or temperature?
Are your hardisks getting full? Are there multiple devices plugged in?
Are there both ohci and ehci connections used at the same time?
Is wine starting automatically?
Lots of nits to pick :( but,

if an xrun occurs, and is inaudible, it's like driving to work,
and running over a grain of sand. Worry over such, will bring on chest pains.

The least complex path for
audio is the pci bus. usb was never done right by manufacturers,
and never implemented well by msoft or apple. It was a cheapo
connection, chosen so office droids could boost their self esteem by
dabbling with a computer, without burning up their cubicle.

wolftune
Established Member
Posts: 1305
Joined: Fri Feb 24, 2012 7:40 pm
Location: Portland, OR
Contact:

Re: Do I really need an RT(Real Time) kernel

Post by wolftune »

Yeah, I know USB is mediocre. It's like lots of stuff we deal with that GNU/Linux highlights, such as mp3 vs ogg. The right choice for quality tools isn't always what gets used most. My computer has no PCI card slot. I could get one that did, but I'm trying to learn about what can actually work…

Yes I am sure something is monitoring stuff. No the disks aren't full at all.
I still don't really understand about ohci vs ehci (I searched online and didn't learn enough to get any real clarity)

Anyway, I'm not concerned about xruns dogmatically. I'm concerned about playing live and suddenly hearing a series of very audible glitches for a second here and there. If it's possible to avoid these glitches on my Mac, then I should be able to avoid them on GNU/Linux, right? (Although to be fair, the primary thing I've used with my Mac is a Firewire interface… but I know that for the basic functions I'm trying to do, the Mac and USB can do it)

So to be clear: I just don't want audible glitches while playing live through guitarix or similar, that's it. I'll deal with whatever other problems come up later…
Aaron Wolf
Music teacher, scholar
http://wolftune.com

Pablo
Established Member
Posts: 1269
Joined: Thu Apr 17, 2008 9:57 pm

Re: Do I really need an RT(Real Time) kernel

Post by Pablo »

So now jackdbus is higher than most other irq listings, but other apps like calfjackhost are high but below ohci_hcd and radeon. Is that fine?
It is fine that calfjackhost or any ohter jack client is below jackdbus. What is not fine is that radeon is so high. I hoped that configuring RTIRQ_NAME_LIST to "rtc usb4" left the radeon and the other ohci_usb buses below, but it seems that it raised the whole IRQ #18.

htop is cool to see what happens but not very convenient for copy/pasting. If you'd like to show us, use this command:

ps -eLo cls,rtprio,cmd | grep FF

FF means SCHED_FIFO, i.e., realtime. It is equivalent to the minus sign in htop. (If you leave out " | grep FF" you will see many more processes under TS and RR which are other kinds of scheduling).
I still don't really understand about ohci vs ehci
ehci_hcd and ohci_hcd are linux drivers. Afaik, ohci_hcd will be loaded for USB1.1 hosts and ehci_hcd for USB2.0 hosts. Your computer seems to have more USB hosts than you can actually access.
If it's possible to avoid these glitches on my Mac, then I should be able to avoid them on GNU/Linux, right?
I don't think so. They are two different computers and I am sure the Mac is much better configured on the hardware side. You pay for it.
So to be clear: I just don't want audible glitches while playing live through guitarix or similar, that's it. I'll deal with whatever other problems come up later…
Well, things that can help:

- Sort out the IRQ thing, so that at least radeon is left below the usb4. I suggest you talk to Rui about this. This could be the main issue when using the usb card. When using the onboard card, the main issue will be the wifi card as we saw.

- Try running jackd in synchronous mode. For this, you have to append --sync to the jackd command. In qjackctl, just write /usr/bin/jackd --sync in the "Server Path" field.

- Make sure your CPU is running on "performance" mode, not "on demand". These are modes for CPU freq scaling. In gnome classic you can add an miniapplication to the panel. In KDE I don't know how to do this "the graphical way". For the CLI way, check threads here (in system configuration board) and/or linuxmusicians wiki.

- Last but not least, increase the latency as much as you can bear it. For USB audio cards, 256 frames/period, 3 periods/buffer is a good compromise, imho. Howver, if you can play with 512 frames without cursing too much, go for it. 1024 is unbearable for playing guitar live, in my experience.

Cheers, Pablo

Pablo
Established Member
Posts: 1269
Joined: Thu Apr 17, 2008 9:57 pm

Re: Do I really need an RT(Real Time) kernel

Post by Pablo »

I thought about making jack higher than 90, but I read elsewhere that jack has a built-in watchdog that will be 10 higher, so I should leave room for that, right?
In our beloved OS, flexibility is a rule, so Joe the User like you and me can't possibly understand it all but they can try to apply the logic as being the only possible way to sucess. However, logic is hard to swallow.

My first rule is: Don't worry about things too complicated to grasp at second sight.
Or should I install some other watchdog?
No, please. Don't do things like that. Keep it as simple as possible, as you usually do.

You are a teacher. You know that there is always something hidden. You and no one else can solve it, you only need patiente.

BTW, I watched the video! The song on the brain. Keep it up, I like it a lot!

Post Reply