drm/i915: Trim partial view sg lists
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Wed, 26 Sep 2018 08:03:53 +0000 (09:03 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 27 Sep 2018 10:26:52 +0000 (11:26 +0100)
Partial views are small but there can be many of them, and since the sg
list space for them is allocated pessimistically, we can save some slab by
trimming the unused tail entries.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180926080353.20867-1-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_gtt.c

index 9e185f0a822ae7bad42cedad57b64bbef80c70d2..ab52657cc3d0b136e443cc6285c2a8a372c4306f 100644 (file)
@@ -2325,6 +2325,8 @@ static inline struct scatterlist *__sg_next(struct scatterlist *sg)
             (((__iter).curr += PAGE_SIZE) >= (__iter).max) ?           \
             (__iter) = __sgt_iter(__sg_next((__iter).sgp), false), 0 : 0)
 
+bool i915_sg_trim(struct sg_table *orig_st);
+
 static inline unsigned int i915_sg_page_sizes(struct scatterlist *sg)
 {
        unsigned int page_sizes;
index 627b1c8a7ea3bad95a582275b6d6826ea415b295..28e943ee8b5e649280b8999a354b189a2e6abf0d 100644 (file)
@@ -2491,7 +2491,7 @@ unlock:
        mutex_unlock(&obj->mm.lock);
 }
 
-static bool i915_sg_trim(struct sg_table *orig_st)
+bool i915_sg_trim(struct sg_table *orig_st)
 {
        struct sg_table new_st;
        struct scatterlist *sg, *new_sg;
index f6c7ab413081e01781f7b279f5c78256a1538a18..1ec721c2058120d9a8ee61bbe660f6ba1a6ec257 100644 (file)
@@ -3835,6 +3835,8 @@ intel_partial_pages(const struct i915_ggtt_view *view,
                count -= len >> PAGE_SHIFT;
                if (count == 0) {
                        sg_mark_end(sg);
+                       i915_sg_trim(st); /* Drop any unused tail entries. */
+
                        return st;
                }