[Intel-gfx] [PATCH v2 3/4] drm/i915: Add WARN_RECUR and i915.recur_warnings

Chris Wilson chris at chris-wilson.co.uk
Fri Dec 18 03:30:25 PST 2015


On Fri, Dec 18, 2015 at 01:08:17PM +0200, Joonas Lahtinen wrote:
> Add i915.recur_warnings parameter to control output in cases where the warning
> is of recurring type and is potentially called from multiple paths. Using just
> WARN_ONCE would mask out other calling paths but one, this is not desireable
> on developer machine or CI system, but is a compromise to be made on end user
> system not to flood the message and overflow all possible kernel log buffers.
> 
> When the recur_warnings option is false (default), WARN_RECUR will reduce to
> WARN_ONCE.
> 
> v2:
> - More upstreamable macro name and parameter (Chris)
> - Squash a hunk that slipped to next patch
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h    | 10 ++++++++++
>  drivers/gpu/drm/i915/i915_params.c |  6 ++++++
>  drivers/gpu/drm/i915/i915_params.h |  1 +
>  3 files changed, 17 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 3ce609f..e1ca61f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -76,6 +76,16 @@
>  #undef WARN_ON_ONCE
>  #define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(" __stringify(x) ")")
>  
> +#define WARN_RECUR(condition, format...) ({				\
> +	static bool __section(.data.unlikely) __warned;			\
> +	int __ret_warn_on = !!(condition);				\
> +	if (unlikely(__ret_warn_on))					\
> +		if (WARN(unlikely(!__warned ||				\
> +				  i915.recur_warnings), format))	\
> +			__warned = true;				\
> +	unlikely(__ret_warn_on);					\
> +})

Ah, see include/linux/ratelimit.h

Just wondering if we can reuse that, extend it in someway to cover a
control variable?

Similarly, how to fold in I915_STATE_WARN (if possible)? i.e. to have
the optional error message instead of the WARN.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list