From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Wilson Subject: Re: [PATCH 1/2] drm/i915: Prefault all pages for pread and pwrite Date: Sun, 10 Jul 2011 09:08:50 +0100 Message-ID: References: <1310200731-18086-1-git-send-email-chris@chris-wilson.co.uk> <20110710014031.GA8410@cloud01> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id A5E859E7E1 for ; Sun, 10 Jul 2011 06:33:23 -0700 (PDT) In-Reply-To: <20110710014031.GA8410@cloud01> 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: Ben Widawsky Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Sun, 10 Jul 2011 01:40:31 +0000, Ben Widawsky wrote: > On Sat, Jul 09, 2011 at 09:38:50AM +0100, Chris Wilson wrote: > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > > index 4fc9738..2fce620 100644 > > --- a/drivers/gpu/drm/i915/i915_gem.c > > +++ b/drivers/gpu/drm/i915/i915_gem.c > > @@ -503,6 +503,19 @@ out: > > return ret; > > } > > > > +static int prefault_writeable(unsigned long uaddr, unsigned long len) > > +{ > > + int ret = 0; > > + > > + len += uaddr; > > + while (uaddr < len) { > > + ret |= __put_user(0, (char __user *)uaddr); > > + uaddr += 4096; > > + } > > + > > + return ret ? -EFAULT : 0; > > +} > > + > > /** > > * Reads data from the object referenced by handle. > > * > > What's the reason for not breaking out of the loop on the first failing > fault? It seems like you could incur a bunch of latency for a call which > you know will ending up failin anyway. Although TBH I'm not clear how > it could actually fail if you've called access_ok(). Because encountering a fault in that loop is an extremely rare event, and the branch inside the loop appeared on the profiles. -Chris -- Chris Wilson, Intel Open Source Technology Centre