From: Ben Widawsky Subject: Re: [PATCH 2/8] drm/i915: Extract vm specific part of eviction Date: Fri, 30 Aug 2013 20:39:59 -0700 Message-ID: <20130831033959.GB1088@bwidawsk.net> References: <1377906241-8463-1-git-send-email-benjamin.widawsky@intel.com> <1377906241-8463-3-git-send-email-benjamin.widawsky@intel.com> <20130830235203.GQ4726@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E822E5CB7 for ; Fri, 30 Aug 2013 20:40:04 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20130830235203.GQ4726@nuc-i3427.alporthouse.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 , Ben Widawsky , Intel GFX List-Id: intel-gfx@lists.freedesktop.org On Sat, Aug 31, 2013 at 12:52:03AM +0100, Chris Wilson wrote: > On Fri, Aug 30, 2013 at 04:43:55PM -0700, Ben Widawsky wrote: > > As we'll see in the next patch, being able to evict for just 1 VM is > > handy. > > > > Signed-off-by: Ben Widawsky > > --- > > drivers/gpu/drm/i915/i915_gem_evict.c | 28 ++++++++++++++++++++++------ > > 1 file changed, 22 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c > > index cc8974f..e9033f0 100644 > > --- a/drivers/gpu/drm/i915/i915_gem_evict.c > > +++ b/drivers/gpu/drm/i915/i915_gem_evict.c > > @@ -155,12 +155,31 @@ found: > > return ret; > > } > > > > +static int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle) > > +{ > > + struct i915_vma *vma, *next; > > + int ret; > > + > > + if (do_idle) { > > + ret = i915_gpu_idle(vm->dev); > > + if (ret) > > + return ret; > > + > > + i915_gem_retire_requests(vm->dev); > > + } > > + > > + list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list) > > + if (vma->obj->pin_count == 0) > > + WARN_ON(i915_vma_unbind(vma)); > > + > > + return 0; > > +} > > + > > int > > i915_gem_evict_everything(struct drm_device *dev) > > { > > drm_i915_private_t *dev_priv = dev->dev_private; > > struct i915_address_space *vm; > > - struct i915_vma *vma, *next; > > bool lists_empty = true; > > int ret; > > > > @@ -187,11 +206,8 @@ i915_gem_evict_everything(struct drm_device *dev) > > i915_gem_retire_requests(dev); > > > > /* Having flushed everything, unbind() should never raise an error */ > > - list_for_each_entry(vm, &dev_priv->vm_list, global_link) { > > - list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list) > > - if (vma->obj->pin_count == 0) > > - WARN_ON(i915_vma_unbind(vma)); > > - } > > + list_for_each_entry(vm, &dev_priv->vm_list, global_link) > > + WARN_ON(i915_gem_evict_vm(vm, false)); > > Wny not use do_idle here? > -Chris > The point of the extraction was to exactly avoid repeated call to idle + retire, although in looking back at it, I suppose the cost wouldn't be much since the first idle would make subsequent calls to idle + retire just about free). Just dropping the do_idle parameter, and always idling is what you probably want. -- Ben Widawsky, Intel Open Source Technology Center