diff mbox series

drm/i915: Break long iterations for get/put shmemfs pages

Message ID 20181105170640.26905-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Break long iterations for get/put shmemfs pages | expand

Commit Message

Chris Wilson Nov. 5, 2018, 5:06 p.m. UTC
As we may have to iterate a few thousand elements to acquire and release
the shmemfs backing storage for a GPU object, we need to break up the
long loop with cond_resched() to retain a modicum of low latency for
other processes.

Testcase: igt/benchmarks/gem_syslatency
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kuo-Hsin Yang <vovoy@chromium.org>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Joonas Lahtinen Nov. 6, 2018, 10:55 a.m. UTC | #1
Quoting Chris Wilson (2018-11-05 19:06:40)
> As we may have to iterate a few thousand elements to acquire and release
> the shmemfs backing storage for a GPU object, we need to break up the
> long loop with cond_resched() to retain a modicum of low latency for
> other processes.
> 
> Testcase: igt/benchmarks/gem_syslatency
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Kuo-Hsin Yang <vovoy@chromium.org>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
Chris Wilson Nov. 6, 2018, 1:41 p.m. UTC | #2
Quoting Joonas Lahtinen (2018-11-06 10:55:32)
> Quoting Chris Wilson (2018-11-05 19:06:40)
> > As we may have to iterate a few thousand elements to acquire and release
> > the shmemfs backing storage for a GPU object, we need to break up the
> > long loop with cond_resched() to retain a modicum of low latency for
> > other processes.
> > 
> > Testcase: igt/benchmarks/gem_syslatency
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Kuo-Hsin Yang <vovoy@chromium.org>
> > Cc: Matthew Auld <matthew.auld@intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Applied as this improves the current syslatency, and further improves
Kuo-Hsin's patch.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b1caff07ed65..a120112d0621 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2404,6 +2404,7 @@  i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj,
 			mark_page_accessed(page);
 
 		put_page(page);
+		cond_resched();
 	}
 	obj->mm.dirty = false;
 
@@ -2574,6 +2575,7 @@  static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 		gfp_t gfp = noreclaim;
 
 		do {
+			cond_resched();
 			page = shmem_read_mapping_page_gfp(mapping, i, gfp);
 			if (likely(!IS_ERR(page)))
 				break;
@@ -2584,7 +2586,6 @@  static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 			}
 
 			i915_gem_shrink(dev_priv, 2 * page_count, NULL, *s++);
-			cond_resched();
 
 			/*
 			 * We've tried hard to allocate the memory by reaping