[Intel-gfx] [PATCH v2] drm/i915/selftests: Release the struct_mutex to free the objects

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Jul 3 10:52:58 UTC 2018


On 03/07/2018 11:18, Chris Wilson wrote:
> live_gtt is a very slow test to run, simply because it tries to allocate
> and use as much as the 48b address space as possibly can and in the
> process will try to own all of the system memory. This leads to resource
> exhaustion and CPU starvation; the latter impacts us when the NMI
> watchdog declares a task hung due to a mutex contention with ourselves.
> This we can prevent by releasing the struct_mutex and forcing our
> i915/rcu workers to run, and in particular flushing the freed object
> worker that is the cause for concern.
> 
> References: https://bugs.freedesktop.org/show_bug.cgi?id=107094
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
>   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 23 +++++++++++++++++++
>   1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index fff26bd05f71..eefcf7b84054 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -32,6 +32,20 @@
>   #include "mock_drm.h"
>   #include "mock_gem_device.h"
>   
> +static void cleanup_freed_objects(struct drm_i915_private *i915)
> +{
> +	/*
> +	 * As we may hold onto the struct_mutex for inordinate lengths of
> +	 * time, the NMI khungtaskd detector may fire for the free objects
> +	 * worker.
> +	 */
> +	mutex_unlock(&i915->drm.struct_mutex);
> +
> +	i915_gem_drain_freed_objects(i915);
> +
> +	mutex_lock(&i915->drm.struct_mutex);
> +}
> +
>   static void fake_free_pages(struct drm_i915_gem_object *obj,
>   			    struct sg_table *pages)
>   {
> @@ -290,6 +304,8 @@ static int lowlevel_hole(struct drm_i915_private *i915,
>   		i915_gem_object_put(obj);
>   
>   		kfree(order);
> +
> +		cleanup_freed_objects(i915);
>   	}
>   
>   	return 0;
> @@ -518,6 +534,7 @@ static int fill_hole(struct drm_i915_private *i915,
>   		}
>   
>   		close_object_list(&objects, vm);
> +		cleanup_freed_objects(i915);
>   	}
>   
>   	return 0;
> @@ -604,6 +621,8 @@ static int walk_hole(struct drm_i915_private *i915,
>   		i915_gem_object_put(obj);
>   		if (err)
>   			return err;
> +
> +		cleanup_freed_objects(i915);
>   	}
>   
>   	return 0;
> @@ -788,6 +807,8 @@ static int drunk_hole(struct drm_i915_private *i915,
>   		kfree(order);
>   		if (err)
>   			return err;
> +
> +		cleanup_freed_objects(i915);
>   	}
>   
>   	return 0;
> @@ -856,6 +877,7 @@ static int __shrink_hole(struct drm_i915_private *i915,
>   	}
>   
>   	close_object_list(&objects, vm);
> +	cleanup_freed_objects(i915);
>   	return err;
>   }
>   
> @@ -948,6 +970,7 @@ static int shrink_boom(struct drm_i915_private *i915,
>   		i915_gem_object_put(explode);
>   
>   		memset(&vm->fault_attr, 0, sizeof(vm->fault_attr));
> +		cleanup_freed_objects(i915);
>   	}
>   
>   	return 0;
> 

Okay this is nicer.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Regards,

Tvrtko


More information about the Intel-gfx mailing list