drm/mm: Reject over-sized allocation requests early
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 21 May 2018 08:21:28 +0000 (09:21 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 24 May 2018 14:04:16 +0000 (15:04 +0100)
commit2f7e87692e0441abf27a9714991edd136e87363a
treea985728198854faad96a6cabc37378fb1039317e
parent1d1a4f6dd1645fba6533c7884582006d13664748
drm/mm: Reject over-sized allocation requests early

As we keep an rbtree of available holes sorted by their size, we can
very easily determine if there is any hole large enough that might
satisfy the allocation request. This helps when dealing with a highly
fragmented address space and a request for a search by address.

To cache the largest size, we convert into the cached rbtree variant
which tracks the leftmost node for us. However, currently we sorted into
ascending size order so the leftmost node is the smallest, and so to
make it the largest hole we need to invert our sorting.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180521082131.13744-1-chris@chris-wilson.co.uk
drivers/gpu/drm/drm_mm.c
include/drm/drm_mm.h