* [PATCH] reduce syslog clutter (take 2)
@ 2006-03-08 22:54 Tilman Schmidt
2006-03-09 5:47 ` Randy.Dunlap
2006-03-09 11:02 ` Andrew Morton
0 siblings, 2 replies; 10+ messages in thread
From: Tilman Schmidt @ 2006-03-08 22:54 UTC (permalink / raw)
To: linux-usb-devel; +Cc: hjlipp, linux-kernel, Greg KH
[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]
The current versions of the err() / info() / warn() syslog macros
insert __FILE__ at the beginning of the message, which expands to
the complete path name of the source file within the kernel tree.
With the following patch, when used in a module, they'll insert the
module name instead, which is significantly shorter and also tends to
be more useful to users trying to make sense of a particular message.
This patch replaces the one posted on 24 Feb 2006 10:50:52 +0100
which caused compile errors in non-modular drivers. It applies to
kernel 2.6.16-rc5 after the patch labeled
"add macros notice(), dev_notice() (take 2)".
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
---
usb.h | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
--- linux-2.6.16-rc5-patch-splitpoint/include/linux/usb.h 2006-03-08 12:36:03.000000000 +0100
+++ linux-2.6.16-rc5-patch-splitpoint2/include/linux/usb.h 2006-03-08 12:43:07.000000000 +0100
@@ -1199,14 +1199,20 @@
#define dbg(format, arg...) do {} while (0)
#endif
+#if defined(CONFIG_MODULES) && defined(THIS_MODULE)
+#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__
+#else
+#define KMSG_LOCATION_PREFIX __FILE__
+#endif
+
#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
- __FILE__ , ## arg)
+ KMSG_LOCATION_PREFIX , ## arg)
#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \
- __FILE__ , ## arg)
+ KMSG_LOCATION_PREFIX , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \
- __FILE__ , ## arg)
+ KMSG_LOCATION_PREFIX , ## arg)
#define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n" , \
- __FILE__ , ## arg)
+ KMSG_LOCATION_PREFIX , ## arg)
#endif /* __KERNEL__ */
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] reduce syslog clutter (take 2)
2006-03-08 22:54 [PATCH] reduce syslog clutter (take 2) Tilman Schmidt
@ 2006-03-09 5:47 ` Randy.Dunlap
2006-03-09 10:15 ` Tilman Schmidt
2006-03-09 11:02 ` Andrew Morton
1 sibling, 1 reply; 10+ messages in thread
From: Randy.Dunlap @ 2006-03-09 5:47 UTC (permalink / raw)
To: Tilman Schmidt; +Cc: linux-usb-devel, hjlipp, linux-kernel, gregkh
On Wed, 08 Mar 2006 23:54:23 +0100 Tilman Schmidt wrote:
> The current versions of the err() / info() / warn() syslog macros
> insert __FILE__ at the beginning of the message, which expands to
> the complete path name of the source file within the kernel tree.
>
> With the following patch, when used in a module, they'll insert the
> module name instead, which is significantly shorter and also tends to
> be more useful to users trying to make sense of a particular message.
>
> This patch replaces the one posted on 24 Feb 2006 10:50:52 +0100
> which caused compile errors in non-modular drivers. It applies to
> kernel 2.6.16-rc5 after the patch labeled
> "add macros notice(), dev_notice() (take 2)".
>
> Signed-off-by: Tilman Schmidt <tilman@imap.cc>
> ---
>
> usb.h | 14 ++++++++++----
> 1 files changed, 10 insertions(+), 4 deletions(-)
>
> --- linux-2.6.16-rc5-patch-splitpoint/include/linux/usb.h 2006-03-08 12:36:03.000000000 +0100
> +++ linux-2.6.16-rc5-patch-splitpoint2/include/linux/usb.h 2006-03-08 12:43:07.000000000 +0100
> @@ -1199,14 +1199,20 @@
> #define dbg(format, arg...) do {} while (0)
> #endif
>
> +#if defined(CONFIG_MODULES) && defined(THIS_MODULE)
> +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__
Can we get parens around the expression, please?
and does it make sense to test
#if defined(THIS_MODULE)
#define KMSG_LOCATION_PREFIX (THIS_MODULE ? ...
If that does make sense (the double testing of THIS_MODULE),
please explain why it does.
> +#else
> +#define KMSG_LOCATION_PREFIX __FILE__
> +#endif
> +
> #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
> - __FILE__ , ## arg)
> + KMSG_LOCATION_PREFIX , ## arg)
> #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \
> - __FILE__ , ## arg)
> + KMSG_LOCATION_PREFIX , ## arg)
> #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \
> - __FILE__ , ## arg)
> + KMSG_LOCATION_PREFIX , ## arg)
> #define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n" , \
> - __FILE__ , ## arg)
> + KMSG_LOCATION_PREFIX , ## arg)
>
>
> #endif /* __KERNEL__ */
---
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] reduce syslog clutter (take 2)
2006-03-09 5:47 ` Randy.Dunlap
@ 2006-03-09 10:15 ` Tilman Schmidt
0 siblings, 0 replies; 10+ messages in thread
From: Tilman Schmidt @ 2006-03-09 10:15 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: linux-usb-devel, hjlipp, linux-kernel, gregkh
[-- Attachment #1: Type: text/plain, Size: 2314 bytes --]
Randy.Dunlap wrote:
>> +#if defined(CONFIG_MODULES) && defined(THIS_MODULE)
>> +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__
>
> Can we get parens around the expression, please?
Will do.
> and does it make sense to test
> #if defined(THIS_MODULE)
> #define KMSG_LOCATION_PREFIX (THIS_MODULE ? ...
Unfortunately, it does.
> If that does make sense (the double testing of THIS_MODULE),
> please explain why it does.
We have the following cases:
- compiling without module support, source file not including linux/module.h
-> !defined(CONFIG_MODULES) && !defined(THIS_MODULE)
-> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
fails with undefined symbol THIS_MODULE
- compiling with module support, source file not including linux/module.h
-> defined(CONFIG_MODULES) && !defined(THIS_MODULE)
-> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
fails with undefined symbol THIS_MODULE
- compiling without module support, source file including linux/module.h
-> !defined(CONFIG_MODULES) && defined(THIS_MODULE)
-> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
fails because THIS_MODULE is defined as a NULL pointer to
struct module which in this case is an incomplete type (*sigh*)
- compiling with module support, source file including linux/module.h,
not compiling as a module
-> defined(CONFIG_MODULES) && defined(THIS_MODULE)
&& THIS_MODULE == ((struct module *)0)
-> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
succeeds (hooray), but THIS_MODULE is a NULL pointer, though this
time the type it points to is at least completely defined
- compiling with module support, source file including linux/module.h,
compiling as a module
-> defined(CONFIG_MODULES) && defined(THIS_MODULE)
&& THIS_MODULE == &__this_module
-> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
succeeds and THIS_MODULE can actualy be dereferenced
I would like the code to compile and run successfully in all these cases.
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] reduce syslog clutter (take 2)
2006-03-08 22:54 [PATCH] reduce syslog clutter (take 2) Tilman Schmidt
2006-03-09 5:47 ` Randy.Dunlap
@ 2006-03-09 11:02 ` Andrew Morton
2006-03-09 16:34 ` Randy.Dunlap
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2006-03-09 11:02 UTC (permalink / raw)
To: Tilman Schmidt; +Cc: linux-usb-devel, hjlipp, linux-kernel, gregkh
Tilman Schmidt <tilman@imap.cc> wrote:
>
> The current versions of the err() / info() / warn() syslog macros
> insert __FILE__ at the beginning of the message, which expands to
> the complete path name of the source file within the kernel tree.
>
> With the following patch, when used in a module, they'll insert the
> module name instead, which is significantly shorter and also tends to
> be more useful to users trying to make sense of a particular message.
Personally, I prefer to see filenames. Or function names. Sometimes it's
rather unobvious how to go from module name to filename, due to a) multiple
.o files being linked together, b) subsystems which insist on #including .c
files in .c files (usb...) and c) the module system's cute habit of
replacing underscores with dashes in module names.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] reduce syslog clutter (take 2)
2006-03-09 11:02 ` Andrew Morton
@ 2006-03-09 16:34 ` Randy.Dunlap
2006-03-09 18:43 ` Tilman Schmidt
0 siblings, 1 reply; 10+ messages in thread
From: Randy.Dunlap @ 2006-03-09 16:34 UTC (permalink / raw)
To: Andrew Morton; +Cc: tilman, linux-usb-devel, hjlipp, linux-kernel, gregkh
On Thu, 9 Mar 2006 03:02:57 -0800 Andrew Morton wrote:
> Tilman Schmidt <tilman@imap.cc> wrote:
> >
> > The current versions of the err() / info() / warn() syslog macros
> > insert __FILE__ at the beginning of the message, which expands to
> > the complete path name of the source file within the kernel tree.
> >
> > With the following patch, when used in a module, they'll insert the
> > module name instead, which is significantly shorter and also tends to
> > be more useful to users trying to make sense of a particular message.
>
> Personally, I prefer to see filenames. Or function names. Sometimes it's
> rather unobvious how to go from module name to filename, due to a) multiple
> .o files being linked together, b) subsystems which insist on #including .c
> files in .c files (usb...) and c) the module system's cute habit of
> replacing underscores with dashes in module names.
True, just using module->name or whatever means that we would
(often?) have to do a lookup to see what source file it was in.
---
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] reduce syslog clutter (take 2)
2006-03-09 16:34 ` Randy.Dunlap
@ 2006-03-09 18:43 ` Tilman Schmidt
[not found] ` <9a8748490603091058l75aacacsfc5fdba3981fb074@mail.gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Tilman Schmidt @ 2006-03-09 18:43 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: Andrew Morton, linux-usb-devel, hjlipp, linux-kernel, gregkh
[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]
On 09.03.2006 17:34, Randy.Dunlap wrote:
> On Thu, 9 Mar 2006 03:02:57 -0800 Andrew Morton wrote:
>
>>Tilman Schmidt <tilman@imap.cc> wrote:
>>
>>>The current versions of the err() / info() / warn() syslog macros
>>> insert __FILE__ at the beginning of the message, which expands to
>>> the complete path name of the source file within the kernel tree.
>>>
>>> With the following patch, when used in a module, they'll insert the
>>> module name instead, which is significantly shorter and also tends to
>>> be more useful to users trying to make sense of a particular message.
>>
>>Personally, I prefer to see filenames. Or function names. Sometimes it's
>>rather unobvious how to go from module name to filename, due to a) multiple
>>.o files being linked together, b) subsystems which insist on #including .c
>>files in .c files (usb...) and c) the module system's cute habit of
>>replacing underscores with dashes in module names.
>
> True, just using module->name or whatever means that we would
> (often?) have to do a lookup to see what source file it was in.
That would be a valid point for debugging messages. However, we are
talking about messages to users here. I maintain that the additional 20
characters in:
Feb 21 00:12:13 gx110 kernel: drivers/isdn/gigaset/i4l.c:
ISDN_CMD_SETL3: invalid protocol 42
as opposed to:
Feb 21 00:12:13 gx110 kernel: gigaset: ISDN_CMD_SETL3: invalid protocol 42
do not provide any useful information for that clientele. They just push
the actual interesting information farther to the right, in this case
even causing a line wrap.
If I want to include the function name in the message I can (and indeed
I quite frequently do), but this only makes the clutter worse if the
macros force the source path on me regardless.
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-03-09 22:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-08 22:54 [PATCH] reduce syslog clutter (take 2) Tilman Schmidt
2006-03-09 5:47 ` Randy.Dunlap
2006-03-09 10:15 ` Tilman Schmidt
2006-03-09 11:02 ` Andrew Morton
2006-03-09 16:34 ` Randy.Dunlap
2006-03-09 18:43 ` Tilman Schmidt
[not found] ` <9a8748490603091058l75aacacsfc5fdba3981fb074@mail.gmail.com>
2006-03-09 19:17 ` Tilman Schmidt
2006-03-09 21:03 ` Andrew Morton
2006-03-09 21:18 ` Pete Zaitcev
2006-03-09 22:42 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox