How do I solve periodic mouse lag on Linux Mint (MATE)?

I have a laptop with the latest Linux Mint installed (the MATE version, not the Cinnamon one). 80-90% of the time everything works great, but periodically the mouse will start "lagging" heavily (it will feel sluggish to respond and the cursor move at maybe 20% normal speed). This problem comes and goes without any apparent cause. It occurs with both a USB mouse as well as the laptop's touchpad. I didn't have this issue with an older version of Mint, though.

I've tried to Google for someone else who solved this issue, but because of the general nature of the terms involved ("mouse", "linux", "lag", etc.) I just find a lot of unrelated pages.

Does anyone have any suggestions on how I can diagnose what is causing this strange mouse lag (and ideally, how I can solve it)?

* EDIT *

Here's a sample of top output during the lag:

top - 20:10:27 up 34 days, 22:31,  4 users,  load average: 2.36, 1.19, 0.65
Tasks: 192 total,   2 running, 190 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.8 us, 24.8 sy,  0.0 ni, 68.5 id,  0.4 wa,  0.0 hi,  0.5 si,  0.0 st
KiB Mem:   4032688 total,  3475752 used,   556936 free,   202180 buffers
KiB Swap:  8787516 total,   137556 used,  8649960 free,  1768748 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND           
21961 root      20   0     0    0    0 S  20.9  0.0   0:12.82 kworker/1:0       
21762 root      20   0     0    0    0 R  11.3  0.0   0:12.05 kworker/0:2       
 5780 me        20   0  181m  26m  16m S   9.3  0.7 271:41.38 mate-system-mon   
21733 root      20   0     0    0    0 S   7.6  0.0   0:16.24 kworker/1:1       
21956 root      20   0     0    0    0 S   7.3  0.0   0:13.10 kworker/0:0       
21879 root      20   0     0    0    0 S   3.7  0.0   0:03.25 kworker/u:2       
23920 me        20   0  425m  85m  16m S   3.3  2.2 148:23.44 chrome            
20013 me        20   0  426m 198m  27m S   2.0  5.0   5:53.41 chrome            
  852 me        20   0  170m  13m  10m S   1.0  0.3   1:43.49 mate-terminal     
 2283 root      20   0  132m  26m  10m S   1.0  0.7 140:33.62 Xorg              
11361 me        20   0 1054m 212m  26m S   1.0  5.4 119:45.32 eclipse           
23766 me        20   0  644m 179m  39m S   1.0  4.6 156:13.04 chrome            
19035 couchdb   20   0 86672 5120 1484 S   0.7  0.1 314:22.75 beam.smp          
   10 root      20   0     0    0    0 S   0.3  0.0   6:08.10 ksoftirqd/1       
 2453 me        20   0 38796 1824 1680 S   0.3  0.0   2:31.55 gvfs-afc-volume   
 5776 me        20   0  105m 8376 6772 S   0.3  0.2   1:48.06 multiload-apple   
18074 me        20   0 69836  14m 3808 S   0.3  0.4   9:23.07 python            

Here's a tail of running dmesg (dmesg gives a lot of output, thus the tail):

[2844570.290434] type=1701 audit(1358135321.797:17): auid=4294967295 uid=1000 gid=1000 ses=4294967295 pid=6593 comm="chrome" reason="seccomp" sig=0 syscall=20 compat=0 ip=0xb3599424 code=0x50000
[2855118.278240] stereo mode not supported
[2891634.104527] stereo mode not supported
[2929390.761034] stereo mode not supported
[2930948.986039] stereo mode not supported
[2931457.828088] stereo mode not supported
[2936251.706768] stereo mode not supported
[2939573.402914] stereo mode not supported
[2940015.539524] stereo mode not supported
[2977473.595590] stereo mode not supported

As per @grs's answer, here's the tail of my /var/log/Xorg.0.log:

[2940015.539] (II) intel(0): Printing DDC gathered Modelines:
[2940015.539] (II) intel(0): Modeline "1366x768"x0.0   69.30  1366 1414 1446 1456  768 771 777 793 -hsync -vsync (47.6 kHz eP)
[2977473.595] (II) intel(0): EDID vendor "AUO", prod id 4140
[2977473.595] (II) intel(0): DDCModeFromDetailedTiming: Ignoring: We don't handle stereo.
[2977473.595] (II) intel(0): Printing DDC gathered Modelines:
[2977473.595] (II) intel(0): Modeline "1366x768"x0.0   69.30  1366 1414 1446 1456  768 771 777 793 -hsync -vsync (47.6 kHz eP)
[3020717.050] (II) intel(0): EDID vendor "AUO", prod id 4140
[3020717.050] (II) intel(0): DDCModeFromDetailedTiming: Ignoring: We don't handle stereo.
[3020717.050] (II) intel(0): Printing DDC gathered Modelines:
[3020717.050] (II) intel(0): Modeline "1366x768"x0.0   69.30  1366 1414 1446 1456  768 771 777 793 -hsync -vsync (47.6 kHz eP)

Solution 1:

I found the following solution on Ask Ubuntu:

sudo -i
echo N> /sys/module/drm_kms_helper/parameters/poll
echo "options drm_kms_helper poll=N">/etc/modprobe.d/local.conf

It definitively solved the problem for me, and after more than a week of testing I can confirm it stopped the mouse lag for me.

Solution 2:

Note that on newer kernels the drm_kms_helper module may not be loaded by default. One extra step gets this working:

sudo su -
modprobe drm_kms_helper
echo N> /sys/module/drm_kms_helper/parameters/poll
echo "drm_kms_helper" >> /etc/modprobe.d/local.conf
echo "options drm_kms_helper poll=N" >> /etc/modprobe.d/local.conf

Hope that helps someone!

Solution 3:

Fixing Mouse Lag on Cinnamon

I have experienced heavy mouse lag on cinnamon suddenly. In case someone else finds this page when searching, like me, for a possible cause, it is perhaps: Desktop magnification. Make sure it is turned off with Alt+Super+8, even when the screen is not magnified.

It took me quite some time to track it down, mainly found the problem after starting to bisect my entire home directory (move half of the directories to a temporary directory and log in again etc.) until I could locate ~/.config/dconf/user and then finally the zoom level factor that was set to 1.0:

[org/cinnamon/desktop/a11y/magnifier]
mag-factor=1.0
screen-magnifier-enabled=true

You can check if this is the case on your Cinnamon with

dconf dump / |grep mag

Solution 4:

After weeks of searching and trying to fix this problem, I finally got it sorted through this page: http://carlocapocasa.com/crushing-the-kworker-uprising-or-how-to-fix-your-linux-lenovo-ideapad-y560p/

$ grep enabled /sys/firmware/acpi/interrupts/* (the gpe with the clear high number is the problem)

Then add a crontab entry to fix it @reboot echo "disable" > /sys/firmware/acpi/interrupts/gpeXX (XX is the number of your gpe)

-037

Solution 5:

While OP's accepted answer may have helped back in the day; it no longer works today.

Today, you need to adjust the mousepoll rate of the usbhid module.

If your mouse is 1000hz then you need to tell usbhid to poll at at that interval; by default it polls at 125hz.

On Debian systems you can do that by adding the following to /etc/modules:

-r usbhid
usbhid mousepoll=1

Note: I've never had echo 1 > /sys/module/usbhid/parameters/mousepoll work; I've had to add the poll interval and restart. Probably have to restart X and/or reload video modules to apply it without restarting.