[Intel-gfx] [PATCH 1/3] drm/i915: Use pagecache write to prepopulate shmemfs from pwrite-ioctl

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Mon Mar 6 19:48:31 UTC 2017


On ma, 2017-03-06 at 09:29 +0000, Chris Wilson wrote:
> Before we instantiate/pin the backing store for our use, we
> can prepopulate the shmemfs filp efficiently using the a
> write into the pagecache. We avoid the penalty of instantiating
> all the pages, important if the user is just writing to a few
> and never uses the object on the GPU, and using a direct write
> into shmemfs allows it to avoid the cost of retrieving a page
> (either swapin or clearing-before-use) before it is overwritten.
> 
> This can be extended later to provide additional specialisation for
> other backends (other than shmemfs).
> 
> References: https://bugs.freedesktop.org/show_bug.cgi?id=99107
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.william.auld at gmail.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>

<SNIP>

> +static int
> +i915_gem_object_pwrite_gtt(struct drm_i915_gem_object *obj,
> +			   const struct drm_i915_gem_pwrite *arg)
> +{
> +	struct address_space *mapping = obj->base.filp->f_mapping;
> +	char __user *user_data = u64_to_user_ptr(arg->data_ptr);
> +	u64 remain, offset;
> +	unsigned int pg;
> +
> +	/* Before we instantiate/pin the backing store for our use, we
> +	 * can prepopulate the shmemfs filp efficiently using the a
> +	 * write into the pagecache. We avoid the penalty of instantiating
> +	 * all the pages, important if the user is just writing to a few
> +	 * and never uses the object on the GPU, and using a direct write
> +	 * into shmemfs allows it to avoid the cost of retrieving a page
> +	 * (either swapin or clearing-before-use) before it is overwritten.
> +	 */
> +	if (READ_ONCE(obj->mm.pages))
> +		return -ENODEV;
> +
> +	/* Before the pages are instantioted the object is treated as being

*instantiated

<SNIP>

> +		err = pagecache_write_end(obj->base.filp, mapping, offset,
> +					  len, len - unwritten,
> +					  page, data);

Did you deliberately make the arguments different from write_begin? :)

If this solves a problem;

Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

But should we instead fix libva?

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation


More information about the Intel-gfx mailing list