How do I enable real time?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Luc
Established Member
Posts: 741
Joined: Fri Mar 27, 2015 1:04 pm
Been thanked: 1 time

How do I enable real time?

Post by Luc »

Two years ago, I did not have real time enabled and I learned how to enable it in some forum. It may have been here, but perhaps elsewhere. It worked, but I didn't write it down, and now I don't know how I did it. :x

All I know is that I can check it works with this command:

Code: Select all

ps ax | grep "\[irq"
   37 ?        S      0:00 [irq/9-acpi]
   51 ?        S      0:00 [irq/12-i8042]
   52 ?        S      0:00 [irq/1-i8042]
   53 ?        S      0:00 [irq/8-rtc0]
  105 ?        S     10:46 [irq/23-ehci_hcd]
  106 ?        S     11:23 [irq/23-ehci_hcd]
  107 ?        S      5:37 [irq/42-ahci]
 9276 ?        S      0:05 [irq/41-eth0]
18198 ?        S      0:00 [irq/43-mei_me]
18199 ?        S      0:04 [irq/44-snd_hda_]
18200 ?        S      0:02 [irq/45-i915]
18202 ?        S      0:05 [irq/16-rt2800pc]
I seem to vaguely remember something to do with /boot or grub. Does anyone know?
rghvdberg
Established Member
Posts: 1067
Joined: Mon May 12, 2014 7:11 am
Has thanked: 15 times
Been thanked: 36 times

Re: How do I enable real time?

Post by rghvdberg »

There's a real time kernel.
There's real-time priveleges.
And there's rt-irq.

It depends on your Linux distro how to install and configure them.
Luc
Established Member
Posts: 741
Joined: Fri Mar 27, 2015 1:04 pm
Been thanked: 1 time

Re: How do I enable real time?

Post by Luc »

Thanks, but I would like to remember how I did it the last time around.
tramp
Established Member
Posts: 2348
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 9 times
Been thanked: 468 times

Re: How do I enable real time?

Post by tramp »

First step will be to create/edit /etc/security/limits.d/audio.conf
and wrote in:

Code: Select all

 @audio - rtprio 90       # maximum realtime priority
 @audio - memlock unlimited  # maximum locked-in-memory address space (KB)
add yourself to the audio group if you are not a member:
check if you are in the audio group:

Code: Select all

groups
add yourself to the audio group ( as root):

Code: Select all

useradd -G audio username
reboot and use rt.
On the road again.
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: How do I enable real time?

Post by CrocoDuck »

Luc wrote:I seem to vaguely remember something to do with /boot or grub. Does anyone know?
It seems to me you are thinking about rtirq actually. That needs to boot with threadirqs parameter, and you need to indeed configure GRUB for that. Let us know if you need to do that. Otherwise, if you want to enable your user for realtime audio operation, tramp already provided instructions.
Luc
Established Member
Posts: 741
Joined: Fri Mar 27, 2015 1:04 pm
Been thanked: 1 time

Re: How do I enable real time?

Post by Luc »

CrocoDuck wrote:It seems to me you are thinking about rtirq actually. That needs to boot with threadirqs parameter, and you need to indeed configure GRUB for that. Let us know if you need to do that. Otherwise, if you want to enable your user for realtime audio operation, tramp already provided instructions.
tramp's procedure doesn't look like what I did the last time. Please tell me about Grub. I do think that Grub was involved.
asbak
Established Member
Posts: 897
Joined: Thu Sep 11, 2014 3:04 pm
Has thanked: 71 times
Been thanked: 64 times

Re: How do I enable real time?

Post by asbak »

There's nothing fancy involved although unfortunately there are many bizarre configuration guides floating around on the Interwebz.

- I'm assuming you would like to have decent low-latency audio performance on Linux. (Why anyone wouldn't and why people keep posting semi-official guides which insist on enabling sub-par performance is an on-going source of mystery to me.)
- For decent low-latency audio performance you need a PREEMPT or RT kernel already installed and booted.
- I'm assuming a clean OS installation here without pre-baked "distros", overlays and settings installed.
- Once you start pasting "distros" over your OS, goodness only knows what it will or won't change or screw up, something to keep in mind.
- Follow Tramp's configuration instructions.

My own limits.conf looks like this

Code: Select all

@audio - rtprio 90
@audio - memlock unlimited
username        soft    nofile           100000
username        hard    nofile           100000
- Disable pulseaudio from autospawning.
- Kill pulseaudio process.
- Ensure that pulseaudio stays dead before continuing.

