All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 1/6] drm/i915: Compile time concatenate WARN_ON macro strings
Date: Fri, 18 Dec 2015 09:28:41 +0000	[thread overview]
Message-ID: <20151218092841.GC26780@nuc-i3427.alporthouse.com> (raw)
In-Reply-To: <1450380351-28397-2-git-send-email-joonas.lahtinen@linux.intel.com>

On Thu, Dec 17, 2015 at 09:25:46PM +0200, Joonas Lahtinen wrote:
> Using __stringify(x) instead of #x adds support for macros as
> a parameter and reduces runtime overhead.
> 
> Slightly increases the .text size but should not matter.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 1d28d90..fe3e76d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -69,11 +69,11 @@
>  		BUILD_BUG_ON(__i915_warn_cond); \
>  	WARN(__i915_warn_cond, "WARN_ON(" #x ")"); })
>  #else
> -#define WARN_ON(x) WARN((x), "WARN_ON(%s)", #x )
> +#define WARN_ON(x) WARN((x), "WARN_ON(" __stringify(x) ")")
>  #endif
>  
>  #undef WARN_ON_ONCE
> -#define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(%s)", #x )
> +#define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(" __stringify(x) ")")
>  
>  #define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \
>  			     (long) (x), __func__);
> @@ -97,12 +97,14 @@
>  })
>  
>  #define I915_STATE_WARN_ON(condition) ({				\
> +	static const char __warn_on_txt[] =				\
> +		"WARN_ON(" __stringify(condition) ")\n";		\
>  	int __ret_warn_on = !!(condition);				\
>  	if (unlikely(__ret_warn_on)) {					\
>  		if (i915.verbose_state_checks)				\
> -			WARN(1, "WARN_ON(" #condition ")\n");		\
> +			WARN(1, __warn_on_txt);				\
>  		else 							\
> -			DRM_ERROR("WARN_ON(" #condition ")\n");		\
> +			DRM_ERROR(__warn_on_txt);			\
>  	}								\

Bikeshedding, sorry.

#define I915_STATE_WARN_ON(condition) ({				\
  	int __ret_warn_on = !!(condition);				\
  	if (unlikely(__ret_warn_on)) {					\
		static const char __warn_on_txt[] =			\
			"WARN_ON(" __stringify(condition) ")\n";	\
  		if (!WARN(i915.verbose_state_checks, __warn_on_txt);	\
			DRM_ERROR(__warn_on_txt);			\
  	}								\
  	unlikely(__ret_warn_on);					\
  })
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-12-18  9:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 19:25 [RFC][PATCH 0/6] Optionally display recurring warning messages Joonas Lahtinen
2015-12-17 19:25 ` [PATCH 1/6] drm/i915: Compile time concatenate WARN_ON macro strings Joonas Lahtinen
2015-12-18  9:28   ` Chris Wilson [this message]
2015-12-17 19:25 ` [PATCH 2/6] drm/i915: Decouple struct i915_params i915 into i915_params.h Joonas Lahtinen
2015-12-17 20:59   ` Chris Wilson
2015-12-18  9:21     ` Chris Wilson
2015-12-17 19:25 ` [PATCH 3/6] drm/i915: Reorder i915_params struct Joonas Lahtinen
2015-12-17 21:00   ` Chris Wilson
2015-12-17 19:25 ` [PATCH 4/6] drm/i915: Add i915.debug parameter Joonas Lahtinen
2015-12-17 21:02   ` Chris Wilson
2015-12-18 10:01     ` Joonas Lahtinen
2015-12-17 19:25 ` [PATCH 5/6] drm/i915: Add helpers to reduce (repetitive) noise Joonas Lahtinen
2015-12-17 21:10   ` Chris Wilson
2015-12-18  8:20     ` Joonas Lahtinen
2015-12-17 19:25 ` [PATCH 6/6] drm/i915: Use I915_WARN_RECUR for recurring warning messages Joonas Lahtinen
2015-12-18  8:20 ` ✗ warning: Fi.CI.BAT Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151218092841.GC26780@nuc-i3427.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.