2006-11-01 13:51:09

by Glauber Costa

[permalink] [raw]
Subject: [PATCH] use printk_ratelimit() inside DRM_DEBUG

--- linux-2.6.18.x86_64/drivers/char/drm/drmP.h.orig 2006-11-01 08:00:18.000000000 -0500
+++ linux-2.6.18.x86_64/drivers/char/drm/drmP.h 2006-11-01 08:06:27.000000000 -0500
@@ -185,7 +185,7 @@
#if DRM_DEBUG_CODE
#define DRM_DEBUG(fmt, arg...) \
do { \
- if ( drm_debug ) \
+ if ( drm_debug && printk_ratelimit() ) \
printk(KERN_DEBUG \
"[" DRM_NAME ":%s] " fmt , \
__FUNCTION__ , ##arg); \


Attachments:
(No filename) (275.00 B)
drm_debug.patch (443.00 B)
Download all attachments

2006-11-01 20:06:55

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] use printk_ratelimit() inside DRM_DEBUG

On Wed, 1 Nov 2006 10:50:51 -0300
Glauber de Oliveira Costa <[email protected]> wrote:

> the DRM_DEBUG macro can be called within functions very oftenly
> triggered, thus generating lots of message load and potentially
> compromising system
>
> Signed-off-by: Glauber de Oliveira Costa <[email protected]>
>
> --
> Glauber de Oliveira Costa
> Red Hat Inc.
> "Free as in Freedom"
>
>
> [drm_debug.patch text/plain (444B)]
> --- linux-2.6.18.x86_64/drivers/char/drm/drmP.h.orig 2006-11-01 08:00:18.000000000 -0500
> +++ linux-2.6.18.x86_64/drivers/char/drm/drmP.h 2006-11-01 08:06:27.000000000 -0500
> @@ -185,7 +185,7 @@
> #if DRM_DEBUG_CODE
> #define DRM_DEBUG(fmt, arg...) \
> do { \
> - if ( drm_debug ) \
> + if ( drm_debug && printk_ratelimit() ) \
> printk(KERN_DEBUG \
> "[" DRM_NAME ":%s] " fmt , \
> __FUNCTION__ , ##arg); \


DRM_DEBUG() should be disabled in production code, and enabled only when
developers are developing stuff. In the latter case, the developer wants
to see all the messages.

IOW, don't load the drm module with the `debug' parameter.