From: Jesse Barnes Subject: Re: [PATCH 2/2] drm/i915: add idle/busy tracepoints Date: Fri, 18 Mar 2011 11:18:11 -0700 Message-ID: <20110318111811.1db22228@jbarnes-desktop> References: <1300470975-2521-1-git-send-email-jbarnes@virtuousgeek.org> <1300470975-2521-2-git-send-email-jbarnes@virtuousgeek.org> <0d30dc$lg87j6@orsmga001.jf.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from oproxy2-pub.bluehost.com (oproxy2-pub.bluehost.com [67.222.39.60]) by gabe.freedesktop.org (Postfix) with SMTP id C2F669EFCA for ; Fri, 18 Mar 2011 11:18:13 -0700 (PDT) In-Reply-To: <0d30dc$lg87j6@orsmga001.jf.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Fri, 18 Mar 2011 18:12:25 +0000 Chris Wilson wrote: > On Fri, 18 Mar 2011 10:56:15 -0700, Jesse Barnes 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 > > --- > > 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