All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v3 2/2] drm/i915: Compile-time concatenate WARN_ON macro strings
Date: Tue, 22 Dec 2015 10:03:23 +0100	[thread overview]
Message-ID: <20151222090323.GO30437@phenom.ffwll.local> (raw)
In-Reply-To: <1450441647-23924-3-git-send-email-joonas.lahtinen@linux.intel.com>

On Fri, Dec 18, 2015 at 02:27:27PM +0200, Joonas Lahtinen wrote:
> Using __stringify(x) instead of #x adds support for macros as
> a parameter and compile-time concatenation reduces the runtime
> overhead.
> 
> Slightly increases the .text size but should not matter.
> 
> v2:
> - Define I915_STATE_WARN_ON though I915_STATE_WARN
>   (Bikeshed inspiration by Chris)
> 
> v3:
> - More specific commit message
> 
> v4:
> - Do not directly pass arbitary string as format, instead
>   guard with "%s" (Dave)
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Dave Gordon <david.s.gordon@intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v3)
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Both patches merged to dinq, thanks.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.h | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 5a5a3e0..664ceb4 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), "%s", "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), "%s", "WARN_ON_ONCE(" __stringify(x) ")")
>  
>  #define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \
>  			     (long) (x), __func__);
> @@ -93,14 +93,8 @@
>  	unlikely(__ret_warn_on);					\
>  })
>  
> -#define I915_STATE_WARN_ON(condition) ({				\
> -	int __ret_warn_on = !!(condition);				\
> -	if (unlikely(__ret_warn_on))					\
> -		if (!WARN(i915.verbose_state_checks,			\
> -			  "WARN_ON(" #condition ")\n"))			\
> -			DRM_ERROR("WARN_ON(" #condition ")\n");		\
> -	unlikely(__ret_warn_on);					\
> -})
> +#define I915_STATE_WARN_ON(x)						\
> +	I915_STATE_WARN((x), "%s", "WARN_ON(" __stringify(x) ")")
>  
>  static inline const char *yesno(bool v)
>  {
> -- 
> 2.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-12-22  9:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 12:27 [PATCH v3 0/2] Optimize WARN_ON macros Joonas Lahtinen
2015-12-18 12:27 ` [PATCH v3 1/2] drm/i915: Simplify _STATE_ debug macros Joonas Lahtinen
2015-12-18 16:18   ` Dave Gordon
2015-12-21  8:11     ` Joonas Lahtinen
2015-12-21 11:53       ` Dave Gordon
2015-12-21 13:41         ` Daniel Vetter
2015-12-22  8:41           ` Joonas Lahtinen
2015-12-18 12:27 ` [PATCH v3 2/2] drm/i915: Compile-time concatenate WARN_ON macro strings Joonas Lahtinen
2015-12-22  9:03   ` Daniel Vetter [this message]
2015-12-18 13:20 ` ✗ warning: Fi.CI.BAT Patchwork
2015-12-18 14:00 ` 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=20151222090323.GO30437@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --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.