How to lower polling rate of Logitech MX518 mouse under Linux?

0

I am running Arch Linux and have an issue with my mouse (Logitech MX518 Gaming mouse). I would like to lower its polling rate. Right now, it is polling every single ms, which causes higher CPU usage in most applications, and is a bit of overkill for my use case. I've established the polling rate is 1ms, by analyzing the output of cat /sys/kernel/debug/usb/devices:

T:  Bus=02 Lev=04 Prnt=09 Port=02 Cnt=02 Dev#= 11 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=046d ProdID=c08e Rev=40.00
S:  Manufacturer=Logitech
S:  Product=MX518 Gaming Mouse
S:  SerialNumber=0C6338513038
C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=300mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=1ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
E:  Ad=82(I) Atr=03(Int.) MxPS=  20 Ivl=1ms

In particular, Ivl=1ms shows it is polling every ms, also verified using evhz, a tool that can report the polling rate of a mouse. I have modified the kernel parameters to set a fixed mouse polling rate, by adding usbhid.mousepoll=8. Indeed, after rebooting, it seems the driver parameter is correctly set:

$ systool -m usbhid -A mousepoll
Module = "usbhid"

    mousepoll           = "8"

Before, mousepoll was set to 0, which means 'automatic', and 8 should mean poll every 8ms, which is the same as the poll rate of my old mouse. However, the mouse is still polling every ms; evhz shows a pollling frequency of 1000Hz, and the output of cat /sys/kernel/debug/usb/devices is the same as before. In other words setting the kernel parameter did not have any effect.

Is there something I am missing here? How can I lower the polling rate of my mouse?

Ton van den Heuvel

Posted 2019-10-02T11:21:26.997

Reputation: 3 316

I am very suspicious about the claim that the USB hardware polling interval causes higher CPU usage in most applications. First thing I'd to is to verify that claim by measuring CPU usage with and without the mouse plugged in. That said, the first place to look if usbhid is encountering any errors when trying to set the polling interval (for example, because the mouse only supports 1ms) is dmesg. – dirkt – 2019-10-03T06:31:16.427

@dirkt, I have verified it. In the end I managed to reduce the polling frequency to 125Hz by modifying the mouse settings under Windows. Apparently these settings are stored in the mouse. Now, moving the mouse over a Firefox window without doing anything else 'only' causes 20% CPU usage, whereas it was ~50% before. – Ton van den Heuvel – 2019-10-03T09:22:47.820

If it really increases CPU usage, please also check out the following: Start xev, move the mouse into the window (you should see motion events), take your hands off the mouse. Try this several times in different positions. If you continue to see events even with your hands off the mouse, then this is what is causing the increased usage. – dirkt – 2019-10-03T11:17:20.947

Answers

1

Thanks to the users on the Arch forum for the following answer.

I was able to modify some of the mouse settings (in particular DPI) using Piper, which is a frontend for libratbag which does support the MX518. Even though Piper gives the option to modify the polling frequency (between 500Hz and 1000Hz), toggling that setting does not have any effect.

In the end, I had to hook up the mouse to a Windows, and use Logitech's software to change the polling frequency to 125Hz. Now, using the mouse under Linux, evhz also reports a polling frequency of 125Hz for the mouse. Apparently, some of these settings are directly stored inside the mouse itself...

Ton van den Heuvel

Posted 2019-10-02T11:21:26.997

Reputation: 3 316