diff mbox series

[RFC] Make dynamic debug infrastructure more flexible

Message ID 5bb4b918aec3c77038122588ee642ae4aa2a09b0.camel@perches.com (mailing list archive)
State New, archived
Headers show
Series [RFC] Make dynamic debug infrastructure more flexible | expand

Commit Message

Joe Perches May 21, 2020, 8:06 p.m. UTC
On Thu, 2020-05-21 at 09:08 -0700, Joe Perches wrote:
> On Thu, 2020-05-21 at 16:28 +0300, Stanimir Varbanov wrote:
> > Here we introduce few debug macros with levels (low, medium and
> > high) and debug macro for firmware. Enabling the particular level
> > will be done by dynamic debug.
> 
> I'd rather make the logging level facility generic in
> dynamic debug than prefix all formats with what could
> be non-specific content.
> 
> From a long time ago:
> 
> https://groups.google.com/forum/#!msg/linux.kernel/VlWbno-ZAFw/k_fFadhNHXcJ

Hey Jason.

I believe there are 6 bits left in the unsigned int
use for the line number and flags in struct _ddebug

Assuming the use of a mechanism like

	pr_debug_level(level, fmt, ...)

would you be OK with something like this to enable a
level or bitmask test of dynamic debug logging output?

where the output is controlled by something like

echo 'file <filename> level <n> +p' > <debugfs>/dynamic_debug/control

to enable dynamic debug output only at level <n> or higher
or maybe match a bitmap of <n>

(modulo all the rest of the code necessary to use it?)
---
 include/linux/dynamic_debug.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jason Baron May 21, 2020, 9:10 p.m. UTC | #1
On 5/21/20 4:06 PM, Joe Perches wrote:
> On Thu, 2020-05-21 at 09:08 -0700, Joe Perches wrote:
>> On Thu, 2020-05-21 at 16:28 +0300, Stanimir Varbanov wrote:
>>> Here we introduce few debug macros with levels (low, medium and
>>> high) and debug macro for firmware. Enabling the particular level
>>> will be done by dynamic debug.
>>
>> I'd rather make the logging level facility generic in
>> dynamic debug than prefix all formats with what could
>> be non-specific content.
>>
>> From a long time ago:
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_forum_-23-21msg_linux.kernel_VlWbno-2DZAFw_k-5FfFadhNHXcJ&d=DwICAw&c=96ZbZZcaMF4w0F4jpN6LZg&r=1fLh1mlLqbfetnnGsbwXfpwmGlG4m83mXgtV4vZ1B1A&m=frs_z9MmQ_bzjMWZc5gnzdbuAHVi2EWsCO7ikUkszv4&s=Cbij9ptIrxbwB3XJNp8lxXrdTDi8T2s5XlB1llRbmjU&e= 
> 
> Hey Jason.
> 
> I believe there are 6 bits left in the unsigned int
> use for the line number and flags in struct _ddebug
> 
> Assuming the use of a mechanism like
> 
> 	pr_debug_level(level, fmt, ...)
> 
> would you be OK with something like this to enable a
> level or bitmask test of dynamic debug logging output?
> 
> where the output is controlled by something like
> 
> echo 'file <filename> level <n> +p' > <debugfs>/dynamic_debug/control
> 
> to enable dynamic debug output only at level <n> or higher
> or maybe match a bitmap of <n>
> 
> (modulo all the rest of the code necessary to use it?)

Hi Joe,

Yes, I think its good idea. I think in the past I felt that since
we could enable/disable statements individually it wasn't needed.
However, the ability to group in the kernel seems like a better
layer. I think we were also missing a specific use-case. Seems
like we have that here. So makes sense to me.

Thanks,

-Jason



> ---
>  include/linux/dynamic_debug.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> index abcd5fde30eb..616dbb2b5921 100644
> --- a/include/linux/dynamic_debug.h
> +++ b/include/linux/dynamic_debug.h
> @@ -38,6 +38,8 @@ struct _ddebug {
>  #define _DPRINTK_FLAGS_DEFAULT 0
>  #endif
>  	unsigned int flags:8;
> +	unsigned int level:5;
> +	unsigned int level_is_bitmask:1;
>  #ifdef CONFIG_JUMP_LABEL
>  	union {
>  		struct static_key_true dd_key_true;
> 
>
Stanimir Varbanov May 21, 2020, 10:39 p.m. UTC | #2
Hi Joe, Jason,

On 5/21/20 11:06 PM, Joe Perches wrote:
> On Thu, 2020-05-21 at 09:08 -0700, Joe Perches wrote:
>> On Thu, 2020-05-21 at 16:28 +0300, Stanimir Varbanov wrote:
>>> Here we introduce few debug macros with levels (low, medium and
>>> high) and debug macro for firmware. Enabling the particular level
>>> will be done by dynamic debug.
>>
>> I'd rather make the logging level facility generic in
>> dynamic debug than prefix all formats with what could
>> be non-specific content.

I like the idea. To be honest I researched the dynamic debug for such
level debugging facility but found it will be too complex to implement.
I guess now when you catch me it will be better to add it in dyndbg ;) .

>>
>> From a long time ago:
>>
>> https://groups.google.com/forum/#!msg/linux.kernel/VlWbno-ZAFw/k_fFadhNHXcJ
> 
> Hey Jason.
> 
> I believe there are 6 bits left in the unsigned int
> use for the line number and flags in struct _ddebug
> 
> Assuming the use of a mechanism like
> 
> 	pr_debug_level(level, fmt, ...)
> 
> would you be OK with something like this to enable a
> level or bitmask test of dynamic debug logging output?
> 
> where the output is controlled by something like
> 
> echo 'file <filename> level <n> +p' > <debugfs>/dynamic_debug/control

I guess for bitmask it should be?

echo 'file <> bitmask <0xn> +p' >  $CONTROL

> 
> to enable dynamic debug output only at level <n> or higher
> or maybe match a bitmap of <n>
> 
> (modulo all the rest of the code necessary to use it?)
> ---
>  include/linux/dynamic_debug.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> index abcd5fde30eb..616dbb2b5921 100644
> --- a/include/linux/dynamic_debug.h
> +++ b/include/linux/dynamic_debug.h
> @@ -38,6 +38,8 @@ struct _ddebug {
>  #define _DPRINTK_FLAGS_DEFAULT 0
>  #endif
>  	unsigned int flags:8;
> +	unsigned int level:5;
> +	unsigned int level_is_bitmask:1;
>  #ifdef CONFIG_JUMP_LABEL
>  	union {
>  		struct static_key_true dd_key_true;
> 
>
diff mbox series

Patch

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index abcd5fde30eb..616dbb2b5921 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -38,6 +38,8 @@  struct _ddebug {
 #define _DPRINTK_FLAGS_DEFAULT 0
 #endif
 	unsigned int flags:8;
+	unsigned int level:5;
+	unsigned int level_is_bitmask:1;
 #ifdef CONFIG_JUMP_LABEL
 	union {
 		struct static_key_true dd_key_true;