[Intel-gfx] [PATCH 1/2] drm/i915: Prefault all pages for pread and pwrite
Ben Widawsky
ben at bwidawsk.net
Sun Jul 10 03:40:31 CEST 2011
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
More information about the Intel-gfx
mailing list