[Intel-gfx] [PATCH 1/2] drm/i915: Warn if request allocation stalls
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Oct 5 08:37:37 UTC 2018
On 05/10/2018 09:02, Chris Wilson wrote:
> Add a warning for an allocation stall to make it painfully more obvious
> while debugging.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_gem.h | 2 ++
> drivers/gpu/drm/i915/i915_request.c | 6 ++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.h b/drivers/gpu/drm/i915/i915_gem.h
> index 599c4f6eb1ea..e2db030fd75a 100644
> --- a/drivers/gpu/drm/i915/i915_gem.h
> +++ b/drivers/gpu/drm/i915/i915_gem.h
> @@ -47,6 +47,7 @@ struct drm_i915_private;
> #define GEM_DEBUG_DECL(var) var
> #define GEM_DEBUG_EXEC(expr) expr
> #define GEM_DEBUG_BUG_ON(expr) GEM_BUG_ON(expr)
> +#define GEM_DEBUG_WARN(expr...) WARN(expr)
Reminds me of one patch which would look so good preceding this one!
>
> #else
>
> @@ -58,6 +59,7 @@ struct drm_i915_private;
> #define GEM_DEBUG_DECL(var)
> #define GEM_DEBUG_EXEC(expr) do { } while (0)
> #define GEM_DEBUG_BUG_ON(expr)
> +#define GEM_DEBUG_WARN(expr...) do { } while (0)
> #endif
>
> #if IS_ENABLED(CONFIG_DRM_I915_TRACE_GEM)
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index abd4dacbab8e..32bf2c9868bf 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -647,6 +647,8 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
> rq = kmem_cache_alloc(i915->requests,
> GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);
> if (unlikely(!rq)) {
> + GEM_DEBUG_DECL(ktime_t start = ktime_get());
> +
> i915_retire_requests(i915);
>
> /* Ratelimit ourselves to prevent oom from malicious clients */
> @@ -671,6 +673,10 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
> ret = -ENOMEM;
> goto err_unreserve;
> }
> +
> + GEM_DEBUG_WARN(ktime_ms_delta(ktime_get(), start) > 500,
> + "request allocation delayed for %lldms\n",
> + ktime_ms_delta(ktime_get(), start));
Usefulness of the arbitrary threshold vs source code pollution?
Regards,
Tvrtko
> }
>
> rq->rcustate = get_state_synchronize_rcu();
>
More information about the Intel-gfx
mailing list