[Intel-gfx] [PATCH] drm/i915/selftests: add missing gtt shrinker test
Chris Wilson
chris at chris-wilson.co.uk
Wed Jan 31 20:58:56 UTC 2018
Quoting Matthew Auld (2018-01-31 19:14:53)
> Try to catch a bug we've seen in the wild where the shrinker purges the
> pd/pdp from under us while allocating our paging structures.
>
> References: https://bugs.freedesktop.org/show_bug.cgi?id=104773
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 84 +++++++++++++++++++++++++++
> 1 file changed, 84 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index bb7cf998fc65..a40a2a7514fd 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -885,6 +885,84 @@ static int shrink_hole(struct drm_i915_private *i915,
> return err;
> }
>
> +static int shrink_boom(struct drm_i915_private *i915,
> + struct i915_address_space *vm,
> + u64 hole_start, u64 hole_end,
> + unsigned long end_time)
> +{
> + unsigned int sizes[] = {SZ_2M, SZ_1G};
> + struct drm_i915_gem_object *purge;
> + struct drm_i915_gem_object *explode;
> + struct i915_vma *vma;
> + unsigned int flags = PIN_USER | PIN_OFFSET_FIXED;
> + int err;
> + int i;
> +
> + /*
> + * Catch the case which shrink_hole seems to miss. The setup here
> + * requires invoking the shrinker as we do the alloc_pt/alloc_pd, while
> + * ensuring that all vma assiocated with the respective pd/pdp are
> + * unpinned at the time.
> + */
Question for everyone: can we see more holes in shrink_hole?
> +
> + for (i = 0; i < ARRAY_SIZE(sizes); ++i) {
> + unsigned int size = sizes[i];
> +
> + purge = fake_dma_object(i915, size);
> + if (IS_ERR(purge))
> + return PTR_ERR(purge);
> +
> + vma = i915_vma_instance(purge, vm, NULL);
> + if (IS_ERR(vma)) {
> + err = PTR_ERR(vma);
> + goto err_purge;
> + }
> +
> + err = i915_vma_pin(vma, 0, 0, flags);
> + if (err)
> + goto err_purge;
> +
> + /* Should now be ripe for purging */
> + i915_vma_unpin(vma);
> +
> + explode = fake_dma_object(i915, size);
> + if (IS_ERR(explode)) {
> + err = PTR_ERR(purge);
> + goto err_purge;
> + }
> +
> + vm->fault_attr.probability = 100;
> + vm->fault_attr.interval = 1;
> + atomic_set(&vm->fault_attr.times, -1);
> +
> + vma = i915_vma_instance(explode, vm, NULL);
> + if (IS_ERR(vma)) {
> + err = PTR_ERR(vma);
> + goto err_explode;
> + }
> +
> + err = i915_vma_pin(vma, 0, 0, flags | size);
> + if (err)
> + goto err_explode;
> +
> + i915_vma_unpin(vma);
> +
> + i915_gem_object_put(purge);
> + i915_gem_object_put(explode);
> +
> + memset(&vm->fault_attr, 0, sizeof(vm->fault_attr));
> + }
> +
> + return 0;
> +
> +err_explode:
> + i915_gem_object_put(explode);
> +err_purge:
> + i915_gem_object_put(purge);
> +
> + return err;
> +}
As this demonstrates a shrinker bug we missed in the test intended to
find all shrinker bugs,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Just worrying about how deep the iceberg goes. (Though more about
catching tomorrow's bug as we should have this one fixed pretty shortly.)
-Chris
More information about the Intel-gfx
mailing list