- Start jackd with syntax along these lines (modify to suit your particular soundcard), you could optionally drop the -S switch:

Code: Select all

jackd -S -P89 -dalsa -r48000 -p64 -n3 -Xraw -D -Chw:U96k -Phw:U96k
Some Focal / 20.04 audio packages and resources https://midistudio.groups.io/g/linuxaudio
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: How do I enable real time?

Post by CrocoDuck »

Luc wrote:tramp's procedure doesn't look like what I did the last time. Please tell me about Grub. I do think that Grub was involved.
There is a software package called rtirq. It is not about enabling realtime, but about assigning higher irq to audio devices, in order to reduce the chances of interrupts along the hardware involved in your audio streams. The command you entered (ps ax | grep "\[irq") seems to me a method to assess the irq situation in your hardware. Basically, you want your audio devices having an high irq which isn't shared by other devices. rtirq offers an automatic way to do it.

I think you are on debian, so I am not too aware about how to install rtirq on your platform. On Arch, we install rtirq from AUR, then we enable its systemd service

Code: Select all

systemctl enable rtirq
You can check how the script is working with these two commands:

Code: Select all

systemctl status rtirq
/usr/bin/rtirq status
Which should return something like this if rtirq is working properly:

Code: Select all

● rtirq.service - Realtime IRQ thread system tuning
   Loaded: loaded (/usr/lib/systemd/system/rtirq.service; enabled; vendor preset: disabled
   Active: active (exited) since Sat 2017-09-30 09:32:54 BST; 51min ago
  Process: 852 ExecStart=/usr/bin/rtirq start (code=exited, status=0/SUCCESS)
 Main PID: 852 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/rtirq.service

Sep 30 09:32:54 arch systemd[1]: Starting Realtime IRQ thread system tuning...
Sep 30 09:32:54 arch rtirq[852]: Setting IRQ priorities: start [xhci] irq=45 pid=104 prio=
Sep 30 09:32:54 arch systemd[1]: Started Realtime IRQ thread system tuning.

Code: Select all

  PID CLS RTPRIO  NI PRI %CPU STAT COMMAND	
  104 FF      90   - 130  0.0 S    irq/45-xhci_hcd	
   43 FF      50   -  90  0.0 S    irq/9-acpi	
   63 FF      50   -  90  0.0 S    irq/42-PCIe PME	
   64 FF      50   -  90  0.0 S    irq/43-PCIe PME	
   65 FF      50   -  90  0.0 S    irq/44-PCIe PME	
   66 FF      50   -  90  0.0 S    irq/42-pciehp	
   68 FF      50   -  90  0.0 S    irq/8-rtc0	
   98 FF      50   -  90  0.0 S    irq/12-i8042	
   99 FF      50   -  90  0.0 S    irq/1-i8042	
  102 FF      50   -  90  0.0 S    irq/23-ehci_hcd	
  105 FF      50   -  90  0.0 S    irq/46-ahci[000	
  262 FF      50   -  90  0.0 S    irq/47-mei_me	
  266 FF      50   -  90  0.0 S    irq/18-i801_smb	
  284 FF      50   -  90  0.0 S    irq/49-iwlwifi	
  351 FF      50   -  90  0.0 S    irq/50-snd_hda_	
  359 FF      50   -  90  0.0 S    irq/51-i915	
  426 FF      50   -  90  0.0 S    irq/52-snd_hda_	
  559 FF      50   -  90  0.0 S    irq/48-enp2s0	
  285 FF      49   -  89  0.0 S    irq/49-s-iwlwif	
    3 TS       -   0  19  0.0 S    ksoftirqd/0	
   16 TS       -   0  19  0.0 S    ksoftirqd/1	
   22 TS       -   0  19  0.0 S    ksoftirqd/2	
   28 TS       -   0  19  0.0 S    ksoftirqd/3	
To ensure that rtirq works, you might need to boot your kernel with the threadirqs parameter. To do that, you need to edit /etc/default/grub, then add threadirqs to the GRUB_CMDLINE_LINUX_DEFAULT or GRUB_CMDLINE_LINUX options. I just add it to GRUB_CMDLINE_LINUX_DEFAULT. Then, regenerate grub.cfg:

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg
You can look at this for a discussion about fine tuning rtirq.
Post Reply