Skip to contentSkip to conversation

drm: Don't split up debug output

PATCH In review Daniel Vetter 2 participants 2 messages Nov 17, 2013 – Nov 18, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Don't split up debug output

Otherwise we risk that the 2nd part of the line ends up on a line of it's own, which means a kernel dmesg line without a log level. This then upsets the dmesg checker in piglit.

Only really happens in some of the truly nasty igt testcases which race cache dropping (through debugfs) with other gem operations.

---
 drivers/gpu/drm/drm_stub.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_stub.c +9 -3
index f53d5246979c..74e0357c1c38 100644
@@ -99,13 +99,19 @@ void drm_ut_debug_printk(unsigned int request_level,
 			 const char *function_name,
 			 const char *format, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
 	if (drm_debug & request_level) {
-		if (function_name)
-			printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
 		va_start(args, format);
-		vprintk(format, args);
+		vaf.fmt = format;
+		vaf.va = &args;
+
+		if (function_name)
+			printk(KERN_DEBUG "[%s:%s], %pV", prefix,
+			       function_name, &vaf);
+		else
+			printk(KERN_DEBUG "%pV", &vaf);
 		va_end(args);
 	}
 }
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Daniel Vetter

Otherwise we risk that the 2nd part of the line ends up on a line of it's own, which means a kernel dmesg line without a log level. This then upsets the dmesg checker in piglit.

Only really happens in some of the truly nasty igt testcases which race cache dropping (through debugfs) with other gem operations.

---
 drivers/gpu/drm/drm_stub.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_stub.c +2 -3
index f53d5246979c..74e0357c1c38 100644
@@ -99,13 +99,19 @@ void drm_ut_debug_printk(unsigned int request_level,
 			 const char *function_name,
 			 const char *format, ...)
 {
+	struct va_format vaf;
 	va_list args;
 
 	if (drm_debug & request_level) {
-		if (function_name)
-			printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
 		va_start(args, format);
-		vprintk(format, args);
+		vaf.fmt = format;

drivers/gpu/drm/drm_stub.c void drm_ut_debug_printk(unsigned int request_level, · line 117

Quoted 10 lines
drivers/gpu/drm/drm_stub.c +7 -0
+		vaf.va = &args;
+
+		if (function_name)
+			printk(KERN_DEBUG "[%s:%s], %pV", prefix,
+			       function_name, &vaf);
+		else
+			printk(KERN_DEBUG "%pV", &vaf);
 		va_end(args);
 	}
 }

According to Documentation/printk-formats.txt, usage of %pV is not recommended unless the format string and va_list can be properly verified for correctness.

I guess we leave it up to the compiler to do that verification using the __printf() annotation, so I think it should be fine to use it here:

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx