DanielOgorchock / joycond

userspace daemon to combine joy-cons from the hid-nintendo kernel driver
GNU General Public License v3.0
371 stars 70 forks source link

Using 100% of a CPU core doing epoll_pwait #153

Open Apteryks opened 1 month ago

Apteryks commented 1 month ago

Hi,

I'm using the latest commit of this repository, and after a while the joycond process starts using 100% of a CPU (perhaps when the Nintendo Switch Pro controller goes to sleep?). strace reports:

# LANG=C strace -f -s600 -p22798
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2
read(5, 0x3cf51240, 6144)               = -1 ENODEV (No such device)
read(15, 0x3cf58bb0, 6144)              = -1 ENODEV (No such device)
epoll_pwait(3, [{events=EPOLLERR|EPOLLHUP, data={u32=5, u64=5}}, {events=EPOLLERR|EPOLLHUP, data={u32=15, u64=15}}], 10, 500, NULL, 8) = 2

Any idea?

Apteryks commented 1 month ago

The issue appears to be resolved by reverting from 9d1f5098b716681d087cca695ad714218a18d4e8 to f9a66914622514c13997c2bf7ec20fa98e9dfc1d, so it appears to be a very recent regression.

Apteryks commented 1 month ago

The culprit appears to be: cdec32865c6093bd4761326ea461aaa2fcf7d1b4.

My rough test case: start problematic joycond. Press right arrow on Switch Pro or other buttons to have the front LEDs flashing. Press both L and R to have it assigned as controller 1 (leftmost front LED is stable lit.)

Start RetroArch with bsnes-jg core, play a bit. Close emulator. Press button on the back of the switch pro controller to disconnect.

Now press buttons on the controller to wake it up; it'll struggle to establish the link, and eventually will succeed but the joycond daemon will peak at 100% CPU usage.

I think cdec32865c6093bd4761326ea461aaa2fcf7d1b4 should probably be reverted unless the underlying issue can be understood and resolved.