Skip to contentSkip to conversation

alsactl monitor spins at 100% cpu after unplugging USB headphones

DISCUSSION Thomas Gläßle 2 participants 3 messages Sep 30, 2018 – Oct 2, 2018

lore
Share & tools
lore
#0 lore raw

Hi,

on both my desktop and laptop (archlinux), alsactl monitor beginns spinning at 100% cpu when I unplug my USB headset. This happens every time and can be reproduced as follows:

- plug in USB headphones
- start alsactl monitor
- unplug headphones

It happens only if the headphones are already plugged in when starting alsactl.

The increased activity does not lead to spamming stdout or similar, alsactl continues to perform seemingly correct, i.e. reports when I change volume levels etc, but nothing apart from the ordinary.

I'm sorry if this is not the right place to report this issue or if the problem is already, I couldn't find anything about it.

Below is the output from alsa-info.sh:

with headphones:

http://www.alsa-project.org/db/?f=0dfc632e3adafb8bc78a182e0a225bcb13bea9fa

after unplugging:

http://www.alsa-project.org/db/?f=41dbf0735fdd7cd2416a6b4a602505715d25b44f

Please let me know if you need further info.

Best regards,
Thomas

#1 lore raw

Hi,

Quoted 8 lines · Thomas Gläßle

on both my desktop and laptop (archlinux), alsactl monitor beginns spinning at 100% cpu when I unplug my USB headset. This happens every time and can be reproduced as follows:

- plug in USB headphones
- start alsactl monitor
- unplug headphones

Quoted 6 lines

It happens only if the headphones are already plugged in when starting alsactl.

The increased activity does not lead to spamming stdout or similar, alsactl continues to perform seemingly correct, i.e. reports when I change volume levels etc, but nothing apart from the ordinary.

Thank you for this report and I can regenerate this problem.

$ strace alsactl monitor
...
(disconnect my sound device)
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}, {fd=4, events=POLLIN|POLLERR|POLLNVAL}, {fd=5, events=POLLIN|POLLERR|POLLNVAL}], 3, -1) = 1 ([{fd=5, revents=POLLERR|POLLNVAL}])
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}, {fd=4, events=POLLIN|POLLERR|POLLNVAL}, {fd=5, events=POLLIN|POLLERR|POLLNVAL}], 3, -1) = 1 ([{fd=5, revents=POLLERR|POLLNVAL}])
...

This is a bug of alsactl due to handling return code of poll(2) system call[1].

In an operation to ALSA control character devices, when handled device is disconnected, a call of poll(2) returns positive value to notify events with 'EPOLLERR | EPOLLNVAL'[2].

Soon I'll post a patch to improve this behaviour of alsactl.

Quoted 8 lines

I'm sorry if this is not the right place to report this issue or if the problem is already, I couldn't find anything about it.

Below is the output from alsa-info.sh:

with headphones:

Quoted 7 lines

http://www.alsa-project.org/db/?f=0dfc632e3adafb8bc78a182e0a225bcb13bea9fa

after unplugging:

http://www.alsa-project.org/db/?f=41dbf0735fdd7cd2416a6b4a602505715d25b44f

Please let me know if you need further info.

You did enough good. Thank you and wait for a while till I'll fix it.

[1] http://git.alsa-project.org/?p=alsa-utils.git;a=blob;f=alsactl/monitor.c;hb=HEAD#l120
[2] https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/sound/core/init.c?h=for-next#n347

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw

Takashi Sakamoto wrote on 10/2/18 11:01 AM:

Quoted 15 lines

Thank you for this report and I can regenerate this problem.

$ strace alsactl monitor
...
(disconnect my sound device)
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}, {fd=4,
events=POLLIN|POLLERR|POLLNVAL}, {fd=5,
events=POLLIN|POLLERR|POLLNVAL}], 3, -1) = 1 ([{fd=5,
revents=POLLERR|POLLNVAL}])
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}, {fd=4,
events=POLLIN|POLLERR|POLLNVAL}, {fd=5,
events=POLLIN|POLLERR|POLLNVAL}], 3, -1) = 1 ([{fd=5,
revents=POLLERR|POLLNVAL}])
...
Quoted 8 lines

This is a bug of alsactl due to handling return code of poll(2) system call[1].

In an operation to ALSA control character devices, when handled device is disconnected, a call of poll(2) returns positive value to notify events with 'EPOLLERR | EPOLLNVAL'[2].

Soon I'll post a patch to improve this behaviour of alsactl.

Thank you a lot, this is great news!

Cheers, Thomas

Quoted 32 lines
Quoted 12 lines

I'm sorry if this is not the right place to report this issue or if the problem is already, I couldn't find anything about it.

Below is the output from alsa-info.sh:

with headphones:

http://www.alsa-project.org/db/?f=0dfc632e3adafb8bc78a182e0a225bcb13bea9fa

Quoted 6 lines

after unplugging:

http://www.alsa-project.org/db/?f=41dbf0735fdd7cd2416a6b4a602505715d25b44f

Please let me know if you need further info.

You did enough good. Thank you and wait for a while till I'll fix it.

[1]
http://git.alsa-project.org/?p=alsa-utils.git;a=blob;f=alsactl/monitor.c;hb=HEAD#l120
[2]
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/sound/core/init.c?h=for-next#n347

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel