diff mbox

[6/7] drm/i915: Only grab timestamps when needed

Message ID 1452521321-4032-7-git-send-email-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tvrtko Ursulin Jan. 11, 2016, 2:08 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

No need to call ktime_get_raw_ns twice per unlimited wait and can
also elimate a local variable.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Chris Wilson Jan. 11, 2016, 2:36 p.m. UTC | #1
On Mon, Jan 11, 2016 at 02:08:40PM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> No need to call ktime_get_raw_ns twice per unlimited wait and can
> also elimate a local variable.

But we could eliminate both, and the unsightly pointless assignment only
required to shut gcc up.

Still preferring my patch.
-Chris
Tvrtko Ursulin Jan. 11, 2016, 3:04 p.m. UTC | #2
On 11/01/16 14:36, Chris Wilson wrote:
> On Mon, Jan 11, 2016 at 02:08:40PM +0000, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> No need to call ktime_get_raw_ns twice per unlimited wait and can
>> also elimate a local variable.
>
> But we could eliminate both, and the unsightly pointless assignment only
> required to shut gcc up.
>
> Still preferring my patch.

Ah I remember it now.. you were storing it in the pointer provided by 
the caller. I think that is significantly worse, sorry cannot approve that.

Regards,

Tvrtko
Dave Gordon Jan. 12, 2016, 3:52 p.m. UTC | #3
On 11/01/16 15:04, Tvrtko Ursulin wrote:
>
> On 11/01/16 14:36, Chris Wilson wrote:
>> On Mon, Jan 11, 2016 at 02:08:40PM +0000, Tvrtko Ursulin wrote:
>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>
>>> No need to call ktime_get_raw_ns twice per unlimited wait and can
>>> also elimate a local variable.
>>
>> But we could eliminate both, and the unsightly pointless assignment only
>> required to shut gcc up.
>>
>> Still preferring my patch.
>
> Ah I remember it now.. you were storing it in the pointer provided by
> the caller. I think that is significantly worse, sorry cannot approve that.
>
> Regards,
>
> Tvrtko

Local variable good, pointer indirection through parameter bad.

Reviewed-by: Dave Gordon <david.s.gordon@intel.com>
Daniel Vetter Jan. 12, 2016, 5:14 p.m. UTC | #4
On Tue, Jan 12, 2016 at 03:52:36PM +0000, Dave Gordon wrote:
> On 11/01/16 15:04, Tvrtko Ursulin wrote:
> >
> >On 11/01/16 14:36, Chris Wilson wrote:
> >>On Mon, Jan 11, 2016 at 02:08:40PM +0000, Tvrtko Ursulin wrote:
> >>>From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>>
> >>>No need to call ktime_get_raw_ns twice per unlimited wait and can
> >>>also elimate a local variable.
> >>
> >>But we could eliminate both, and the unsightly pointless assignment only
> >>required to shut gcc up.
> >>
> >>Still preferring my patch.
> >
> >Ah I remember it now.. you were storing it in the pointer provided by
> >the caller. I think that is significantly worse, sorry cannot approve that.
> >
> >Regards,
> >
> >Tvrtko
> 
> Local variable good, pointer indirection through parameter bad.
> 
> Reviewed-by: Dave Gordon <david.s.gordon@intel.com>

Needs a comment like now = 0; /* shut up dense gcc */, with that acked.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index de98dc41fb9f..c4f69579eb7a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1246,7 +1246,7 @@  int __i915_wait_request(struct drm_i915_gem_request *req,
 	int state = interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
 	DEFINE_WAIT(wait);
 	unsigned long timeout_expire;
-	s64 before, now;
+	s64 before = 0;
 	int ret;
 
 	WARN(!intel_irqs_enabled(dev_priv), "IRQs disabled");
@@ -1266,14 +1266,17 @@  int __i915_wait_request(struct drm_i915_gem_request *req,
 			return -ETIME;
 
 		timeout_expire = jiffies + nsecs_to_jiffies_timeout(*timeout);
+
+		/*
+		 * Record current time in case interrupted by signal, or wedged.
+		 */
+		before = ktime_get_raw_ns();
 	}
 
 	if (INTEL_INFO(dev_priv)->gen >= 6)
 		gen6_rps_boost(dev_priv, rps, req->emitted_jiffies);
 
-	/* Record current time in case interrupted by signal, or wedged */
 	trace_i915_gem_request_wait_begin(req);
-	before = ktime_get_raw_ns();
 
 	/* Optimistic spin for the next jiffie before touching IRQs */
 	ret = __i915_spin_request(req, state);
@@ -1331,11 +1334,10 @@  int __i915_wait_request(struct drm_i915_gem_request *req,
 	finish_wait(&ring->irq_queue, &wait);
 
 out:
-	now = ktime_get_raw_ns();
 	trace_i915_gem_request_wait_end(req);
 
 	if (timeout) {
-		s64 tres = *timeout - (now - before);
+		s64 tres = *timeout - (ktime_get_raw_ns() - before);
 
 		*timeout = tres < 0 ? 0 : tres;