[Intel-gfx] [PATCH 1/2] drm/i915: Prefault all pages for pread and pwrite
Chris Wilson
chris at chris-wilson.co.uk
Sun Jul 10 10:08:50 CEST 2011
On Sun, 10 Jul 2011 01:40:31 +0000, Ben Widawsky <ben at bwidawsk.net> 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
More information about the Intel-gfx
mailing list