[Intel-gfx] [PATCH 14/15] drm/i915: Only query timestamp when measuring elapsed time

Chris Wilson chris at chris-wilson.co.uk
Mon Nov 30 06:31:41 PST 2015


On Mon, Nov 30, 2015 at 10:19:40AM +0000, Tvrtko Ursulin wrote:
> 
> On 29/11/15 08:48, Chris Wilson wrote:
> >Avoid the two calls to ktime_get_raw_ns() (at best it reads the TSC) as
> >we only need to compute the elapsed time for a timed wait.
> >
> >Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> >---
> >  drivers/gpu/drm/i915/i915_gem.c | 13 +++++--------
> >  1 file changed, 5 insertions(+), 8 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> >index 2c3e36e19cb0..871201713c73 100644
> >--- a/drivers/gpu/drm/i915/i915_gem.c
> >+++ b/drivers/gpu/drm/i915/i915_gem.c
> >@@ -1227,7 +1227,6 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
> >  	int state = interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
> >  	DEFINE_WAIT(wait);
> >  	unsigned long timeout_remain;
> >-	s64 before, now;
> >  	int ret;
> >
> >  	if (list_empty(&req->list))
> >@@ -1244,13 +1243,12 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
> >  		if (*timeout == 0)
> >  			return -ETIME;
> >
> >+		/* Record current time in case interrupted, or wedged */
> >  		timeout_remain = nsecs_to_jiffies_timeout(*timeout);
> >+		*timeout += ktime_get_raw_ns();
> 
> Don't really like this one, how you use the passed in pointer to
> store the intermediate local state.
> 
> It works etc but just feels too hacky.

Bah, it's already in the CPU cache I might as well take advantage of the
space. :)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list