You are not logged in.

#1 2020-06-07 22:18:40

drdee
Member
Registered: 2020-06-07
Posts: 1

High cpu usage from xhci_hc when using USB soundcard

Hello
i don't know why, but when using my usb soundcard cpu usage spikes alot. `iotop` always shows `[irq/131-xhci_hc]` as a running process using around 10% cpu costantly. I've also checked `/proc/interrupts`, and that particular irq (131) is always handled by a single cpu

Here's the output of `cat /proc/interrupts`
https://pastebin.com/cXQBXXNv

The strange thing is, i'm running the realtime kernel, and the rtirq service. I use ALSA+Pulseaudio, and i've already tried fully setting up jack with no results. I've also followed the entire article https://wiki.archlinux.org/index.php/Professional_audio where applicable. I tried disabling usb autosuspend from the kernel, and tlp.
I've also noticed that sometimes the usb card "crashes", and dmesg outputs an error message (here's the `journactl -k`, look at 18:05)
https://pastebin.com/XQA2qbjL

`lspci -v` output:
https://pastebin.com/ttHTxm0a

`lsusb -v` output:
https://pastebin.com/SD75w1ia

The usb soundcard i use is a Focusrite Scarlett 2i2, my bios is up to date

Has anyone ever had the same problem before?

Offline

#2 2020-06-13 09:45:49

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

Hi,

I have the same problem with Topping D10. I tried various kernels, including 5.7, removed pulseaudio to test on alsa directly, disabled autosuspend on usb, etc... but nothing helped.
The observation is that during playback, the device is generating roughly 9000 interrupts causing CPU to work at max frequency. All works fine under Windows 10.
No idea what to do next in order to troubleshoot. Any help would be much appreciated.

Offline

#3 2020-06-14 08:55:54

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

I think I am getting closer to the root cause of the issue. Strongly believe it stems from very small buffer and period size set for the card. If I connected my DAC to another laptop, older spec, but still USB 3.0 / high-speed, running Ubuntu 20.04 (from livecd), it worked very well w/o putting any load on the system. Interestingly, the number of interrupts was similar - between 8k-9k, but as I said - the system was idle, cpu at low freq, etc..

Arch:

# cat /proc/asound/D10/pcm0p/sub0/hw_params 
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 16384

Ubuntu:

# cat /proc/asound/D10/pcm0p/sub0/hw_params 
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 44100
buffer_size: 88200

Offline

#4 2020-06-14 10:51:55

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

Unfortunately I was wrong, PulseAudio increases the buffers, but it doesn't have any impact on CPU load.

UPDATE: I booted the same Ubuntu from LiveCD and unfortunately the problem still persist so it must be related to this specific hardware (Thinkpad P1). sad

Last edited by ellukes1234 (2020-06-14 12:47:54)

Offline

#5 2020-06-14 17:20:36

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: High cpu usage from xhci_hc when using USB soundcard

I see (or saw) the same problem here with a "Sabaj D3" DAC. The DAC produces 2000 interrupts per second. I looked at "watch -n10 cat /proc/interrupts" to get the 2000 Hz number.

I've seen the CPU usage problem show up differently on different PC hardware. On an older Ivy Bridge generation system the CPU usage is serious, on a newer Ryzen system it's not really a problem.

The old and new hardware I compared is first an Intel i5-3570K CPU overclocked to 4.6GHz and second a R7 2700X CPU. The raw performance of single CPU cores is pretty similar between the two systems. On the Ivy Bridge system the DAC goes through the "EHCI" controller of the chipset, not the XHCI controller. The Ryzen system only has XHCI controllers so the DAC has to go through that. I was blaming this EHCI vs. XHCI difference for the different CPU usage but I guess that can't be right?

I can't quite remember the CPU usage on the i5-3570K system. It was definitely more then 15% but I can't say how high it was exactly. On the new system it's around 1% CPU usage.

I couldn't find a way to reduce the CPU usage. The Sabaj D3 DAC has SPDIF input and the motherboard has SPDIF out, so I use it without going through USB.

The problem showed up for me in both Linux and Windows.

Offline

#6 2020-06-14 18:12:30

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

The results between Thinkpad P1 i7-8750 and Thinkpad T430 i5-3320 were completely different, specifically:

>> INTERRUPTS
  * P1 and T430 - same number, single core handling it, rtkit-daemon/irqbalance - have no impact

>> CPU load
  * P1 and T430 - very low - <5%, at least no extra load other than X11/browser

>> CPU frequency
  * P1: turbo mode all the time (~4Ghz)
  * T430: idle, ~800-1200Mhz

