在Manjaro使用6.14以下内核版本+pipwire1.4.1及以下版本(已知存在问题的版本) 会出现因为声卡snd-seq模块导致的单核cpu使用率100%,导致笔记本耗电严重。
sy列很高,用strace跟踪下系统调用发现大量的epoll_wait
perf record -F 99 -p 1323 -g -- sleep 30
后打印火焰图,也是epoll_wait,虽然打印热点函数也是epoll_wait,但看函数栈似乎看不出啥,毕竟不熟悉pipewire。
strace -p 1323
显示大量的epoll_wait描述符都是5
通过lsof 看下5这个描述符是干啥的,注意0,14设备是一个是 匿名 inode
可以看到fd=5的epoll等待了一堆fd
用 lsof -p 1323|grep -E '\b(3|4|6|7|8|11|18|20|21|23|25|26|27|34|35|36|37|38|39|54)u\b'
列出所有等待事件的fd,其中只有fd=54的代表音频设备/dev/snd/seq,并且是一个字符类型的设备
在 Arch Linux 系统中,/dev/snd/seq 是 ALSA(Advanced Linux Sound Architecture)音频子系统提供的字符设备文件,专用于 MIDI(Musical Instrument Digital Interface)音序器功能。
在网上找到了社区的一篇bug反馈,可供参考https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4621 这里也阐述了该字符设备引起的cpu 100%的bug。
解决方案:
snd-seq模块驱动加黑名单,不影响正常音频播放。
#编辑 /etc/modprobe.d/blacklist-snd-seq.conf
blacklist snd_seq
blacklist snd_seq_dummy
blacklist snd_seq_device
install snd_seq /bin/true
重启后一切正常