2012-08-24 04:35:44

by Hiroshi Doyu

[permalink] [raw]
Subject: [v3 1/1] driver-core: Shut up dev_dbg_reatelimited() without DEBUG

dev_dbg_reatelimited() without DEBUG printed "217078 callbacks
suppressed". This shouldn't print anything without DEBUG.

With CONFIG_DYNAMIC_DEBUG, the print should be configured as expected.

Signed-off-by: Hiroshi Doyu <[email protected]>
Reported-by: Hin-Tak Leung <[email protected]>
Tested-by: Antti Palosaari <[email protected]>
Acked-by: Hin-Tak Leung <[email protected]>
---
include/linux/device.h | 62 +++++++++++++++++++++++++++++------------------
1 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 9648331..bb6ffcb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -932,6 +932,32 @@ int _dev_info(const struct device *dev, const char *fmt, ...)

#endif

+/*
+ * Stupid hackaround for existing uses of non-printk uses dev_info
+ *
+ * Note that the definition of dev_info below is actually _dev_info
+ * and a macro is used to avoid redefining dev_info
+ */
+
+#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
+
+#if defined(CONFIG_DYNAMIC_DEBUG)
+#define dev_dbg(dev, format, ...) \
+do { \
+ dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
+} while (0)
+#elif defined(DEBUG)
+#define dev_dbg(dev, format, arg...) \
+ dev_printk(KERN_DEBUG, dev, format, ##arg)
+#else
+#define dev_dbg(dev, format, arg...) \
+({ \
+ if (0) \
+ dev_printk(KERN_DEBUG, dev, format, ##arg); \
+ 0; \
+})
+#endif
+
#define dev_level_ratelimited(dev_level, dev, fmt, ...) \
do { \
static DEFINE_RATELIMIT_STATE(_rs, \
@@ -955,33 +981,21 @@ do { \
dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
#define dev_info_ratelimited(dev, fmt, ...) \
dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
+#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
#define dev_dbg_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_dbg, dev, fmt, ##__VA_ARGS__)
-
-/*
- * Stupid hackaround for existing uses of non-printk uses dev_info
- *
- * Note that the definition of dev_info below is actually _dev_info
- * and a macro is used to avoid redefining dev_info
- */
-
-#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
-
-#if defined(CONFIG_DYNAMIC_DEBUG)
-#define dev_dbg(dev, format, ...) \
-do { \
- dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
+do { \
+ static DEFINE_RATELIMIT_STATE(_rs, \
+ DEFAULT_RATELIMIT_INTERVAL, \
+ DEFAULT_RATELIMIT_BURST); \
+ DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
+ if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
+ __ratelimit(&_rs)) \
+ __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
+ ##__VA_ARGS__); \
} while (0)
-#elif defined(DEBUG)
-#define dev_dbg(dev, format, arg...) \
- dev_printk(KERN_DEBUG, dev, format, ##arg)
#else
-#define dev_dbg(dev, format, arg...) \
-({ \
- if (0) \
- dev_printk(KERN_DEBUG, dev, format, ##arg); \
- 0; \
-})
+#define dev_dbg_ratelimited(dev, fmt, ...) \
+ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif

#ifdef VERBOSE_DEBUG
--
1.7.5.4


2012-08-25 07:12:40

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [v3 1/1] driver-core: Shut up dev_dbg_reatelimited() without DEBUG

--- On Fri, 24/8/12, Hiroshi Doyu <[email protected]> wrote:

> From: Hiroshi Doyu <[email protected]>
> Subject: [v3 1/1] driver-core: Shut up dev_dbg_reatelimited() without DEBUG
> To: "[email protected]" <[email protected]>
> Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
> Date: Friday, 24 August, 2012, 5:35
> dev_dbg_reatelimited() without DEBUG
> printed "217078 callbacks
> suppressed". This shouldn't print anything without DEBUG.
>
> With CONFIG_DYNAMIC_DEBUG, the print should be configured as
> expected.
>
> Signed-off-by: Hiroshi Doyu <[email protected]>
> Reported-by: Hin-Tak Leung <[email protected]>
> Tested-by: Antti Palosaari <[email protected]>
> Acked-by: Hin-Tak Leung <[email protected]>

Tested-by: Hin-Tak Leung <[email protected]>

Went ahead and patched my 2.5.x distro kernel-devel package header, and it works as expected. Apologies about the red-herring with media_build (for those who are not familar with it, = "back-port" wrapper package for building new DVB modules against older kernels).

The distro kernel-devel headers is per installed distro kernel so will be replaced in a week or two... no permanent demage done :-).

> ---
> include/linux/device.h |???62
> +++++++++++++++++++++++++++++------------------
> 1 files changed, 38 insertions(+), 24 deletions(-)
>
> diff --git a/include/linux/device.h
> b/include/linux/device.h
> index 9648331..bb6ffcb 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -932,6 +932,32 @@ int _dev_info(const struct device *dev,
> const char *fmt, ...)
>
> #endif
>
> +/*
> + * Stupid hackaround for existing uses of non-printk uses
> dev_info
> + *
> + * Note that the definition of dev_info below is actually
> _dev_info
> + * and a macro is used to avoid redefining dev_info
> + */
> +
> +#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt,
> ##arg)
> +
> +#if defined(CONFIG_DYNAMIC_DEBUG)
> +#define dev_dbg(dev, format, ...)???
> ??? ? ???\
> +do {??? ???
> ??? ??? ???
> ??? ? ???\
> +??? dynamic_dev_dbg(dev, format,
> ##__VA_ARGS__); \
> +} while (0)
> +#elif defined(DEBUG)
> +#define dev_dbg(dev, format, arg...)???
> ??? \
> +??? dev_printk(KERN_DEBUG, dev, format,
> ##arg)
> +#else
> +#define dev_dbg(dev, format, arg...)???
> ??? ??? ??? \
> +({??? ??? ???
> ??? ??? ???
> ??? ??? \
> +??? if (0)???
> ??? ??? ???
> ??? ??? ??? \
> +??? ???
> dev_printk(KERN_DEBUG, dev, format,
> ##arg);??? \
> +??? 0;??? ???
> ??? ??? ???
> ??? ??? \
> +})
> +#endif
> +
> #define dev_level_ratelimited(dev_level, dev, fmt,
> ...)??? ??? ???
> \
> do {??? ???
> ??? ??? ???
> ??? ??? ???
> ??? \
> ??? static
> DEFINE_RATELIMIT_STATE(_rs,???
> ??? ??? ??? \
> @@ -955,33 +981,21 @@ do {???
> ??? ??? ???
> ??? ??? ???
> ??? ??? \
> ??? dev_level_ratelimited(dev_notice, dev,
> fmt, ##__VA_ARGS__)
> #define dev_info_ratelimited(dev, fmt,
> ...)??? ??? ???
> ??? \
> ??? dev_level_ratelimited(dev_info, dev,
> fmt, ##__VA_ARGS__)
> +#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
> #define dev_dbg_ratelimited(dev, fmt,
> ...)??? ??? ???
> ??? \
> -??? dev_level_ratelimited(dev_dbg, dev, fmt,
> ##__VA_ARGS__)
> -
> -/*
> - * Stupid hackaround for existing uses of non-printk uses
> dev_info
> - *
> - * Note that the definition of dev_info below is actually
> _dev_info
> - * and a macro is used to avoid redefining dev_info
> - */
> -
> -#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt,
> ##arg)
> -
> -#if defined(CONFIG_DYNAMIC_DEBUG)
> -#define dev_dbg(dev, format, ...)???
> ??? ? ???\
> -do {??? ???
> ??? ??? ???
> ??? ? ???\
> -??? dynamic_dev_dbg(dev, format,
> ##__VA_ARGS__); \
> +do {??? ???
> ??? ??? ???
> ??? ??? ???
> ??? \
> +??? static
> DEFINE_RATELIMIT_STATE(_rs,???
> ??? ??? ??? \
> +??? ??? ???
> ??? ? ? ?
> DEFAULT_RATELIMIT_INTERVAL,??? \
> +??? ??? ???
> ??? ? ? ?
> DEFAULT_RATELIMIT_BURST);???
> ??? \
> +???
> DEFINE_DYNAMIC_DEBUG_METADATA(descriptor,
> fmt);??? ???
> ??? \
> +??? if (unlikely(descriptor.flags &
> _DPRINTK_FLAGS_PRINT) &&??? \
> +??? ? ?
> __ratelimit(&_rs))??? ???
> ??? ??? ???
> ??? \
> +??? ???
> __dynamic_pr_debug(&descriptor,
> pr_fmt(fmt),??? ??? \
> +??? ??? ???
> ???
> ???##__VA_ARGS__);???
> ??? ??? \
> } while (0)
> -#elif defined(DEBUG)
> -#define dev_dbg(dev, format, arg...)???
> ??? \
> -??? dev_printk(KERN_DEBUG, dev, format,
> ##arg)
> #else
> -#define dev_dbg(dev, format, arg...)???
> ??? ??? ??? \
> -({??? ??? ???
> ??? ??? ???
> ??? ??? \
> -??? if (0)???
> ??? ??? ???
> ??? ??? ??? \
> -??? ???
> dev_printk(KERN_DEBUG, dev, format,
> ##arg);??? \
> -??? 0;??? ???
> ??? ??? ???
> ??? ??? \
> -})
> +#define dev_dbg_ratelimited(dev, fmt,
> ...)??? ??? ???
> \
> +??? no_printk(KERN_DEBUG pr_fmt(fmt),
> ##__VA_ARGS__)
> #endif
>
> #ifdef VERBOSE_DEBUG
> --
> 1.7.5.4
>