xen: speed up grant-table reclaim
authorDemi Marie Obenour <demi@invisiblethingslab.com>
Wed, 26 Jul 2023 16:52:41 +0000 (12:52 -0400)
committerJuergen Gross <jgross@suse.com>
Thu, 27 Jul 2023 05:53:12 +0000 (07:53 +0200)
commitc04e9894846c663f3278a414f34416e6e45bbe68
treeb69f437caa637263c35436466f6494145a0208f7
parent58f6259b7a08f8d47d4629609703d358b042f0fd
xen: speed up grant-table reclaim

When a grant entry is still in use by the remote domain, Linux must put
it on a deferred list.  Normally, this list is very short, because
the PV network and block protocols expect the backend to unmap the grant
first.  However, Qubes OS's GUI protocol is subject to the constraints
of the X Window System, and as such winds up with the frontend unmapping
the window first.  As a result, the list can grow very large, resulting
in a massive memory leak and eventual VM freeze.

To partially solve this problem, make the number of entries that the VM
will attempt to free at each iteration tunable.  The default is still
10, but it can be overridden via a module parameter.

This is Cc: stable because (when combined with appropriate userspace
changes) it fixes a severe performance and stability problem for Qubes
OS users.

Cc: stable@vger.kernel.org
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20230726165354.1252-1-demi@invisiblethingslab.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Documentation/ABI/testing/sysfs-module
drivers/xen/grant-table.c