>> Temperature
  * P1: very hot, fans maxed out
  * T430: normal/cold, zero/minimum fan noise

There was no difference between XHCI and EHCI on T430.

Surprisingly - P1 works super well under Windows 10, so... leaning toward it's driver problem or some incompatibility, anyway windows deals with it better.

At the moment I disabled Turbo mode, so my CPU work at 2.2Ghz all the time, but this is acceptable in terms of temperatures (42C) and fan noise (level 0-1).

I am just wondering how to take it forward - is it CPU (intel_pstate?) or USB or something else, LKML?

Offline

#7 2020-06-14 19:00:34

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: High cpu usage from xhci_hc when using USB soundcard

Maybe it's a hardware problem, but the driver has influence over it? Perhaps there's a setting in the hardware that causes this, and the Windows driver and the Linux driver set the hardware up differently. If that's the problem, maybe there's something you can tweak in kernel module parameters or in /sys somewhere.

About irqbalance, I found out irqbalance is not needed anymore today. In the past, the kernel would put all interrupts onto CPU 0. Nowadays the kernel distributes the interrupts over all CPUs. I would remove irqbalance because it might clash with what the kernel tries is doing.

If you think it's intel_pstate causing it, you can try disabling it. You put this onto the kernel command line:

intel_pstate=disable

The system will then use the "acpi_cpufreq" module to set the CPU MHz. That acpi_cpufreq module has two different "frequency governors" that are interesting for you: "schedutil" and "ondemand". In my experience the ondemand one is less aggressive about ramping up MHz. The schedutil one is wired into the task scheduler and will react faster to load. To tweak this, there's a package "cpupower" with a command "cpupower". You can switch things around live like this from the command line:

sudo cpupower frequency-info   # <-- use this to check on current settings

sudo cpupower frequency-set -g ondemand
sudo cpupower frequency-set -g schedutil

And to apply certain settings at boot, there's a service "cpupower.service" you can enable that will load its settings from a config file "/etc/default/cpupower".

Offline

#8 2020-06-27 08:41:23

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

Disabling "intel_pstate" helped to keep CPU less busy. Temperatures are much better and as a result fans are not noisy anymore. However it can still be observed that even simple speaker-test puts some load on CPU. For instance, i7-8750H (2.2Ghz max, 4Ghz turbo) with pstate enabled and music playing stays at 4Ghz all the time. After disabling pstate, CPU is at ~1.5Ghz, sometimes spikes to 2.2Ghz but rarely. The caveat of disabled pstate is bigger power usage when in sleep mode. On a positive side ondemand governor seems to cause less CPU spikes and less use of turbo boost mode.

Offline

#9 2020-09-04 19:53:23

gmas
Member
Registered: 2013-06-17
Posts: 4

Re: High cpu usage from xhci_hc when using USB soundcard

I'm having the same issues while playing music through a JDS Atom DAC on a Lenovo Carbon X1 Gen 7.
Watching "/proc/interrupts" I'm seeing this particular interrupt fire at a rate of 8k/s:

 138:          0          0          0          0          0          0          0   11939119  IR-PCI-MSI 327680-edge      xhci_hcd

I haven't tried disabling "intel_pstate" yet but switching to the Linux-Ck kernel seems to help keep the CPU cores at reasonable frequencies instead of letting them max out at 4.2GHz, even though one (always the 7th) the cores still spends ~95% in the C1 state. This effectively lowers CPU temps from 51C to 47C on an otherwise mostly idle system.

%Cpu(s):  3.1 us,  0.6 sy,  0.0 ni, 95.1 id,  0.0 wa,  0.8 hi,  0.4 si,  0.0 st

Offline

#10 2020-12-18 05:49:55

gmas
Member
Registered: 2013-06-17
Posts: 4

Re: High cpu usage from xhci_hc when using USB soundcard

I accidentally stumbled upon a solution: adding

cpuidle.governor=teo

to the boot cmdline (linux-ck-skylake kernel) keeps CPU core frequencies low when using the USB audio device, thus lowering temps by 8C at idle.

Offline

#11 2020-12-19 15:24:49

ellukes1234
Member
Registered: 2020-06-13
Posts: 6

Re: High cpu usage from xhci_hc when using USB soundcard

gmas wrote:

I accidentally stumbled upon a solution: adding

cpuidle.governor=teo

to the boot cmdline (linux-ck-skylake kernel) keeps CPU core frequencies low when using the USB audio device, thus lowering temps by 8C at idle.

Many thanks for sharing!
It also helped in my setup. Amazing!!!

Offline

Board footer

Powered by FluxBB