Long story cut short, I've settled on a KDE Neon install using the HWE 18-04 lowlatency kernel and the recently announced new KXStudio repo(s). Getting that 96kHz xrun-free sampling is proving a lot more difficult than back in 2014. Since then we've had SPECTRE, and the kernel devs have been beavering away at making cgroups completely incomprehensible to mere mortals.
The system is sat next to me at the moment, it's been running jack at 96000/256/3 with audacious playing an album on loop for a simple load. So far 3 Xruns in the last 2 hours. Good enough for recording, but not for live work since the xruns can be a second or so of silence. Yes, I still get Xruns without audacity running, albeit perhaps even less frequently. I'd prefer none, and I've no qualms about building an rt kernel - if I can put one together with any Ubuntu-specific tweaks the current lowlatency kernel includes. [Aside: I've tried booting off the AVLinux live ISO and still got Xruns with it].
Here's a rundown of the tuning process so far, documented fairly completely so it might be of use to others. Please highlight any obsolete/incorrect bits you might spot:
Kernel & /etc/defaults/grub:
Code: Select all
$ uname -a
Linux FT-Studio-M 5.0.0-32-lowlatency #34~18.04.2-Ubuntu SMP PREEMPT Thu Oct 10 11:22:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
# Transparent hugepage copied from AVLinux, isolcpus onward from Drumkit's post (see later)
GRUB_CMDLINE_DEFAULT="threadirqs transparent_hugepage=never noresume noquiet nosplash isolcpus=1-3 bohz_full=1-3 rcu_nocbs=1-3 nowatchdog acpi_irq_nobalance"
Code: Select all
$ perl ./realTimeConfigQuickScan.pl
== GUI-enabled checks ==
Checking if you are root... no - good
Checking filesystem 'noatime' parameter... 5.0.0 kernel - good
(relatime is default since 2.6.30)
Checking CPU Governors... CPU 0: 'performance' CPU 1: 'performance' CPU 2: 'performance' CPU 3: 'performance' - good
Checking swappiness... 10 - good
Checking for resource-intensive background processes... none found - good
Checking checking sysctl inotify max_user_watches... >= 524288 - good
Checking access to the high precision event timer... readable - good
Checking access to the real-time clock... readable - good
Checking whether you're in the 'audio' group... yes - good
Checking for multiple 'audio' groups... no - good
Checking the ability to prioritize processes with chrt... yes - good
Checking kernel support for high resolution timers... found - good
Kernel with Real-Time Preemption... not found - not good
Kernel without real-time capabilities found
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#installing_a_real-time_kernel
Checking if kernel system timer is high-resolution... found - good
Checking kernel support for tickless timer... found - good
== Other checks ==
Checking filesystem types... ok.
Checking for devices at IRQ 19... did not find multiple. ok.
Code: Select all
$ cat /etc/security/limits.d/audio.conf
# Provided by the jackd package.
#
# Changes to this file will be preserved.
#
# If you want to enable/disable realtime permissions, run
#
# dpkg-reconfigure -p high jackd
@audio - rtprio 95
@audio - memlock unlimited
#@audio - nice -19
Code: Select all
$ tail /etc/sysctl.conf
#
# Protects against creating or following links under certain conditions
# Debian kernels have both set to 1 (restricted)
# See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
#fs.protected_hardlinks=0
#fs.protected_symlinks=0
# Per quickscan requirements
vm.swappiness =10
fs.inotify.max_user_watches = 524288
# From Rosegarden tuning tip, may be obsolete
dev.hpet.max-user-freq=3072
Code: Select all
$ cat /etc/udev/rules.d/40-timer-permissions.rules
KERNEL=="rtc0", GROUP="audio"
KERNEL=="hpet", GROUP="audio"
## Read access is set up in rtirq script (details later in this post)
Code: Select all
$ tail -n24 /etc/default/rtirq
# RTIRQ_NAME_LIST="rtc snd usb i8042" # old
RTIRQ_NAME_LIST="snd usb i8042 rtc hci_rcd"
# Highest priority.
RTIRQ_PRIO_HIGH=90
# Priority decrease step.
RTIRQ_PRIO_DECR=5
# Lowest priority.
RTIRQ_PRIO_LOW=51
# 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"
Code: Select all
$ /etc/init.d/rtirq status
PID CLS RTPRIO NI PRI %CPU STAT COMMAND
546 FF 90 - 130 1.1 S irq/19-snd_ice1
609 FF 90 - 130 0.0 S irq/16-snd_ice1
150 FF 85 - 125 0.0 S irq/24-xhci_hcd
46 FF 50 - 90 0.0 S irq/9-acpi
151 FF 50 - 90 0.0 S irq/8-rtc0
255 FF 50 - 90 0.0 S irq/25-ahci[000
260 FF 50 - 90 0.0 S irq/27-i915
450 FF 50 - 90 0.0 S irq/28-mei_me
994 FF 50 - 90 0.0 S irq/26-enp2s0
9 TS - 0 19 0.1 S ksoftirqd/0
18 TS - 0 19 0.0 S ksoftirqd/1
24 TS - 0 19 0.0 S ksoftirqd/2
30 TS - 0 19 0.0 S ksoftirqd/3
Code: Select all
$ cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
0: 9 0 0 0 IO-APIC 2-edge timer
8: 0 0 0 1 IO-APIC 8-edge rtc0
9: 0 5 0 0 IO-APIC 9-fasteoi acpi
16: 0 0 0 0 IO-APIC 16-fasteoi snd_ice1712
19: 0 6647744 0 1 IO-APIC 19-fasteoi snd_ice1712
24: 497 16964 50 0 PCI-MSI 327680-edge xhci_hcd
25: 27651 0 0 0 PCI-MSI 512000-edge ahci[0000:00:1f.2]
26: 0 0 0 0 PCI-MSI 1048576-edge enp2s0
27: 303403 151 0 0 PCI-MSI 32768-edge i915
28: 0 0 20 0 PCI-MSI 360448-edge mei_me
NMI: 0 0 0 0 Non-maskable interrupts
LOC: 5250288 382908 7425 7395 Local timer interrupts
SPU: 0 0 0 0 Spurious interrupts
PMI: 0 0 0 0 Performance monitoring interrupts
IWI: 73 0 0 0 IRQ work interrupts
RTR: 0 0 0 0 APIC ICR read retries
RES: 1005288 5 0 0 Rescheduling interrupts
CAL: 0 12038 12038 12036 Function call interrupts
TLB: 0 0 0 0 TLB shootdowns
TRM: 0 0 0 0 Thermal event interrupts
THR: 0 0 0 0 Threshold APIC interrupts
DFR: 0 0 0 0 Deferred Error APIC interrupts
MCE: 0 0 0 0 Machine check exceptions
MCP: 31 32 32 32 Machine check polls
HYP: 0 0 0 0 Hypervisor callback interrupts
HRE: 0 0 0 0 Hyper-V reenlightenment interrupts
HVS: 0 0 0 0 Hyper-V stimer0 interrupts
ERR: 0
MIS: 0
PIN: 0 0 0 0 Posted-interrupt notification event
NPI: 0 0 0 0 Nested posted-interrupt event
PIW: 0 0 0 0 Posted-interrupt wakeup event
Code: Select all
$ lspci -v
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
Subsystem: Gigabyte Technology Co., Ltd 4th Gen Core Processor DRAM Controller
Flags: bus master, fast devsel, latency 0
Capabilities: <access denied>
Kernel driver in use: hsw_uncore
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])
Subsystem: Gigabyte Technology Co., Ltd Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller
Flags: bus master, fast devsel, latency 0, IRQ 27
Memory at f7800000 (64-bit, non-prefetchable) [size=4M]
Memory at e0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000 [size=64]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: <access denied>
Kernel driver in use: i915
Kernel modules: i915
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
Subsystem: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller
Flags: bus master, fast devsel, latency 0, IRQ 11
Memory at f7d10000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel modules: snd_hda_intel
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
Subsystem: Gigabyte Technology Co., Ltd 8 Series/C220 Series Chipset Family USB xHCI
Flags: bus master, medium devsel, latency 0, IRQ 24
Memory at f7d00000 (64-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: xhci_hcd
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
Subsystem: Gigabyte Technology Co., Ltd 8 Series/C220 Series Chipset Family MEI Controller
Flags: bus master, fast devsel, latency 0, IRQ 28
Memory at f7d19000 (64-bit, non-prefetchable) [size=16]
Capabilities: <access denied>
Kernel driver in use: mei_me
Kernel modules: mei_me
00:16.3 Serial controller: Intel Corporation 8 Series/C220 Series Chipset Family KT Controller (rev 04) (prog-if 02 [16550])
Subsystem: Gigabyte Technology Co., Ltd 8 Series/C220 Series Chipset Family KT Controller
Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 19
I/O ports at f0c0 [size=8]
Memory at f7d17000 (32-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: serial
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 16
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
Capabilities: <access denied>
Kernel driver in use: pcieport
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 18
Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
I/O behind bridge: 0000e000-0000efff
Memory behind bridge: f7c00000-f7cfffff
Prefetchable memory behind bridge: 00000000f0000000-00000000f00fffff
Capabilities: <access denied>
Kernel driver in use: pcieport
00:1c.3 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d5) (prog-if 01 [Subtractive decode])
Flags: bus master, fast devsel, latency 0, IRQ 19
Bus: primary=00, secondary=03, subordinate=04, sec-latency=0
I/O behind bridge: 0000d000-0000dfff
Capabilities: <access denied>
00:1f.0 ISA bridge: Intel Corporation H87 Express LPC Controller (rev 05)
Subsystem: Gigabyte Technology Co., Ltd H87 Express LPC Controller
Flags: bus master, medium devsel, latency 0
Capabilities: <access denied>
Kernel driver in use: lpc_ich
Kernel modules: lpc_ich
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05) (prog-if 01 [AHCI 1.0])
Subsystem: Gigabyte Technology Co., Ltd 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 25
I/O ports at f0b0 [size=8]
I/O ports at f0a0 [size=4]
I/O ports at f090 [size=8]
I/O ports at f080 [size=4]
I/O ports at f060 [size=32]
Memory at f7d16000 (32-bit, non-prefetchable) [size=2K]
Capabilities: <access denied>
Kernel driver in use: ahci
Kernel modules: ahci
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
Subsystem: Gigabyte Technology Co., Ltd 8 Series/C220 Series Chipset Family SMBus Controller
Flags: medium devsel, IRQ 5
Memory at f7d15000 (64-bit, non-prefetchable) [disabled] [size=256]
I/O ports at f040 [size=32]
Kernel modules: i2c_i801
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
Subsystem: Gigabyte Technology Co., Ltd Onboard Ethernet
Flags: bus master, fast devsel, latency 0, IRQ 18
I/O ports at e000 [size=256]
Memory at f7c00000 (64-bit, non-prefetchable) [size=4K]
Memory at f0000000 (64-bit, prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: r8169
Kernel modules: r8169
03:00.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 41) (prog-if 01 [Subtractive decode])
Flags: bus master, fast devsel, latency 0, IRQ 19
Bus: primary=03, secondary=04, subordinate=04, sec-latency=32
I/O behind bridge: 0000d000-0000dfff
Capabilities: <access denied>
04:00.0 Multimedia audio controller: VIA Technologies Inc. ICE1712 [Envy24] PCI Multi-Channel I/O Controller (rev 02)
Subsystem: Roland Corp. Edirol DA-2496
Flags: bus master, medium devsel, latency 32, IRQ 19
I/O ports at d0a0 [size=32]
I/O ports at d0f0 [size=16]
I/O ports at d0e0 [size=16]
I/O ports at d040 [size=64]
Capabilities: <access denied>
Kernel driver in use: snd_ice1712
Kernel modules: snd_ice1712
04:01.0 Multimedia audio controller: VIA Technologies Inc. ICE1712 [Envy24] PCI Multi-Channel I/O Controller (rev 02)
Subsystem: Roland Corp. Edirol DA-2496
Flags: bus master, medium devsel, latency 32, IRQ 16
I/O ports at d080 [size=32]
I/O ports at d0d0 [size=16]
I/O ports at d0c0 [size=16]
I/O ports at d000 [size=64]
Capabilities: <access denied>
Kernel driver in use: snd_ice1712
Kernel modules: snd_ice1712
Code: Select all
$ jackd -P90 -v -S -ch -dalsa -dhw:DA2496,0 -zs -M -H -p256 -r96000 -n3
Even with all that, I'd periodic Xruns still annoying me - far more frequently than now. But, I found obscura related to cgroups. What's on jackaudio.org baffles me, and seems to relate to cgroups1 whereas the current is cgroups2.
This post from Drumfix has helped a lot. However, if I disable rt throttling the system will sometimes lock up. All I'm doing just now is making sure the IRQs for the soundcards are off Core 0.
I've done this in /etc/init.d/rtirq, which I've a suspicion might be the ideal place to deal with this for most people. Here are the added bits to tweak CPU affinity:
Code: Select all
## Disable RT throttling - causes hangs
#echo -1 >/proc/sys/kernel/sched_rt_runtime_us
## ICE cards to core 1
echo 2 >/proc/irq/16/smp_affinity
echo 2 >/proc/irq/19/smp_affinity
## xhci_hcd to core 1
echo 2 >/proc/irq/24/smp_affinity
## Force disk handling to core 0
echo 1 >/proc/irq/25/smp_affinity
## Force i915 (Intel graphics) to core 0
echo 1 >/proc/irq/27/smp_affinity
## Timer frequency/readable RTC clock
echo 3072 >/sys/class/rtc/rtc0/ma_user_freq
chmod 660 /dev/hpet /dev/rtc0
Last bit of data for troubleshooting - a couple of sample Xruns:
Code: Select all
[...]
Tue Nov 12 12:38:55 2019: Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 14
Tue Nov 12 12:38:59 2019: Jack: **** alsa_pcm: xrun of at least -6689945.088 msecs
Tue Nov 12 12:38:59 2019: Jack: ALSA XRun wait_status = 0
Tue Nov 12 12:38:59 2019: Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 13
Tue Nov 12 12:38:59 2019: Jack: JackRequest::Notification
Tue Nov 12 12:38:59 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
Tue Nov 12 12:38:59 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
Tue Nov 12 12:38:59 2019: Jack: JackClient::ClientNotify ref = 2 name = dbusapi notify = 3
Tue Nov 12 12:38:59 2019: Jack: JackClient::kXRunCallback
Tue Nov 12 12:38:59 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
[...]
Tue Nov 12 13:03:20 2019: Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 14
Tue Nov 12 13:03:23 2019: Jack: **** alsa_pcm: xrun of at least -8153522.176 msecs
Tue Nov 12 13:03:23 2019: Jack: ALSA XRun wait_status = 0
Tue Nov 12 13:03:23 2019: Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 13
Tue Nov 12 13:03:23 2019: Jack: JackRequest::Notification
Tue Nov 12 13:03:23 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
Tue Nov 12 13:03:23 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
Tue Nov 12 13:03:23 2019: Jack: JackClient::ClientNotify ref = 2 name = dbusapi notify = 3
Tue Nov 12 13:03:23 2019: Jack: JackClient::kXRunCallback
Tue Nov 12 13:03:23 2019: Jack: JackEngine::ClientNotify: no callback for notification = 3
Tue Nov 12 13:03:23 2019: Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 14
[...]