I recompiled libusb with debug symbols:
Normal CPU:
Thread 5 (Thread 0x7f0238fcb700 (LWP 24364)):
#0 0x00007f02394dfb6d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007f0238fdbafc in poll (__timeout=-1, __nfds=2,
__fds=0x7f0238fcaee0)
at /usr/include/x86_64-linux-gnu/bits/poll2.h:46
#2 linux_udev_event_thread_main (arg=<optimized out>)
at ../../libusb/os/linux_udev.c:175
#3 0x00007f02397ab284 in start_thread (arg=0x7f0238fcb700)
at pthread_create.c:333
#4 0x00007f02394e8a4d in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
100% CPU:
Thread 5 (Thread 0x7fbeac2a4700 (LWP 24181)):
#0 0x00007fbeaca8cbdd in recvmsg () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007fbead2806ec in udev_monitor_receive_device ()
from /lib/x86_64-linux-gnu/libudev.so.1
#2 0x00007fbeac2b4b8b in linux_udev_event_thread_main (arg=<optimized out>)
at ../../libusb/os/linux_udev.c:186
#3 0x00007fbeaca84284 in start_thread (arg=0x7fbeac2a4700)
at pthread_create.c:333
#4 0x00007fbeac7c1a4d in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
So the diff happens in that code from libusb/os/linux_udev.c:
usbi_dbg("udev event thread entering.");
while (poll(fds, 2, -1) >= 0) {
if (fds[0].revents & POLLIN) {
r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy));
if (r <= 0) {
usbi_warn(NULL, "udev control pipe read failed");
}
break;
}
if (fds[1].revents & POLLIN) {
usbi_mutex_static_lock(&linux_hotplug_lock);
udev_dev = udev_monitor_receive_device(udev_monitor);
if (udev_dev)
udev_hotplug_event(udev_dev);
usbi_mutex_static_unlock(&linux_hotplug_lock);
}
}
usbi_dbg("udev event thread exiting");
I added error msgs in the loop.
When 100% CPU, the poll() is non-blocking and the loop becomes a busy loop.
On 03/06/2016 11:49 PM, Philippe Teuwen wrote:
> #0 0x00007f196a6cabdd in recvmsg () at ../sysdeps/unix/syscall-template.S:81
> #1 0x00007f196aebe6ec in udev_monitor_receive_device () from
> /lib/x86_64-linux-gnu/libudev.so.1
> #2 0x00007f1969ef2bcb in ?? () from /lib/x86_64-linux-gnu/libusb-1.0.so.0
> #3 0x00007f196a6c2284 in start_thread (arg=0x7f1969ee2700) at
> pthread_create.c:333
> #4 0x00007f196a3ffa4d in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:109