USB mouse polling rates under Linux

October 29, 2015

I'm behind the times, so I only recently discovered that USB mice have a polling rate, that this polling rate can often be adjusted under Linux, and that you might want to do so. A good starting point for this is the Arch Linux wiki page on mouse polling rate, but it assumes some basic background that I had to think through.

The advantage of a higher mouse polling rate is not that your mouse moves any faster. Instead, it is that the mouse reports your motion changes sooner (what I think gamers are interested in) and that it reports them more frequently. More frequent reporting usually means more frequent updating, which in turn can lead to smoother, more continuous motion. On the other side, too-slow updates can make mouse motion feel subtly jerky.

(Mouse movement under X is generally already accelerated to some degree once you move the mouse far enough. See at least xset's mouse settings and probably the preferences for your desktop environment if you use one.)

If what you mostly care about is smooth motion, I think that there's not much benefit to a mouse polling rate that is massively above the refresh rate of your display. After all, updating the mouse cursor position 500 times a second is relatively pointless if you only see it 60 times a second. At the same time, a relatively high polling rate has the advantage that it gives X and programs a lot of time to respond to your mouse movement before the next display update, rather than perhaps only getting the position update at the last moment.

The Arch page is a little bit confusing about the normal default Linux mouse polling rate. Based on looking at the kernel source, how it appears to work is that USB mice can tell us their desired polling rate and by default the kernel just accepts that. The normal USB mouse rate is 125 Hertz, so most USB mice are going to tell the kernel to use that; however, I believe some mice can be (or are) set to ask for a higher polling rate, and if they do the kernel will honour that by default.

(Your LCD panel likely refreshes at a nominal 60 Hz rate, so I'd expect that 125 Hz provides plenty of responsiveness headroom; still, increasing the polling rate is unlikely to hurt.)

As covered in the Arch page, it's possible to explicitly set the Linux mouse polling rate and thus increase it from 125 Hertz. This is done by setting a non-zero value for the usbhid module's mousepoll module parameter (see the Arch page for what values you want). The Arch page describes an elaborate procedure to change the mousepoll parameter without rebooting, which is fortunately not necessary these days as kernel modules expose their module parameters in /sys/module/<NAME>/parameters. To change and test mouse polling rates on the fly, you first write the new mousepoll value with:

echo N >/sys/module/usbhid/parameters/mousepoll

and then unplug and replug your USB mouse (or mice). The unplug and replug bit is necessary because the usbhid module only sets up the mouse polling interval for a specific USB mouse when the mouse is plugged in. Changing mousepoll thus only changes the polling rate for future mice, not currently attached ones.

(A mousepoll value of 0 means 'use whatever the mouse would like', which is probably mostly going to be '125 Hertz'. Note that this implies that setting an explicit conservative mousepoll value may cause some USB mice to be polled at a lower rate than you'd get if you just left things alone.)

What you've set Linux's mouse polling rate to is not necessarily the polling rate that you actually get, for various reasons. You can see what the actual achieved rate is using the useful evhz program, which measures the rate based on how fast it receives evdev events. This isn't restricted to just USB mice; it will also reports values for PS/2 mice and probably any mouse-like thing that Linux's evdev system supports.

The Arch page also talks about displaying the USB device polling rate, which can be dug out of /sys/kernel/debug/usb/devices. Based on my own testing on Fedora 22, the reported device Ivl does not have much to do with the mouse polling rate. All of my USB mice report 10ms (which is only 100 Hz), but evhz disagrees and reports 125 Hz normally for a standard USB mouse and a 500 Hz polling rate if I set mousepoll to 2.

Regardless of what you have mousepoll set to, it's possible for a USB mouse (or at least something claiming to be one) to respond at a slower rate. In other words, Linux's USB mouse polling rate is a maximum, not a minimum. Hopefully such hardware is rare, especially when it comes to real mice.

(I suspect that KVM over IP systems that support virtual USB mice have relatively low maximum mouse poll rates no matter what Linux asks for.)

Written on 29 October 2015.
« System V was kind of backwards for a long time
My discovery that the USB mouse polling rate matters »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Oct 29 02:03:29 2015
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.