From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: Re: [PATCH 1/2] drm/i915: Prefault all pages for pread and pwrite Date: Sun, 10 Jul 2011 01:40:31 +0000 Message-ID: <20110710014031.GA8410@cloud01> References: <1310200731-18086-1-git-send-email-chris@chris-wilson.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id DECEC9E78F for ; Sat, 9 Jul 2011 18:44:32 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1310200731-18086-1-git-send-email-chris@chris-wilson.co.uk> 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 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(). Also you should probably use PAGE_SIZE instead of 4096. Ben