usbatm: printk_ratelimit() always called in the atm_rldbg()
Hi,
commit 2d6401cf4ca3861692a4779745e0049cac769d10 ("USB: usbatm: move the atm_dbg() call to use dynamic debug") changed the atm_rldbg() to:
#define atm_rldbg(instance, format, arg...) \ if (printk_ratelimit()) \ atm_dbg(instance , format , ## arg)
and now printk_ratelimit() is always called even when debugging is disabled and a lot of "callbacks suppressed" messages are printed by the printk_ratelimit():
[...]usbatm_rx_process: 4977 callbacks suppressedusbatm_extract_one_cell: 2920 callbacks suppressed [...]
I'm not sure how to fix that, maybe we need dynamic_pr_debug_ratelimit()?
Krzysiek
Greg Kroah-Hartman
maintainerQuoted 14 lines · Krzysztof Mazur
Hi,
commit
2d6401cf4ca3861692a4779745e0049cac769d10("USB: usbatm: move theatm_dbg()call to use dynamic debug") changed theatm_rldbg()to:#define atm_rldbg(instance, format, arg...) \ if (printk_ratelimit()) \ atm_dbg(instance , format , ## arg)and now
printk_ratelimit()is always called even when debugging is disabled and a lot of "callbacks suppressed" messages are printed by theprintk_ratelimit():
Quoted 7 lines
[...]
usbatm_rx_process: 4977 callbacks suppressedusbatm_extract_one_cell: 2920 callbacks suppressed [...]I'm not sure how to fix that, maybe we need
dynamic_pr_debug_ratelimit()?
How about just deleting the use of that macro entirely? Odds are it's not really needed anymore, right?
thanks,
greg k-h
PATCH 1/1 printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
pr_debug_ratelimited should be coded similar to dev_dbg_ratelimited to reduce the "callbacks suppressed" messages.
---
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 lines · Krzysztof Mazur
Hi,
commit
2d6401cf4ca3861692a4779745e0049cac769d10("USB: usbatm: move theatm_dbg()call to use dynamic debug") changed theatm_rldbg()to:#define atm_rldbg(instance, format, arg...) \ if (printk_ratelimit()) \ atm_dbg(instance , format , ## arg)and now
printk_ratelimit()is always called even when debugging is disabled and a lot of "callbacks suppressed" messages are printed by theprintk_ratelimit():[...]
usbatm_rx_process: 4977 callbacks suppressedusbatm_extract_one_cell: 2920 callbacks suppressed [...]
Quoted 4 lines
Quoted 1 line
I'm not sure how to fix that, maybe we need
dynamic_pr_debug_ratelimit()?How about just deleting the use of that macro entirely? Odds are it's not really needed anymore, right?
include/linux/printk.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
include/linux/printk.h +13 -1
@@ -343,7 +343,19 @@ extern asmlinkage void dump_stack(void) __cold;#endif /* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) +#if defined(CONFIG_DYNAMIC_DEBUG ) +/* descriptor check is first to prevent flooding with "callbacks suppressed" */ +#define pr_debug_ratelimited (dev, fmt, ...) \ +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(fmt, ##__VA_ARGS__); \ +} while (0) +#elif defined(DEBUG )#define pr_debug_ratelimited (fmt, ...) \ printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)#else
Greg Kroah-Hartman
maintainerRe: [PATCH] printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
Quoted 4 lines · Joe Perches
pr_debug_ratelimitedshould be coded similar todev_dbg_ratelimitedto reduce the "callbacks suppressed" messages.Signed-off-by Joe Perches <[email protected]>
Looks good, I'll queue both of these up soon.
greg k-h
Re: [PATCH] printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Joe Perches
pr_debug_ratelimitedshould be coded similar todev_dbg_ratelimitedto reduce the "callbacks suppressed" messages.Signed-off-by Joe Perches <[email protected]>Looks good, I'll queue both of these up soon.
Sorry Greg, hand out the brown paper bag please.
Just ignore these both, I'll resubmit properly tested ones.
PATCH v2 1/1 printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
In reply to Greg Kroah-Hartmanpr_debug_ratelimited should be coded similarly to dev_dbg_ratelimited to reduce the "callbacks suppressed" messages.
Add #include <linux/dynamic_debug.h> to printk.h. Unfortunately, this new #include must be after the prototype/declaration of function printk.
It may be better to split out these _ratelimited declarations into a separate file one day.
Any use of these pr_<foo>_ratelimited functions must also have another specific #include <ratelimited.h>. Most users have this done indirectly via #include <linux/kernel.h>
printk.h may not #include <linux/ratelimit.h> as it causes circular dependencies and compilation failures.
---
V2: Fix #include dependencies and typos.
Compile tested with and without CONFIG_DYNAMIC_DEBUG
It looks to me as if device.h should also have #include <dynamic_debug.h> It currently gets the #include indirectly via kobject.h -> kernel.h.
include/linux/printk.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
include/linux/printk.h +15 -1
@@ -233,6 +233,8 @@ extern asmlinkage void dump_stack(void) __cold; no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)#endif +#include <linux/dynamic_debug.h> +/* If you are writing a driver, please use dev_dbg instead */ #if defined(CONFIG_DYNAMIC_DEBUG )/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
@@ -343,7 +345,19 @@ extern asmlinkage void dump_stack(void) __cold;#endif /* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) +#if defined(CONFIG_DYNAMIC_DEBUG ) +/* descriptor check is first to prevent flooding with "callbacks suppressed" */ +#define pr_debug_ratelimited (fmt, ...) \ +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, fmt, ##__VA_ARGS__); \ +} while (0) +#elif defined(DEBUG )#define pr_debug_ratelimited (fmt, ...) \ printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)#else
Re: [PATCH V2] printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
Quoted 13 lines · Joe Perches
pr_debug_ratelimitedshould be coded similarly todev_dbg_ratelimitedto reduce the "callbacks suppressed" messages.Add #include <
linux/dynamic_debug.h> toprintk.h. Unfortunately, this new #include must be after the prototype/declaration of function printk.It may be better to split out these
_ratelimiteddeclarations into a separate file one day.Any use of these pr_<foo>_ratelimited functions must also have another specific #include <
ratelimited.h>. Most users have this done indirectly via #include <linux/kernel.h>
Quoted 8 lines
printk.hmay not #include <linux/ratelimit.h> as it causes circular dependencies and compilation failures.Signed-off-by Joe Perches <[email protected]>---
V2: Fix #include dependencies and typos.Compile tested with and without
CONFIG_DYNAMIC_DEBUG
I've tested both patches without CONFIG_DYNAMIC_DEBUG and with enabled and disabled debugging with CONFIG_DYNAMIC_DEBUG and everything seems work correctly.
Thanks,
Krzysiek
PATCH 1/1 atmusb: Fix dynamic_debug macros
In reply to Greg Kroah-HartmanFix use of atm_dbg to all normal pr_debug not dynamic_pr_debug because dynamic_pr_debug may not be compiled in at all.
--- drivers/usb/atm/usbatm.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/usb/atm/usbatm.h +6 -7
@@ -59,13 +59,12 @@ atm_printk(KERN_INFO, instance , format , ## arg) #define atm_warn(instance, format, arg...) \ atm_printk(KERN_WARNING, instance , format , ## arg) -#define atm_dbg(instance, format, arg...) \ - dynamic_pr_debug("ATM dev %d: " format , \ - (instance)->atm_dev->number , ## arg) -#define atm_rldbg(instance, format, arg...) \ - if (printk_ratelimit()) \ - atm_dbg(instance , format , ## arg) - +#define atm_dbg(instance, format, arg...) \ + pr_debug("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__) +#define atm_rldbg(instance, format, arg...) \ + pr_debug_ratelimited("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__)/* flags, set by mini-driver in bind() */
Re: [PATCH] atmusb: Fix dynamic_debug macros
Quoted 2 lines · Joe Perches
Fix use of
atm_dbgto all normalpr_debugnotdynamic_pr_debugbecausedynamic_pr_debugmay not be compiled in at all.
Greg, please don't apply this one.
I'll resubmit one that actually works.
(the arg...) should be ...
Quoted 1 line
+#define
atm_dbg(instance, format, arg...)\
^ oops.
drivers/usb/atm/usbatm.h line 67
Quoted 3 lines
drivers/usb/atm/usbatm.h +3
-0+#define atm_rldbg(instance, format, arg...) \ + pr_debug_ratelimited("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__)
here too.
Krzysztof Mazur
Tested-byRe: [PATCH] atmusb: Fix dynamic_debug macros
Quoted 9 lines · Joe Perches
Quoted 2 lines · Joe Perches
Fix use of
atm_dbgto all normalpr_debugnotdynamic_pr_debugbecausedynamic_pr_debugmay not be compiled in at all.Greg, please don't apply this one.
I'll resubmit one that actually works.(the arg...) should be ...
Quoted 9 lines
Quoted 1 line
+#define
atm_dbg(instance, format, arg...)\^ oops.drivers/usb/atm/usbatm.h line 67
Quoted 3 lines
drivers/usb/atm/usbatm.h +3
-0+#define atm_rldbg(instance, format, arg...) \ + pr_debug_ratelimited("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__)here too.
Yeah, I initially fixed that with changing "##__VAR_ARGS" to "## arg", but without with "arg..." -> "..." it also compiles and runs correctly.
I tested that only in my configuration - without DEBUG and DYNAMIC_DEBUG
- and compile tested that it with DYNAMIC_DEBUG. If you like you can add:
BTW: the driver is named usbatm, not atmusb.
Thanks,
Krzysiek
PATCH v2 1/1 usbatm: Fix dynamic_debug / ratelimited atm_dbg and atm_rldbg macros
In reply to Joe PerchesFix atm_dbg to use normal pr_debug not dynamic_pr_debug because dynamic_pr_debug may not be compiled in at all.
---
V2: Fix macro use of arg... vs ... typo
Fix usbatm vs atmusb typo (thanks Krzysiek)
drivers/usb/atm/usbatm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/atm/usbatm.h +7 -7
@@ -34,6 +34,7 @@#include <linux/stringify.h> #include <linux/usb.h> #include <linux/mutex.h> +#include <linux/ratelimit.h> /* #define VERBOSE_DEBUG
@@ -59,13 +60,12 @@ atm_printk(KERN_INFO, instance , format , ## arg) #define atm_warn(instance, format, arg...) \ atm_printk(KERN_WARNING, instance , format , ## arg) -#define atm_dbg(instance, format, arg...) \ - dynamic_pr_debug("ATM dev %d: " format , \ - (instance)->atm_dev->number , ## arg) -#define atm_rldbg(instance, format, arg...) \ - if (printk_ratelimit()) \ - atm_dbg(instance , format , ## arg) - +#define atm_dbg(instance, format, ...) \ + pr_debug("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__) +#define atm_rldbg(instance, format, ...) \ + pr_debug_ratelimited("ATM dev %d: " format, \ + (instance)->atm_dev->number, ##__VA_ARGS__) /* flags, set by mini-driver in bind() */