[Intel-gfx] [PATCH 2/2] drm/i915: add idle/busy tracepoints

Jesse Barnes jbarnes at virtuousgeek.org
Fri Mar 18 19:18:11 CET 2011


On Fri, 18 Mar 2011 18:12:25 +0000
Chris Wilson <chris at chris-wilson.co.uk> wrote:

> On Fri, 18 Mar 2011 10:56:15 -0700, Jesse Barnes <jbarnes at virtuousgeek.org> wrote:
> > Add trace points for when the GPU goes from idle to busy and vice-versa.
> > Also trace when we start to idle the GPU and when it finally does idle
> > (this could take awhile if the ring is full of commands).
> > 
> > Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.h         |    4 +++
> >  drivers/gpu/drm/i915/i915_gem.c         |    4 +++
> >  drivers/gpu/drm/i915/i915_irq.c         |    5 ++++
> >  drivers/gpu/drm/i915/i915_trace.h       |   35 +++++++++++++++++++++++++++++++
> >  drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++++
> >  5 files changed, 54 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index c8a21ce..adff483 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -674,6 +674,10 @@ typedef struct drm_i915_private {
> >  	int lvds_downclock;
> >  	struct work_struct idle_work;
> >  	struct timer_list idle_timer;
> > +
> > +	bool gpu_busy;
> > +	unsigned long gpu_busy_start;
> > +
> >  	bool busy;
> >  	u16 orig_clock;
> >  	int child_dev_num;
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index ac23dcf..18534d7 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -2208,6 +2208,8 @@ i915_gpu_idle(struct drm_device *dev)
> >  	bool lists_empty;
> >  	int ret, i;
> >  
> > +	trace_i915_gpu_idle_start(dev);
> > +
> >  	lists_empty = (list_empty(&dev_priv->mm.flushing_list) &&
> >  		       list_empty(&dev_priv->mm.active_list));
> >  	if (lists_empty)
> > @@ -2220,6 +2222,8 @@ i915_gpu_idle(struct drm_device *dev)
> >  			return ret;
> >  	}
> >  
> > +	trace_i915_gpu_idle_end(dev);
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> > index 346dd85..0d3cc62 100644
> > --- a/drivers/gpu/drm/i915/i915_irq.c
> > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > @@ -365,6 +365,11 @@ static void notify_ring(struct drm_device *dev,
> >  	dev_priv->hangcheck_count = 0;
> >  	mod_timer(&dev_priv->hangcheck_timer,
> >  		  jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
> > +
> > +	if (I915_READ_HEAD(ring) == I915_READ_TAIL(ring)) {
> > +		dev_priv->gpu_busy = false;
> > +		trace_i915_gpu_busy_end(dev_priv->dev);
> > +	}
> >  }
> 
> IRQ notifies should in fact be few and far between. I do not see how you
> actually detect when the gpu goes idle should we not be waiting on a
> request. So I think you need a pair of ring->irq_get/irq_put in and add
> tracepoints for each ring as opposed to device! You can then have a device
> busy which is the summation of active rings...

Oops, yeah I have a hack in my local tree that disables irq_put so I
get a notify every time.  We only want that if tracing is enabled
though (even then it will make things a lot noisier and affect CPU
utilization, but I guess totally invisible tracing isn't really
possible).

Would probably be better to have trace points per ring to track busy
idle for each.  I'll fix it up.

-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list