drm/i915: Only free the oldest stale context before allocating
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 5 Jul 2017 14:26:34 +0000 (15:26 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 6 Jul 2017 10:51:52 +0000 (11:51 +0100)
commitcb0aeaa81842948e32f39838f0ec113e3bb52291
tree0ec0aec532cc70e246b8a4ccf342ba077209e348
parent6b6573d114050ee4ee1c54a60a92ae1b68ce1b6e
drm/i915: Only free the oldest stale context before allocating

Currently, we move all unreferenced contexts to an RCU free list and
then onto a worker for eventual reaping. To compensate against this
growing into a long list with frequent allocations starving the system
of available memory, before we allocate a new context we reap all the
stale contexts. This puts all the cost of destroying the context into
the next allocator, which is presumably more sensitive to syscall
latency and unfair. We can limit the number of contexts being freed by
the new allocator to both keep the list trimmed and to allow the
allocator to be reasonably fast.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170705142634.18554-4-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
drivers/gpu/drm/i915/i915_gem_context.c