mborjesson / USB-Mouse-to-Serial

Connect a USB mouse to your retro computer using a Raspberry Pi
GNU General Public License v2.0
46 stars 3 forks source link

100% CPU usage on a raspberry pi 2b #1

Closed acmelab68 closed 5 years ago

acmelab68 commented 6 years ago

Hello,

first of all, thank you very much for this really great tool. I'm using it on a everyday basis and wonder why this tool isn't more common and popular, since this is the first out of the box working solution without massive prerequisites or other requirements. All is working fine and I don't have any real issues. The only think I recognized is a constantly high CPU load (100% on one CPU core) on my raspberry pi - model 2b. It doesn't matter if running as a daemon or console, with or without verbosity. The console messages looks pretty normal, too.

here are my specs:

$ uname -a
Linux raspify 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux

$ cat /proc/device-tree/model
Raspberry Pi 2 Model B Rev 1.1

$ cat /sys/module/usbhid/parameters/mousepoll
1

$ ps -ef | grep usb
root      1046     1 85 17:46 ?        03:36:44 usb_mouse_to_serial --output /dev/ttyUSB0 -v -p mousesystems --daemon -s

$ top
top - 22:06:45 up  4:21,  3 users,  load average: 1.03, 1.02, 1.00
Tasks: 114 total,   1 running,  75 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.4 us,  0.4 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.3 us,  0.7 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  : 40.6 us, 59.4 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    949460 total,   224900 used,   724560 free,    18952 buffers
KiB Swap:   102396 total,        0 used,   102396 free.   126232 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                   
 1046 root      20   0   21616    128     16 S 100.5  0.0 223:22.36 usb_mouse_to_se                                                                           
 1833 pi        20   0    5108   2540   2148 R   1.0  0.3   0:00.38 top                                                                                       
    1 root      20   0    5508   4000   2792 S   0.0  0.4   0:04.20 systemd                                                                                   
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd                                                                                  
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H                                                                              
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq                                                                              
    7 root      20   0       0      0      0 S   0.0  0.0   0:00.24 ksoftirqd/0                                                                               
    8 root      20   0       0      0      0 I   0.0  0.0   0:04.15 rcu_sched                                                                                 
    9 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh                                                                                    
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 migration/0                                                                               
   11 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0                                                                                   
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1                                                                                   
   13 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/1                                                                               
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.35 ksoftirqd/1                                                                               
   16 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0H                                                                              
   17 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2                                                                                   
   18 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 migration/2                                                                               
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.01 ksoftirqd/2                                                                               
   21 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/2:0H                                                                              
   22 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/3                                                                                   
   23 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 migration/3                                                                               
   24 root      20   0       0      0      0 S   0.0  0.0   0:00.01 ksoftirqd/3                                                                               
   26 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/3:0H           

I've followed you're build instructions and didn't incounter any issue on my why.

mborjesson commented 6 years ago

Hi!

Thank you, you're welcome! Yeah I use it every day as well when gaming on my retro PCs, so much better than the old serial mices :)

Ah, I noticed the issue as well while developing but I completely forgot to look into it, thanks for reporting it! I've made a fix which I'm testing right now. It looks good so far and if it continues to do so I'll commit it in an hour or so.

mborjesson commented 6 years ago

I just pushed the fix, please try it and see if it works as expected.

acmelab68 commented 6 years ago

OK - the load ranges now from 0.3 to 0.7%. Where 0.3% --> idle and 0.7% --> when mouse is being moved. Thank you very much for this very quick and nice fix!

mborjesson commented 6 years ago

That's great! You're welcome! :)

acmelab68 commented 6 years ago

Hello :) I had time to test the new patch on my old DOS6.22 installation more thoroughly now. It's working - but... : The mouse freezes after approx. 5sec. I have to press a mouse button to make it work again. I don't know if the "-s" aka suspend switch is relatet or not, but no matter what I choose, the behaviour doesn't change. Is this intended to work now like this?

The hardware/programs I used to test it:

acmelab68 commented 6 years ago

Strange - I've tried out the previous version again and the mouse showed the same behaviour - it also just stop reacting after five seconds. Then I've rebooted the Raspberry and now everything is back to normal.

mborjesson commented 6 years ago

Hi! Sorry for the late reply, I've been travelling.

Hmm it sounds as the mouse may have ended up stuck in the suspended mode somehow. If it happens a reboot should always fix the issue. If it starts to happen regularly it might be an issue with the mouse and autosuspend :(