diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-26 14:01:51 +0300 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-26 15:00:58 +0300 |
commit | 2a1d775201081c400d7e60ceb8e5ac887d11b1f7 (patch) | |
tree | 5bd3ef0d28b31918b4325c4f74459855ba2f2095 /drivers/gpu/drm/i915/i915_gem_shrinker.c | |
parent | 4a50d20e105a4a8e46a641e4779e9431e0aabc84 (diff) | |
download | linux-2a1d775201081c400d7e60ceb8e5ac887d11b1f7.tar.xz |
drm/i915: Prefer list_first_entry_or_null
list_first_entry_or_null() can generate better code than using
if (!list_empty()) {ptr = list_first_entry()) ..., so put it to use.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1469432687-22756-3-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1469530913-17180-2-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_shrinker.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_shrinker.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index afaa2597e35e..5d4772c146b1 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c @@ -163,17 +163,18 @@ i915_gem_shrink(struct drm_i915_private *dev_priv, */ for (phase = phases; phase->list; phase++) { struct list_head still_in_list; + struct drm_i915_gem_object *obj; if ((flags & phase->bit) == 0) continue; INIT_LIST_HEAD(&still_in_list); - while (count < target && !list_empty(phase->list)) { - struct drm_i915_gem_object *obj; + while (count < target && + (obj = list_first_entry_or_null(phase->list, + typeof(*obj), + global_list))) { struct i915_vma *vma, *v; - obj = list_first_entry(phase->list, - typeof(*obj), global_list); list_move_tail(&obj->global_list, &still_in_list); if (flags & I915_SHRINK_PURGEABLE && |