How best to pin pages in physical memory?

From: Chris Wilson
Date: Sun Sep 26 2010 - 17:07:55 EST


This morning I came to the sickening conclusion that there is
nothing in the drm/i915 driver that prevents the VM from swapping out
pages mapped into the GTT (i.e. pages that are currently being written
to or read from the GPU).

The following patch is what I hastily threw together after grepping the
sources for likely methods. A couple of considerations that need to be
taken into account are:

1. Not all pages allocated through the shmfs get_pages() allocator that
backs each GEM buffer object is mapped into the GTT. Though the actual
quantity of such pages are small and temporary

2. The GTT may be as large as 2GiB + a separate 2GiB that can be used
for a per-process GTT.

3. Forced eviction is currently the shrinker, which may wait upon the
GPU to finish and then unbind the pages from the GTT (and attempt to
return the memory to the system). It might be useful to throttle the GPU
and return the pages earlier to prevent the system from swapping?

If this looks like the continuation of the memory corruption saga caused
by i915.ko during suspend, it is.
-Chris

---