lpereira / hardinfo

System profiler and benchmark tool for Linux systems
http://hardinfo.org
GNU General Public License v2.0
771 stars 130 forks source link

USB Devices is extremally slow when reading bConfigurationValue files from sysfinfo #602

Open baryluk opened 3 years ago

baryluk commented 3 years ago

git master @ a72881a1d25b2b1ea7718c5e2f76b92ee43d8ef8

Linux 5.10.13

Clicking USB Devices shows no results, and hangs the process. 0% CPU usage. After few minutes it gets back to life.

It is stuck reading stuff from sysfs:

(gdb) bt
#0  __GI___libc_read (nbytes=4096, buf=0x5639da2269e0, fd=28) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=28, buf=0x5639da2269e0, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007f096318613f in g_file_get_contents () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00005639d91e7e63 in h_sysfs_read_string ()
#4  0x00005639d91e1887 in usb_get_device_sysfs ()
#5  0x00005639d91e1d5b in usb_get_device ()
#6  0x00005639d91e1fbf in usb_get_device_list_sysfs ()
#7  0x00005639d91e204e in usb_get_device_list ()
#8  0x00007f095f11a02b in __scan_usb () at /usr/local/lib/hardinfo/modules/devices.so
#9  0x00007f095f100811 in scan_usb () at /usr/local/lib/hardinfo/modules/devices.so
#10 0x00005639d91e7770 in module_entry_reload ()
#11 0x00005639d91fe131 in reload_section ()
#12 0x00007f096319c8f4 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x00007f096319bd6f in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007f096319c118 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007f096319c40b in g_main_loop_run () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007f09639b7b95 in gtk_main () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#17 0x00005639d91e5035 in main ()
(gdb) 
ls -lh /proc/$(pidof hardinfo)/fd/28
lr-x------ 1 user user 64 Feb 21 13:11 /proc/55961/fd/28 -> /sys/devices/pci0000:40/0000:40:07.1/0000:43:00.3/usb8/bConfigurationValue

Reading these files is slow:

user@debian:~/hardinfo$ time cat /sys/devices/pci0000:40/0000:40:07.1/0000:43:00.3/usb8/bConfigurationValue > /dev/null

real    0m3.375s
user    0m0.001s
sys 0m0.000s

Maybe show a progress bar, that something is happening?

Also the values are uncached, so any click, resize, scroll, etc, will re-read everything again.

Another good idea is to first read basic information, and display it, then asynchronously read extra information.

A simple lsusb on my machine takes usually less than 2 seconds, not minutes.

mckaygerhard commented 3 years ago

quite xtrange, i have linux 3.16 and 7 devices connected.. debian jessie and is quite faster.. ummm WELL maybe nos so faster.. taking screeenshot can noted something:

BUT noted that in linux 4.9 is MORE SLOWER and later in 5.X MORE MORE SLOWER so i guess is a problem of linux modern coding 😅😂

image

lpereira commented 3 years ago

It seems instantaneous here. That's curious because this should return values found by the kernel during USB enumeration, so it shouldn't take long to read them. I'm on 5.10.16 here, but never noticed anything strange in previous kernels. Maybe this is related to the USB controller you have? (I use a computer with an Intel controller, but have successfully used this in computers with other controllers as well, including some with a non-x86 processor.)

mckaygerhard commented 3 years ago

It seems instantaneous here. That's curious because this should return values found by the kernel during USB enumeration, so it shouldn't take long to read them. I'm on 5.10.16 here, but never noticed anything strange in previous kernels. Maybe this is related to the USB controller you have? (I use a computer with an Intel controller, but have successfully used this in computers with other controllers as well, including some with a non-x86 processor.)

hey, look! in my dell i7 of course is quite enought fast. . but foir others CPU and less power.. is xtremelly slow in recent linux kernels.. that-s why in my house i used always older software..

that is the situation:

cpu/kernel 3.X 4.X 5.X
semprom sufering suffering eternal slow
core duo sufering suffering eternal slow
dual core slow slower eternally slow
i3/i5 normal normal slow
i7/i9 fast fast fast
ryzen instantly fast fast