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@xxxxxxxxxxxxxxxxxx> > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> > --- > 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 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx