Optimize WARN_ON macros
Subsystems (2)
Joonas Lahtinen
maintainercover Optimize WARN_ON macros
Joonas Lahtinen (2):
drm/i915: Simplify _STATE_ debug macros drm/i915: Compile time concatenate WARN_ON macro strings
drivers/gpu/drm/i915/i915_drv.h | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
Signature · 6 lines
2.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerPATCH 1/2 drm/i915: Simplify _STATE_ debug macros
Take advantage of WARN return value to simplify the flow.
--- drivers/gpu/drm/i915/i915_drv.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -10
@@ -87,23 +87,18 @@*/ #define I915_STATE_WARN(condition, format...) ({ \ int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) { \ - if (i915.verbose_state_checks) \ - WARN(1, format); \ - else \ + if (unlikely(__ret_warn_on)) \ + if (!WARN(i915.verbose_state_checks, format)) \ DRM_ERROR(format); \ - } \ unlikely(__ret_warn_on); \ })#define I915_STATE_WARN_ON (condition) ({ \ int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) { \ - if (i915.verbose_state_checks) \ - WARN(1, "WARN_ON(" #condition ")\n"); \ - else \ + 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); \ })
Signature · 6 lines
2.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerPATCH 2/2 drm/i915: Compile time concatenate WARN_ON macro strings
In reply to Joonas LahtinenUsing __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.
v2:
- Define I915_STATE_WARN_ON though I915_STATE_WARN (Bikeshed inspiration by Chris)
--- drivers/gpu/drm/i915/i915_drv.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -10
@@ -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__);
@@ -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), "WARN_ON(" __stringify(x) ")")static inline const char *yesno (bool v) {
Signature · 6 lines
2.4.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings
Quoted 5 lines · Joonas Lahtinen
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.
Quoted 8 lines
v2:
- DefineI915_STATE_WARN_ONthoughI915_STATE_WARN(Bikeshed inspiration by Chris)Cc Rob Clark <[email protected]>Cc Chris Wilson <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>
Neat. Both
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Dave Gordon
NAKRe: [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings
In reply to Joonas LahtinenQuoted 42 lines · Joonas Lahtinen
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.
v2:
- DefineI915_STATE_WARN_ONthoughI915_STATE_WARN(Bikeshed inspiration by Chris)Cc Rob Clark <[email protected]>Cc Chris Wilson <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +2
-5@@ -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__);@@ -93,14 +93,8 @@unlikely (__ret_warn_on); \ }) -#define I915_STATE_WARN_ON (condition) ({ \ - int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) \
drivers/gpu/drm/i915/i915_drv.h line 100
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +2
-5- 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), "WARN_ON(" __stringify(x) ")")static inline const char *yesno (bool v) {
NAK.
This will give compile-time warnings for lines such as:
WARN_ON(x%16 != 0);
because the stringified text of the expression (which in this case contains a "%" character) would appear as part of the format string, rather than inside an argument. See:
4eee492 drm/i915: fix driver's versions of WARN_ON & WARN_ON_ONCE
.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings
Quoted 19 lines · Dave Gordon
Quoted 18 lines · Joonas Lahtinen
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.
v2:
- DefineI915_STATE_WARN_ONthoughI915_STATE_WARN(Bikeshed inspiration by Chris)Cc Rob Clark <[email protected]>Cc Chris Wilson <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
<SNIP>
Quoted 14 lines
drivers/gpu/drm/i915/i915_drv.h line 100
Quoted 9 lines
\
(quoted diff) +1
-1-}) +#define I915_STATE_WARN_ON(x)\drivers/gpu/drm/i915/i915_drv.h +1
-0+ I915_STATE_WARN((x), "WARN_ON(" __stringify(x) ")")static inline const char *yesno (bool v) {NAK.
This will give compile-time warnings for lines such as:
Quoted 8 lines
WARN_ON(x%16 != 0);because the stringified text of the expression (which in this case contains a "%" character) would appear as part of the format string, rather than inside an argument. See:
4eee492 drm/i915: fix driver's versions of
WARN_ON&WARN_ON_ONCE
Great catch, I'll change it to have preceding "%s". Did not get any compile-time warning though, this would be something caught by a (rather advanced?) static analysis.
Regards, Joonas
Quoted 1 line
.Dave.
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings
Quoted 43 lines · Joonas Lahtinen
Quoted 19 lines · Dave Gordon
Quoted 18 lines · Joonas Lahtinen
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.
v2:
- DefineI915_STATE_WARN_ONthoughI915_STATE_WARN(Bikeshed inspiration by Chris)Cc Rob Clark <[email protected]>Cc Chris Wilson <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)<SNIP>
Quoted 20 lines
drivers/gpu/drm/i915/i915_drv.h line 100
Quoted 9 lines
\
(quoted diff) +1
-1-}) +#define I915_STATE_WARN_ON(x)\drivers/gpu/drm/i915/i915_drv.h +1
-0+ I915_STATE_WARN((x), "WARN_ON(" __stringify(x) ")")static inline const char *yesno (bool v) {NAK.
This will give compile-time warnings for lines such as:
WARN_ON(x%16 != 0);because the stringified text of the expression (which in this case contains a "%" character) would appear as part of the format string, rather than inside an argument. See:
Quoted 6 lines
Quoted 2 lines
4eee492 drm/i915: fix driver's versions of
WARN_ON&WARN_ON_ONCEGreat catch, I'll change it to have preceding "%s". Did not get any compile-time warning though, this would be something caught by a (rather advanced?) static analysis.
New gcc seems to complain about this. At least since a few weeks I've seen a few patches for kernel-wide changes to address this float about. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ warning: Fi.CI.BAT
In reply to Joonas Lahtinen== Summary ==
== Summary ==
Built on 3c71db89fc37b6061ce6b070ce73f89155da5f20 drm-intel-nightly: 2015y-12m-18d-09h-42m-49s UTC integration manifest
Test igt@kms_flip@basic-flip-vs-wf_vblank on ivb-t430s pass -> dmesg-warn Test igt@kms_flip@basic-flip-vs-wf_vblank on byt-nuc dmesg-warn -> skip Test igt@kms_flip@basic-flip-vs-wf_vblank on bsw-nuc-2 pass -> dmesg-warn Test igt@kms_pipe_crc_basic@hang-read-crc-pipe-b on byt-nuc pass -> skip Test igt@kms_pipe_crc_basic@hang-read-crc-pipe-a on ivb-t430s dmesg-warn -> pass Test igt@gem_mmap@basic on byt-nuc dmesg-warn -> pass
Test igt@kms_flip@basic-flip-vs-dpms on byt-nuc pass -> skip
Test igt@drv_module_reload_basic on byt-nuc pass -> dmesg-warn
Test igt@kms_flip@basic-plain-flip on bsw-nuc-2 pass -> dmesg-warn Test igt@gem_mmap_gtt@basic-write on bsw-nuc-2 dmesg-warn -> pass Test igt@kms_pipe_crc_basic@read-crc-pipe-a on snb-x220t dmesg-warn -> pass Test igt@kms_pipe_crc_basic@read-crc-pipe-a on byt-nuc dmesg-warn -> pass Test igt@kms_pipe_crc_basic@read-crc-pipe-c on skl-i5k-2 dmesg-warn -> pass Test igt@kms_flip@basic-flip-vs-modeset on snb-x220t pass -> dmesg-warn Test igt@kms_flip@basic-flip-vs-modeset on hsw-brixbox dmesg-warn -> pass Test igt@kms_flip@basic-flip-vs-modeset on skl-i5k-2 pass -> dmesg-warn
bdw-nuci7 total:135 pass:125 dwarn:1 dfail:0 fail:0 skip:9 bsw-nuc-2 total:135 pass:113 dwarn:2 dfail:0 fail:0 skip:20 byt-nuc total:135 pass:117 dwarn:2 dfail:0 fail:0 skip:16 hsw-brixbox total:135 pass:127 dwarn:1 dfail:0 fail:0 skip:7 hsw-gt2 total:135 pass:130 dwarn:1 dfail:0 fail:0 skip:4 ilk-hp8440p total:135 pass:100 dwarn:0 dfail:0 fail:2 skip:33 ivb-t430s total:135 pass:128 dwarn:1 dfail:1 fail:1 skip:4 skl-i5k-2 total:135 pass:122 dwarn:5 dfail:0 fail:0 skip:8 skl-i7k-2 total:135 pass:123 dwarn:4 dfail:0 fail:0 skip:8 snb-dellxps total:135 pass:121 dwarn:2 dfail:0 fail:0 skip:12 snb-x220t total:135 pass:121 dwarn:2 dfail:0 fail:1 skip:11
Results at /archive/results/CI_IGT_test/Patchwork_713/
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx