* [patch 1/6] kmsg: tagged kernel messages.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-09-26 4:48 ` Rusty Russell
2008-09-25 16:28 ` [patch 2/6] kmsg: tagged device messages Martin Schwidefsky
` (4 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Martin Schwidefsky
[-- Attachment #1: 800-kmsg-macros.diff --]
[-- Type: text/plain, Size: 4301 bytes --]
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
From: Michael Holzheu <holzheu@de.ibm.com>
Introduce a new family of printk macros which prefixes each kmsg message
with a component name and allows to tag the message with a 24 bit hash of
the message text. The kmsg component name is defined per source file with
the KMSG_COMPONENT macro. In order to use the kmsg_xxx macros KMSG_COMPONENT
has to be defined.
If the message hash will be printed to the console / syslog at all depends
on CONFIG_MSG_IDS. If it is "n" then a kmsg_xxx call is just another
printk wrapper. These macros are intended to be used uniformly in the
s390 architecture and the s390 device drivers.
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
arch/s390/Kconfig | 9 +++++++++
include/linux/kmsg.h | 42 ++++++++++++++++++++++++++++++++++++++++++
kernel/printk.c | 24 ++++++++++++++++++++++++
3 files changed, 75 insertions(+)
Index: kmsg-2.6/arch/s390/Kconfig
===================================================================
--- kmsg-2.6.orig/arch/s390/Kconfig
+++ kmsg-2.6/arch/s390/Kconfig
@@ -571,6 +571,15 @@ bool "s390 guest support (EXPERIMENTAL)"
select VIRTIO_CONSOLE
help
Select this option if you want to run the kernel under s390 linux
+
+config KMSG_IDS
+ bool "Kernel message numbers"
+ default y
+ help
+ Select this option if you want to include a message number to the
+ prefix for kernel messages issued by the s390 architecture and
+ driver code. See "Documentation/s390/kmsg.txt" for more details.
+
endmenu
source "net/Kconfig"
Index: kmsg-2.6/include/linux/kmsg.h
===================================================================
--- /dev/null
+++ kmsg-2.6/include/linux/kmsg.h
@@ -0,0 +1,42 @@
+#ifndef _LINUX_KMSG_H
+#define _LINUX_KMSG_H
+
+#define kmsg_printk(level, format, ...) \
+ printk(level KMSG_COMPONENT ": " format, ##__VA_ARGS__)
+
+#if defined(__KMSG_CHECKER)
+/* generate magic string for scripts/kmsg-doc to parse */
+#define kmsg_printk_hash(level, format, ...) \
+ __KMSG_PRINT(level _FMT_ format _ARGS_ ##__VA_ARGS__ _END_)
+#elif defined(CONFIG_KMSG_IDS)
+int printk_hash(const char *, const char *, ...);
+#define kmsg_printk_hash(level, format, ...) \
+ printk_hash(level KMSG_COMPONENT ".%06x" ": ", format, ##__VA_ARGS__)
+#else /* !defined(CONFIG_KMSG_IDS) */
+#define kmsg_printk_hash kmsg_printk
+#endif
+
+#define kmsg_emerg(fmt, ...) \
+ kmsg_printk_hash(KERN_EMERG, fmt, ##__VA_ARGS__)
+#define kmsg_alert(fmt, ...) \
+ kmsg_printk_hash(KERN_ALERT, fmt, ##__VA_ARGS__)
+#define kmsg_crit(fmt, ...) \
+ kmsg_printk_hash(KERN_CRIT, fmt, ##__VA_ARGS__)
+#define kmsg_err(fmt, ...) \
+ kmsg_printk_hash(KERN_ERR, fmt, ##__VA_ARGS__)
+#define kmsg_warn(fmt, ...) \
+ kmsg_printk_hash(KERN_WARNING, fmt, ##__VA_ARGS__)
+#define kmsg_notice(fmt, ...) \
+ kmsg_printk_hash(KERN_NOTICE, fmt, ##__VA_ARGS__)
+#define kmsg_info(fmt, ...) \
+ kmsg_printk_hash(KERN_INFO, fmt, ##__VA_ARGS__)
+
+#ifdef DEBUG
+#define kmsg_dbg(fmt, ...) \
+ kmsg_printk(KERN_DEBUG, fmt, ##__VA_ARGS__)
+#else
+#define kmsg_dbg(fmt, ...) \
+ ({ if (0) kmsg_printk(KERN_DEBUG, fmt, ##__VA_ARGS__); 0; })
+#endif
+
+#endif /* _LINUX_KMSG_H */
Index: kmsg-2.6/kernel/printk.c
===================================================================
--- kmsg-2.6.orig/kernel/printk.c
+++ kmsg-2.6/kernel/printk.c
@@ -32,6 +32,8 @@
#include <linux/security.h>
#include <linux/bootmem.h>
#include <linux/syscalls.h>
+#include <linux/jhash.h>
+#include <linux/device.h>
#include <asm/uaccess.h>
@@ -1343,3 +1345,25 @@ bool printk_timed_ratelimit(unsigned lon
}
EXPORT_SYMBOL(printk_timed_ratelimit);
#endif
+
+#if defined CONFIG_PRINTK && defined CONFIG_KMSG_IDS
+
+/**
+ * printk_hash - print a kernel message include a hash over the message
+ * @prefix: message prefix including the ".%06x" for the hash
+ * @fmt: format string
+ */
+asmlinkage int printk_hash(const char *prefix, const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ r = printk(prefix, jhash(fmt, strlen(fmt), 0) & 0xffffff);
+ va_start(args, fmt);
+ r += vprintk(fmt, args);
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(printk_hash);
+#endif
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-25 16:28 ` [patch 1/6] kmsg: tagged kernel messages Martin Schwidefsky
@ 2008-09-26 4:48 ` Rusty Russell
2008-09-26 8:29 ` Martin Schwidefsky
0 siblings, 1 reply; 17+ messages in thread
From: Rusty Russell @ 2008-09-26 4:48 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: linux-kernel, linux-s390, lf_kernel_messages, Greg KH,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
> +#define kmsg_emerg(fmt, ...) \
> + kmsg_printk_hash(KERN_EMERG, fmt, ##__VA_ARGS__)
> +#define kmsg_alert(fmt, ...) \
> + kmsg_printk_hash(KERN_ALERT, fmt, ##__VA_ARGS__)
> +#define kmsg_crit(fmt, ...) \
> + kmsg_printk_hash(KERN_CRIT, fmt, ##__VA_ARGS__)
> +#define kmsg_err(fmt, ...) \
> + kmsg_printk_hash(KERN_ERR, fmt, ##__VA_ARGS__)
> +#define kmsg_warn(fmt, ...) \
> + kmsg_printk_hash(KERN_WARNING, fmt, ##__VA_ARGS__)
> +#define kmsg_notice(fmt, ...) \
> + kmsg_printk_hash(KERN_NOTICE, fmt, ##__VA_ARGS__)
> +#define kmsg_info(fmt, ...) \
> + kmsg_printk_hash(KERN_INFO, fmt, ##__VA_ARGS__)
Now I'm going to be an asshole and ask you to define when each of these levels
should be used. Do we need all of them?
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-26 4:48 ` Rusty Russell
@ 2008-09-26 8:29 ` Martin Schwidefsky
2008-09-27 7:15 ` Rusty Russell
0 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-26 8:29 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel, linux-s390, lf_kernel_messages, Greg KH,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Fri, 2008-09-26 at 14:48 +1000, Rusty Russell wrote:
> On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
> > +#define kmsg_emerg(fmt, ...) \
> > + kmsg_printk_hash(KERN_EMERG, fmt, ##__VA_ARGS__)
> > +#define kmsg_alert(fmt, ...) \
> > + kmsg_printk_hash(KERN_ALERT, fmt, ##__VA_ARGS__)
> > +#define kmsg_crit(fmt, ...) \
> > + kmsg_printk_hash(KERN_CRIT, fmt, ##__VA_ARGS__)
> > +#define kmsg_err(fmt, ...) \
> > + kmsg_printk_hash(KERN_ERR, fmt, ##__VA_ARGS__)
> > +#define kmsg_warn(fmt, ...) \
> > + kmsg_printk_hash(KERN_WARNING, fmt, ##__VA_ARGS__)
> > +#define kmsg_notice(fmt, ...) \
> > + kmsg_printk_hash(KERN_NOTICE, fmt, ##__VA_ARGS__)
> > +#define kmsg_info(fmt, ...) \
> > + kmsg_printk_hash(KERN_INFO, fmt, ##__VA_ARGS__)
>
> Now I'm going to be an asshole and ask you to define when each of these levels
> should be used. Do we need all of them?
These are just the regular printk levels. If your old printk used a
particular level, have the kmsg_xxx printk use the same level. The
question about message severity and message documenation are
independent, aren't they?
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-26 8:29 ` Martin Schwidefsky
@ 2008-09-27 7:15 ` Rusty Russell
2008-09-27 23:16 ` Martin Schwidefsky
0 siblings, 1 reply; 17+ messages in thread
From: Rusty Russell @ 2008-09-27 7:15 UTC (permalink / raw)
To: schwidefsky
Cc: linux-kernel, linux-s390, lf_kernel_messages, Greg KH,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Friday 26 September 2008 18:29:34 Martin Schwidefsky wrote:
> On Fri, 2008-09-26 at 14:48 +1000, Rusty Russell wrote:
> > On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
> > > +#define kmsg_emerg(fmt, ...) \
> > > + kmsg_printk_hash(KERN_EMERG, fmt, ##__VA_ARGS__)
> > > +#define kmsg_alert(fmt, ...) \
> > > + kmsg_printk_hash(KERN_ALERT, fmt, ##__VA_ARGS__)
> > > +#define kmsg_crit(fmt, ...) \
> > > + kmsg_printk_hash(KERN_CRIT, fmt, ##__VA_ARGS__)
> > > +#define kmsg_err(fmt, ...) \
> > > + kmsg_printk_hash(KERN_ERR, fmt, ##__VA_ARGS__)
> > > +#define kmsg_warn(fmt, ...) \
> > > + kmsg_printk_hash(KERN_WARNING, fmt, ##__VA_ARGS__)
> > > +#define kmsg_notice(fmt, ...) \
> > > + kmsg_printk_hash(KERN_NOTICE, fmt, ##__VA_ARGS__)
> > > +#define kmsg_info(fmt, ...) \
> > > + kmsg_printk_hash(KERN_INFO, fmt, ##__VA_ARGS__)
> >
> > Now I'm going to be an asshole and ask you to define when each of these
> > levels should be used. Do we need all of them?
>
> These are just the regular printk levels. If your old printk used a
> particular level, have the kmsg_xxx printk use the same level. The
> question about message severity and message documenation are
> independent, aren't they?
Yes, but since it's a new message API, I thought you might have an idea. It's
hard for authors (eg. me) to know which level to use. As a result, levels
currently seem to be chosen randomly.
If you felt inspired to rationalize them, it would let us clean that up as
things moved to kmsg :)
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-27 7:15 ` Rusty Russell
@ 2008-09-27 23:16 ` Martin Schwidefsky
2008-09-28 2:09 ` Rusty Russell
0 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-27 23:16 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel, linux-s390, lf_kernel_messages, Greg KH,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Sat, 2008-09-27 at 17:15 +1000, Rusty Russell wrote:
> > These are just the regular printk levels. If your old printk used a
> > particular level, have the kmsg_xxx printk use the same level. The
> > question about message severity and message documenation are
> > independent, aren't they?
>
> Yes, but since it's a new message API, I thought you might have an idea. It's
> hard for authors (eg. me) to know which level to use. As a result, levels
> currently seem to be chosen randomly.
>
> If you felt inspired to rationalize them, it would let us clean that up as
> things moved to kmsg :)
Urgs, you are after a sort of definition what the differences is between
a warning, an error, an alert, etc is, aren't you?
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-27 23:16 ` Martin Schwidefsky
@ 2008-09-28 2:09 ` Rusty Russell
2008-09-29 8:35 ` Christian Borntraeger
0 siblings, 1 reply; 17+ messages in thread
From: Rusty Russell @ 2008-09-28 2:09 UTC (permalink / raw)
To: schwidefsky
Cc: linux-kernel, linux-s390, lf_kernel_messages, Greg KH,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Sunday 28 September 2008 09:16:40 Martin Schwidefsky wrote:
> On Sat, 2008-09-27 at 17:15 +1000, Rusty Russell wrote:
> > It's hard for authors (eg. me) to know which level to use. As a result,
> > levels currently seem to be chosen randomly.
> >
> > If you felt inspired to rationalize them, it would let us clean that up
> > as things moved to kmsg :)
>
> Urgs, you are after a sort of definition what the differences is between
> a warning, an error, an alert, etc is, aren't you?
And it is a sign of my admiration for your intellect that I asked you for it.
(Does that help?)
Rusty.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 1/6] kmsg: tagged kernel messages.
2008-09-28 2:09 ` Rusty Russell
@ 2008-09-29 8:35 ` Christian Borntraeger
0 siblings, 0 replies; 17+ messages in thread
From: Christian Borntraeger @ 2008-09-29 8:35 UTC (permalink / raw)
To: Rusty Russell
Cc: schwidefsky, linux-kernel, linux-s390, lf_kernel_messages,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Am Sonntag, 28. September 2008 schrieb Rusty Russell:
> On Sunday 28 September 2008 09:16:40 Martin Schwidefsky wrote:
> > On Sat, 2008-09-27 at 17:15 +1000, Rusty Russell wrote:
> > > It's hard for authors (eg. me) to know which level to use. As a result,
> > > levels currently seem to be chosen randomly.
> > >
> > > If you felt inspired to rationalize them, it would let us clean that up
> > > as things moved to kmsg :)
> >
> > Urgs, you are after a sort of definition what the differences is between
> > a warning, an error, an alert, etc is, aren't you?
>
Rusty,
Since Kernel message levels are used directly by syslog, the Open Group Base
Specifications Issue 6 defines what these levels are:
http://www.opengroup.org/onlinepubs/009695399/basedefs/syslog.h.html
LOG_EMERG
A panic condition was reported to all processes.
LOG_ALERT
A condition that should be corrected immediately.
LOG_CRIT
A critical condition.
LOG_ERR
An error message.
LOG_WARNING
A warning message.
LOG_NOTICE
A condition requiring special handling.
LOG_INFO
A general information message.
LOG_DEBUG
A message useful for debugging programs.
I dont think, that the kernel should define anything different.
We could add a more verbose description or a howto to CodingStyle later on,
but this is really orthogonal to kmsg and would be valid for printk,
dev_printk and any other printk wrapper.
Futhermore, this really smells like a bike shed color question and IMHO we
should not hold of the kmsg patches to answer this kind of controversial
questions ;-)
Christian
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 2/6] kmsg: tagged device messages.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
2008-09-25 16:28 ` [patch 1/6] kmsg: tagged kernel messages Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-09-26 17:57 ` Greg KH
2008-09-25 16:28 ` [patch 3/6] kmsg: Kernel message catalog script Martin Schwidefsky
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Martin Schwidefsky
[-- Attachment #1: 801-kmsg-dev.diff --]
[-- Type: text/plain, Size: 5730 bytes --]
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
From: Michael Holzheu <holzheu@de.ibm.com>
Add CONFIG_MSG_IDS support to the dev_xxx printk family. The message
tag for a device printk consists of the driver name and the 24 bit
hash over the message text. The hash is included in the printed line
if the KMSG_COMPONENT macro is defined and CONFIG_MSG_IDS=y. For
source files that do not define KMSG_COMPONENT or CONFIG_MSG_IDS=n
the dev_xxx printks use the old-style format.
To make it possible for a script to extract the correct message tag
for the dev_xxx printks the KMSG_COMPONENT and the driver name need to
be identical for all dev_xxx printks in a source file. If a source file
is supposed to be converted to use message tags and there are dev_xxx
printks with driver names different to KMSG_COMPONENT these dev_xxx
printks need to be replaced with kmsg_xxx printks. In praxis this
should not be a problem since there are very few dev_xxx printks outside
of driver code.
In addition to the KMSG_COMPONENT changes in include/linux/device.h the
dev_xxx macros with variable arguments are converted from the gcc specific
'## arg' to the C99 variant '##__VA_ARGS__'.
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
include/linux/device.h | 57 ++++++++++++++++++++++++++++++-------------------
kernel/printk.c | 22 ++++++++++++++++++
2 files changed, 57 insertions(+), 22 deletions(-)
Index: kmsg-2.6/include/linux/device.h
===================================================================
--- kmsg-2.6.orig/include/linux/device.h
+++ kmsg-2.6/include/linux/device.h
@@ -520,39 +520,52 @@ extern void sysdev_shutdown(void);
/* debugging and troubleshooting/diagnostic helpers. */
extern const char *dev_driver_string(const struct device *dev);
-#define dev_printk(level, dev, format, arg...) \
+#define dev_printk(level, dev, format, ...) \
printk(level "%s %s: " format , dev_driver_string(dev) , \
- dev_name(dev) , ## arg)
+ dev_name(dev) , ##__VA_ARGS__)
-#define dev_emerg(dev, format, arg...) \
- dev_printk(KERN_EMERG , dev , format , ## arg)
-#define dev_alert(dev, format, arg...) \
- dev_printk(KERN_ALERT , dev , format , ## arg)
-#define dev_crit(dev, format, arg...) \
- dev_printk(KERN_CRIT , dev , format , ## arg)
-#define dev_err(dev, format, arg...) \
- dev_printk(KERN_ERR , dev , format , ## arg)
-#define dev_warn(dev, format, arg...) \
- dev_printk(KERN_WARNING , dev , format , ## arg)
-#define dev_notice(dev, format, arg...) \
- dev_printk(KERN_NOTICE , dev , format , ## arg)
-#define dev_info(dev, format, arg...) \
- dev_printk(KERN_INFO , dev , format , ## arg)
+/* dev_printk_hash for message documentation */
+#if defined(__KMSG_CHECKER) && defined(KMSG_COMPONENT)
+/* generate magic string for scripts/kmsg-doc to parse */
+#define dev_printk_hash(level, dev, format, ...) \
+ __KMSG_DEV(level _FMT_ format _ARGS_ dev, ##__VA_ARGS__ _END_)
+#elif defined(CONFIG_KMSG_IDS) && defined(KMSG_COMPONENT)
+int printk_dev_hash(const char *, const struct device *, const char *, ...);
+#define dev_printk_hash(level, dev, format, ...) \
+ printk_dev_hash(level "%s.%06x: %s: ", dev, format, ##__VA_ARGS__)
+#else /* !defined(CONFIG_KMSG_IDS) */
+#define dev_printk_hash dev_printk
+#endif
+
+#define dev_emerg(dev, format, ...) \
+ dev_printk_hash(KERN_EMERG , dev , format , ##__VA_ARGS__)
+#define dev_alert(dev, format, ...) \
+ dev_printk_hash(KERN_ALERT , dev , format , ##__VA_ARGS__)
+#define dev_crit(dev, format, ...) \
+ dev_printk_hash(KERN_CRIT , dev , format , ##__VA_ARGS__)
+#define dev_err(dev, format, ...) \
+ dev_printk_hash(KERN_ERR , dev , format , ##__VA_ARGS__)
+#define dev_warn(dev, format, ...) \
+ dev_printk_hash(KERN_WARNING , dev , format , ##__VA_ARGS__)
+#define dev_notice(dev, format, ...) \
+ dev_printk_hash(KERN_NOTICE , dev , format , ##__VA_ARGS__)
+#define dev_info(dev, format, ...) \
+ dev_printk_hash(KERN_INFO , dev , format , ##__VA_ARGS__)
#ifdef DEBUG
-#define dev_dbg(dev, format, arg...) \
- dev_printk(KERN_DEBUG , dev , format , ## arg)
+#define dev_dbg(dev, format, ...) \
+ dev_printk(KERN_DEBUG , dev , format , ##__VA_ARGS__)
#else
-#define dev_dbg(dev, format, arg...) \
- ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
+#define dev_dbg(dev, format, ...) \
+ ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##__VA_ARGS__); 0; })
#endif
#ifdef VERBOSE_DEBUG
#define dev_vdbg dev_dbg
#else
-#define dev_vdbg(dev, format, arg...) \
- ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
+#define dev_vdbg(dev, format, ...) \
+ ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##__VA_ARGS__); 0; })
#endif
/* Create alias, so I can be autoloaded. */
Index: kmsg-2.6/kernel/printk.c
===================================================================
--- kmsg-2.6.orig/kernel/printk.c
+++ kmsg-2.6/kernel/printk.c
@@ -1366,4 +1366,26 @@ asmlinkage int printk_hash(const char *p
return r;
}
EXPORT_SYMBOL(printk_hash);
+
+/**
+ * printk_dev_hash - print a kernel message include a hash over the message
+ * @prefix: message prefix including the ".%06x" for the hash
+ * @dev: device this printk is all about
+ * @fmt: format string
+ */
+asmlinkage int printk_dev_hash(const char *prefix, const struct device *dev,
+ const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ r = printk(prefix, dev_driver_string(dev),
+ jhash(fmt, strlen(fmt), 0) & 0xffffff, dev_name(dev));
+ va_start(args, fmt);
+ r += vprintk(fmt, args);
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(printk_dev_hash);
#endif
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [patch 2/6] kmsg: tagged device messages.
2008-09-25 16:28 ` [patch 2/6] kmsg: tagged device messages Martin Schwidefsky
@ 2008-09-26 17:57 ` Greg KH
2008-09-27 23:11 ` Martin Schwidefsky
0 siblings, 1 reply; 17+ messages in thread
From: Greg KH @ 2008-09-26 17:57 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Thu, Sep 25, 2008 at 06:28:29PM +0200, Martin Schwidefsky wrote:
> From: Martin Schwidefsky <schwidefsky@de.ibm.com>
> From: Michael Holzheu <holzheu@de.ibm.com>
>
> Add CONFIG_MSG_IDS support to the dev_xxx printk family. The message
> tag for a device printk consists of the driver name and the 24 bit
> hash over the message text. The hash is included in the printed line
> if the KMSG_COMPONENT macro is defined and CONFIG_MSG_IDS=y. For
> source files that do not define KMSG_COMPONENT or CONFIG_MSG_IDS=n
> the dev_xxx printks use the old-style format.
>
> To make it possible for a script to extract the correct message tag
> for the dev_xxx printks the KMSG_COMPONENT and the driver name need to
> be identical for all dev_xxx printks in a source file. If a source file
> is supposed to be converted to use message tags and there are dev_xxx
> printks with driver names different to KMSG_COMPONENT these dev_xxx
> printks need to be replaced with kmsg_xxx printks. In praxis this
> should not be a problem since there are very few dev_xxx printks outside
> of driver code.
>
> In addition to the KMSG_COMPONENT changes in include/linux/device.h the
> dev_xxx macros with variable arguments are converted from the gcc specific
> '## arg' to the C99 variant '##__VA_ARGS__'.
>
> Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Nice, thanks for reworking this. Feel free to add:
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
here.
Note that you will get some merge errors with -next in device.h due to
the dynamic debug printk work that is in my tree and in -next as well.
But it should be simple to resolve.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 2/6] kmsg: tagged device messages.
2008-09-26 17:57 ` Greg KH
@ 2008-09-27 23:11 ` Martin Schwidefsky
2008-09-28 2:04 ` Greg KH
0 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-27 23:11 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Fri, 2008-09-26 at 10:57 -0700, Greg KH wrote:
> Nice, thanks for reworking this. Feel free to add:
> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> here.
Good, I will do that.
> Note that you will get some merge errors with -next in device.h due to
> the dynamic debug printk work that is in my tree and in -next as well.
> But it should be simple to resolve.
Is the dynamic debug printk work going upstream with the next merge
window? If yes then I'll wait until it hit Linus tree and update my
patch.
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 2/6] kmsg: tagged device messages.
2008-09-27 23:11 ` Martin Schwidefsky
@ 2008-09-28 2:04 ` Greg KH
0 siblings, 0 replies; 17+ messages in thread
From: Greg KH @ 2008-09-28 2:04 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
On Sun, Sep 28, 2008 at 01:11:44AM +0200, Martin Schwidefsky wrote:
> On Fri, 2008-09-26 at 10:57 -0700, Greg KH wrote:
> > Note that you will get some merge errors with -next in device.h due to
> > the dynamic debug printk work that is in my tree and in -next as well.
> > But it should be simple to resolve.
>
> Is the dynamic debug printk work going upstream with the next merge
> window? If yes then I'll wait until it hit Linus tree and update my
> patch.
Yes, it is slated for 2.6.28 inclusion and is in the -next and -mm
releases.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 3/6] kmsg: Kernel message catalog script.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
2008-09-25 16:28 ` [patch 1/6] kmsg: tagged kernel messages Martin Schwidefsky
2008-09-25 16:28 ` [patch 2/6] kmsg: tagged device messages Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-09-25 16:28 ` [patch 4/6] kmsg: convert xpram messages to kmsg api Martin Schwidefsky
` (2 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Martin Schwidefsky
[-- Attachment #1: 802-kmsg-script.diff --]
[-- Type: text/plain, Size: 17266 bytes --]
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
From: Michael Holzheu <holzheu@de.ibm.com>
Add a script and the calls to the make process that allows to check the
kmsg_xxx and dev_xxx printk message and to format man pages from the
message descriptions.
The kmsg message description is a comment with the following format:
/*?
* Tag: <component>.<hash>
* Text: "<kmsg message text>"
* Severity: <severity>
* Parameter:
* @1: <description of the first message parameter>
* @2: <description of the second message parameter>
* ...
* Description:
* <What is the kmsg message all about>
* User action:
* <What can the user do to fix the problem>
*/
The following short form of a kmsg message can be used if the message does
not have a full documentation:
/*? Tag: <component>.<hash> Text: "<kmsg message text>" */
No man page will be printed for these messages.
The script looks for a kmsg comment for a tagged printk at three places,
the source file where the kmsg_xxx / dev_xxx call is located, and in the
files with the name <component> in the two directories Documentation/kmsg
and Documentation/$ARCH/kmsg.
The kmsg check is invoked with "make D=1". It will read the source files for
all objects that are built by the current configuration and searches for
matching kmsg descriptions for the tagged printk in the source. If a message
description can not be found the script prints a blueprint and causes a make
error.
The kmsg man page creation is invoked with "make D=2" and reads the source
files for all built objects, looks up the message description and writes
a man page to $(objtree)/man.
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
Makefile | 16 +
scripts/Makefile.build | 14 +
scripts/kmsg-doc | 466 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 496 insertions(+)
Index: kmsg-2.6/Makefile
===================================================================
--- kmsg-2.6.orig/Makefile
+++ kmsg-2.6/Makefile
@@ -63,6 +63,20 @@ ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif
+# Call message checker as part of the C compilation
+#
+# Use 'make D=1' to enable checking
+# Use 'make D=2' to create the message catalog
+
+ifdef D
+ ifeq ("$(origin D)", "command line")
+ KBUILD_KMSG_CHECK = $(D)
+ endif
+endif
+ifndef KBUILD_KMSG_CHECK
+ KBUILD_KMSG_CHECK = 0
+endif
+
# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence
@@ -321,6 +335,7 @@ PERL = perl
CHECK = sparse
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
+KMSG_CHECK = $(srctree)/scripts/kmsg-doc
MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS)
@@ -355,6 +370,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODU
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
+export KBUILD_KMSG_CHECK KMSG_CHECK
# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
Index: kmsg-2.6/scripts/kmsg-doc
===================================================================
--- /dev/null
+++ kmsg-2.6/scripts/kmsg-doc
@@ -0,0 +1,466 @@
+#!/usr/bin/perl -w
+#
+# kmsg kernel messages check and print tool.
+#
+# To check the source code for missing messages the script is called
+# with check, the name compiler and the compile parameters
+# kmsg-doc check $(CC) $(c_flags) $<
+# To create man pages for the messages the script is called with
+# kmsg-doc print $(CC) $(c_flags) $<
+#
+# Copyright IBM Corp. 2008
+# Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
+# Michael Holzheu <holzheu@linux.vnet.ibm.com>
+#
+
+use Cwd;
+use Switch;
+
+my $errors = 0;
+my $warnings = 0;
+my $srctree = "";
+my $objtree = "";
+my $kmsg_count = 0;
+
+sub remove_quotes($)
+{
+ my ($string) = @_;
+ my $inside = 0;
+ my $slash = 0;
+ my $result = "";
+
+ foreach my $str (split(/([\\"])/, $string)) {
+ if ($inside && ($str ne "\"" || $slash)) {
+ $result .= $str;
+ }
+ # Check for backslash before quote
+ if ($str eq "\"") {
+ if (!$slash) {
+ $inside = !$inside;
+ }
+ $slash = 0;
+ } elsif ($str eq "\\") {
+ $slash = !$slash;
+ } elsif ($str ne "") {
+ $slash = 0;
+ }
+ }
+ return $result;
+}
+
+sub string_to_bytes($)
+{
+ my ($string) = @_;
+ my %is_escape = ('"', 0x22, '\'', 0x27, 'n', 0x0a, 'r', 0x0d, 'b', 0x08,
+ 't', 0x09, 'f', 0x0c, 'a', 0x07, 'v', 0x0b, '?', 0x3f);
+ my (@ar, $slash, $len);
+
+ # scan string, interpret backslash escapes and write bytes to @ar
+ $len = 0;
+ foreach my $ch (split(//, $string)) {
+ if ($ch eq '\\') {
+ $slash = !$slash;
+ if (!$slash) {
+ $ar[$len] = ord('\\');
+ $len++;
+ }
+ } elsif ($slash && defined $is_escape{$ch}) {
+ # C99 backslash escapes: \\ \" \' \n \r \b \t \f \a \v \?
+ $ar[$len] = $is_escape{$ch};
+ $len++;
+ $slash = 0;
+ } elsif ($slash) {
+ # FIXME: C99 backslash escapes \nnn \xhh
+ die("Unknown backslash escape in message $string.");
+ } else {
+ # normal character
+ $ar[$len] = ord($ch);
+ $len++;
+ }
+ }
+ return @ar;
+}
+
+sub calc_jhash($)
+{
+ my ($string) = @_;
+ my @ar;
+ my ($a, $b, $c, $i, $length, $len);
+
+ @ar = string_to_bytes($string);
+ $length = @ar;
+ # add dummy elements to @ar to avoid if then else hell
+ push @ar, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ $a = 0x9e3779b9;
+ $b = 0x9e3779b9;
+ $c = 0;
+ $i = 0;
+ for ($len = $length + 12; $len >= 12; $len -= 12) {
+ if ($len < 23) {
+ # add length for last round
+ $c += $length;
+ }
+ $a += $ar[$i] + ($ar[$i+1]<<8) + ($ar[$i+2]<<16) + ($ar[$i+3]<<24);
+ $b += $ar[$i+4] + ($ar[$i+5]<<8) + ($ar[$i+6]<<16) + ($ar[$i+7]<<24);
+ $c += $ar[$i+8] + ($ar[$i+9]<<8) + ($ar[$i+10]<<16) + ($ar[$i+11]<<24);
+ $a &= 0xffffffff; $b &= 0xffffffff; $c &= 0xffffffff;
+ $a -= $b; $a -= $c; $a ^= ($c >> 13); $a &= 0xffffffff;
+ $b -= $c; $b -= $a; $b ^= ($a << 8); $b &= 0xffffffff;
+ $c -= $a; $c -= $b; $c ^= ($b >> 13); $c &= 0xffffffff;
+ $a -= $b; $a -= $c; $a ^= ($c >> 12); $a &= 0xffffffff;
+ $b -= $c; $b -= $a; $b ^= ($a << 16); $b &= 0xffffffff;
+ $c -= $a; $c -= $b; $c ^= ($b >> 5); $c &= 0xffffffff;
+ $a -= $b; $a -= $c; $a ^= ($c >> 3); $a &= 0xffffffff;
+ $b -= $c; $b -= $a; $b ^= ($a << 10); $b &= 0xffffffff;
+ $c -= $a; $c -= $b; $c ^= ($b >> 15); $c &= 0xffffffff;
+ $i += 12;
+ }
+ return $c;
+}
+
+sub add_kmsg_desc($$$$$$)
+{
+ my ($tag, $text, $sev, $argv, $desc, $user) = @_;
+
+ if ($kmsg_desc{$tag}) {
+ warn "Duplicate message with tag $tag\n";
+ $errors++;
+ return;
+ }
+ $text = remove_quotes($text);
+ $kmsg_desc{$tag}->{'TEXT'} = $text;
+ $kmsg_desc{$tag}->{'SEV'} = $sev;
+ $kmsg_desc{$tag}->{'ARGV'} = $argv;
+ $kmsg_desc{$tag}->{'DESC'} = $desc;
+ $kmsg_desc{$tag}->{'USER'} = $user;
+}
+
+sub add_kmsg_print($$$$$)
+{
+ my ($component, $sev, $prefix, $text, $argv) = @_;
+ my ($hash, $tag, $count, $parm);
+
+ $text = remove_quotes($text);
+ $hash = substr(sprintf("%08x", calc_jhash($text)), 2, 6);
+ $tag = $component . "." . $hash;
+ # Pretty print severity
+ $sev =~ s/"<0>"/Emerg/;
+ $sev =~ s/"<1>"/Alert/;
+ $sev =~ s/"<2>"/Critical/;
+ $sev =~ s/"<3>"/Error/;
+ $sev =~ s/"<4>"/Warning/;
+ $sev =~ s/"<5>"/Notice/;
+ $sev =~ s/"<6>"/Informational/;
+ $sev =~ s/"<7>"/Debug/;
+ $kmsg_print{$kmsg_count}->{'TAG'} = $tag;
+ $kmsg_print{$kmsg_count}->{'TEXT'} = $prefix . $text;
+ $kmsg_print{$kmsg_count}->{'SEV'} = $sev;
+ $kmsg_print{$kmsg_count}->{'ARGV'} = $argv;
+ $kmsg_count += 1;
+}
+
+sub process_source_file($)
+{
+ my $file = "@_";
+ my $state;
+ my $component = "";
+ my ($tag, $text, $sev, $argv, $desc, $user);
+
+ if (!open(FD, "$file")) {
+ return "";
+ }
+
+ $state = 0;
+ while (<FD>) {
+ chomp;
+ # kmsg message component: #define KMSG_COMPONENT "<component>"
+ if (/^#define\s+KMSG_COMPONENT\s+\"(.*)\"[^\"]*$/o) {
+ $component = $1;
+ }
+ if ($state == 0) {
+ # single line kmsg for undocumented messages, format:
+ # /*? Tag: <component>.<hash> Text: "<message>" */
+ if (/^\s*\/\*\?\s*Tag:\s*(\S*)\s*Text:\s*(\".*\")\s*\*\/\s*$/o) {
+ add_kmsg_desc($1, $2, "", "", "", "");
+ }
+ # kmsg message start: '/*?'
+ if (/^\s*\/\*\?\s*$/o) {
+ $state = 1;
+ ($tag, $text, $sev, $argv, $desc, $user) = ( "", "", "", "", "", "" );
+ }
+ } elsif ($state == 1) {
+ # kmsg message end: ' */'
+ if (/^\s*\*\/\s*/o) {
+ add_kmsg_desc($tag, $text, $sev, $argv, $desc, $user);
+ $state = 0;
+ }
+ # kmsg message tag: ' * Tag: <tag>'
+ elsif (/^\s*\*\s*Tag:\s*(\S*)\s*$/o) {
+ $tag = $1;
+ }
+ # kmsg message text: ' * Text: "<message>"'
+ elsif (/^\s*\*\s*Text:\s*(\".*\")\s*$/o) {
+ $text = $1;
+ }
+ # kmsg message severity: ' * Severity: <sev>'
+ elsif (/^\s*\*\s*Severity:\s*(\S*)\s*$/o) {
+ $sev = $1;
+ }
+ # kmsg message parameter: ' * Parameter: <argv>'
+ elsif (/^\s*\*\s*Parameter:\s*(\S*)\s*$/o) {
+ if (!defined($1)) {
+ $argv = "";
+ } else {
+ $argv = $1;
+ }
+ $state = 2;
+ }
+ # kmsg message description start: ' * Description:'
+ elsif (/^\s*\*\s*Description:\s*(\S*)\s*$/o) {
+ if (!defined($1)) {
+ $desc = "";
+ } else {
+ $desc = $1;
+ }
+ $state = 3;
+ }
+ # kmsg has unrecognizable lines
+ else {
+ warn "Warning(${file}:$.): Cannot understand $_";
+ $warnings++;
+ $state = 0;
+ }
+ } elsif ($state == 2) {
+ # kmsg message end: ' */'
+ if (/^\s*\*\//o) {
+ warn "Warning(${file}:$.): Missing description, skipping message";
+ $warnings++;
+ $state = 0;
+ }
+ # kmsg message description start: ' * Description:'
+ elsif (/^\s*\*\s*Description:\s*$/o) {
+ $desc = $1;
+ $state = 3;
+ }
+ # kmsg message parameter line: ' * <argv>'
+ elsif (/^\s*\*(.*)$/o) {
+ $argv .= "\n" . $1;
+ } else {
+ warn "Warning(${file}:$.): Cannot understand $_";
+ $warnings++;
+ $state = 0;
+ }
+ } elsif ($state == 3) {
+ # kmsg message end: ' */'
+ if (/^\s*\*\/\s*/o) {
+ add_kmsg_desc($tag, $text, $sev, $argv, $desc, $user);
+ $state = 0;
+ }
+ # kmsg message description start: ' * User action:'
+ elsif (/^\s*\*\s*User action:\s*$/o) {
+ $user = $1;
+ $state = 4;
+ }
+ # kmsg message description line: ' * <text>'
+ elsif (/^\s*\*\s*(.*)$/o) {
+ $desc .= "\n" . $1;
+ } else {
+ warn "Warning(${file}:$.): Cannot understand $_";
+ $warnings++;
+ $state = 0;
+ }
+ } elsif ($state == 4) {
+ # kmsg message end: ' */'
+ if (/^\s*\*\/\s*/o) {
+ add_kmsg_desc($tag, $text, $sev, $argv, $desc, $user);
+ $state = 0;
+ }
+ # kmsg message user action line: ' * <text>'
+ elsif (/^\s*\*\s*(.*)$/o) {
+ $user .= "\n" . $1;
+ } else {
+ warn "Warning(${file}:$.): Cannot understand $_";
+ $warnings++;
+ $state = 0;
+ }
+ }
+ }
+ return $component;
+}
+
+sub process_cpp_file($$$$)
+{
+ my ($cc, $options, $file, $component) = @_;
+
+ open(FD, "$cc $gcc_options|") or die ("Preprocessing failed.");
+
+ while (<FD>) {
+ chomp;
+ if (/.*__KMSG_PRINT\(\s*(\S*)\s*_FMT_(.*)_ARGS_\s*(.*)?_END_\s*\)/o) {
+ if ($component ne "") {
+ add_kmsg_print($component, $1, "", $2, $3);
+ } else {
+ warn "Error(${file}:$.): kmsg without component\n";
+ $errors++;
+ }
+ } elsif (/.*__KMSG_DEV\(\s*(\S*)\s*_FMT_(.*)_ARGS_\s*(.*)?_END_\*s\)/o) {
+ if ($component ne "") {
+ add_kmsg_print($component, $1, "%s: ", $2, $3);
+ } else {
+ warn "Error(${file}:$.): kmsg without component\n";
+ $errors++;
+ }
+ }
+ }
+}
+
+sub check_messages($)
+{
+ my $component = "@_";
+ my $failed = 0;
+
+ for ($i = 0; $i < $kmsg_count; $i++) {
+ $tag = $kmsg_print{$i}->{'TAG'};
+ if (!defined($kmsg_desc{$tag})) {
+ add_kmsg_desc($tag,
+ "\"" . $kmsg_print{$i}->{'TEXT'} . "\"",
+ $kmsg_print{$i}->{'SEV'},
+ $kmsg_print{$i}->{'ARGV'},
+ "Please insert description here",
+ "What is the user supposed to do");
+ $kmsg_desc{$tag}->{'CHECK'} = 1;
+ $failed = 1;
+ warn "$component: Missing description for: $tag\n";
+ $errors++;
+ next;
+ }
+ if ($kmsg_print{$i}->{'TEXT'} ne $kmsg_desc{$tag}->{'TEXT'}) {
+ warn "$component: format string mismatch for: $tag\n";
+ warn " --- $kmsg_print{$i}->{'TEXT'}\n";
+ warn " +++ $kmsg_desc{$tag}->{'TEXT'}\n";
+ $errors++;
+ }
+ }
+ return $failed;
+}
+
+sub print_templates()
+{
+ print "Templates for missing messages:\n";
+ foreach $tag ( sort { $kmsg_desc{$a} <=> $kmsg_desc{$b} } keys %kmsg_desc ) {
+ if (!defined($kmsg_desc{$tag}->{'CHECK'})) {
+ next;
+ }
+ print "/*?\n";
+ print " * Tag: $tag\n";
+ print " * Text: \"$kmsg_desc{$tag}->{'TEXT'}\"\n";
+ print " * Severity: $kmsg_desc{$tag}->{'SEV'}\n";
+ $argv = $kmsg_desc{$tag}->{'ARGV'};
+ if ($argv ne "") {
+ print " * Parameter:\n";
+ @parms = split(/\s*,\s*/,$kmsg_desc{$tag}->{'ARGV'});
+ $count = 0;
+ foreach $parm (@parms) {
+ $count += 1;
+ if (!($parm eq "")) {
+ print " * \@$count: $parm\n";
+ }
+ }
+ }
+ print " * Description:\n";
+ print " * $kmsg_desc{$tag}->{'DESC'}\n";
+ print " * User action:\n";
+ print " * $kmsg_desc{$tag}->{'USER'}\n";
+ print " */\n\n";
+ }
+}
+
+sub write_man_pages()
+{
+ my $file;
+
+ foreach $tag (keys(%kmsg_desc)) {
+ if (defined($kmsg_desc{$tag}->{'CHECK'})) {
+ next;
+ }
+ if ($kmsg_desc{$tag}->{'DESC'} eq "") {
+ next;
+ }
+ $file = $objtree . "man/" . $tag . ".9";
+ if (!open(WR, ">$file")) {
+ warn "Error: Cannot open file $file\n";
+ $errors++;
+ return;
+ }
+ print WR ".TH \"$tag\" 9 \"Linux Messages\" LINUX\n";
+ print WR ".SH Message\n";
+ print WR $tag . ": " . $kmsg_desc{$tag}->{'TEXT'} . "\n";
+ print WR ".SH Severity\n";
+ print WR "$kmsg_desc{$tag}->{'SEV'}\n";
+ $argv = $kmsg_desc{$tag}->{'ARGV'};
+ if ($argv ne "") {
+ print WR ".SH Parameters\n";
+ @parms = split(/\s*\n\s*/,$kmsg_desc{$tag}->{'ARGV'});
+ foreach $parm (@parms) {
+ $parm =~ s/^\s*(.*)\s*$/$1/;
+ if (!($parm eq "")) {
+ print WR "$parm\n\n";
+ }
+ }
+ }
+ print WR ".SH Description";
+ print WR "$kmsg_desc{$tag}->{'DESC'}\n";
+ $user = $kmsg_desc{$tag}->{'USER'};
+ if ($user ne "") {
+ print WR ".SH User action";
+ print WR "$user\n";
+ }
+ }
+}
+
+if (defined($ENV{'srctree'})) {
+ $srctree = "$ENV{'srctree'}" . "/";
+} else {
+ $srctree = getcwd;
+}
+
+if (defined($ENV{'objtree'})) {
+ $objtree = "$ENV{'objtree'}" . "/";
+} else {
+ $objtree = getcwd;
+}
+
+if (defined($ENV{'SRCARCH'})) {
+ $srcarch = "$ENV{'SRCARCH'}" . "/";
+} else {
+ print "kmsg-doc called without a valid \$SRCARCH\n";
+ exit 1;
+}
+
+$option = shift;
+
+$cc = shift;
+$gcc_options = "-E -D __KMSG_CHECKER ";
+foreach $tmp (@ARGV) {
+ $tmp =~ s/\(/\\\(/;
+ $tmp =~ s/\)/\\\)/;
+ $gcc_options .= " $tmp";
+ $filename = $tmp;
+}
+
+$component = process_source_file($filename);
+if ($component ne "") {
+ process_source_file($srctree . "Documentation/kmsg/" . $srcarch . $component);
+ process_source_file($srctree . "Documentation/kmsg/" . $component);
+}
+
+if ($option eq "check") {
+ process_cpp_file($cc, $gcc_options, $filename, $component);
+ if (check_messages($component)) {
+ print_templates();
+ }
+} elsif ($option eq "print") {
+ write_man_pages();
+}
+
+exit($errors);
Index: kmsg-2.6/scripts/Makefile.build
===================================================================
--- kmsg-2.6.orig/scripts/Makefile.build
+++ kmsg-2.6/scripts/Makefile.build
@@ -211,12 +211,14 @@ endef
# Built-in and composite module parts
$(obj)/%.o: $(src)/%.c FORCE
$(call cmd,force_checksrc)
+ $(call cmd,force_check_kmsg)
$(call if_changed_rule,cc_o_c)
# Single-part modules are special since we need to mark them in $(MODVERDIR)
$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
$(call cmd,force_checksrc)
+ $(call cmd,force_check_kmsg)
$(call if_changed_rule,cc_o_c)
@{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
@@ -339,6 +341,18 @@ $(multi-used-m) : %.o: $(multi-objs-m) F
targets += $(multi-used-y) $(multi-used-m)
+# kmsg check tool
+ifneq ($(KBUILD_KMSG_CHECK),0)
+ ifeq ($(KBUILD_KMSG_CHECK),2)
+ kmsg_cmd := print
+ quiet_cmd_force_check_kmsg = KMSG_PRINT $<
+ $(shell [ -d $(objtree)/man ] || mkdir -p $(objtree)/man)
+ else
+ kmsg_cmd := check
+ quiet_cmd_force_check_kmsg = KMSG_CHECK $<
+ endif
+ cmd_force_check_kmsg = $(KMSG_CHECK) $(kmsg_cmd) $(CC) $(c_flags) $< ;
+endif
# Descending
# ---------------------------------------------------------------------------
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* [patch 4/6] kmsg: convert xpram messages to kmsg api.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
` (2 preceding siblings ...)
2008-09-25 16:28 ` [patch 3/6] kmsg: Kernel message catalog script Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-09-25 16:28 ` [patch 5/6] kmsg: convert vmcp " Martin Schwidefsky
2008-09-25 16:28 ` [patch 6/6] kmsg: convert lcs printk messages " Martin Schwidefsky
5 siblings, 0 replies; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Martin Schwidefsky
[-- Attachment #1: 803-kmsg-xpram.diff --]
[-- Type: text/plain, Size: 6978 bytes --]
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
Documentation/kmsg/s390/xpram | 61 ++++++++++++++++++++++++++++++++++++++++++
drivers/s390/block/xpram.c | 41 +++++++++++++---------------
2 files changed, 80 insertions(+), 22 deletions(-)
Index: kmsg-2.6/Documentation/kmsg/s390/xpram
===================================================================
--- /dev/null
+++ kmsg-2.6/Documentation/kmsg/s390/xpram
@@ -0,0 +1,61 @@
+/*?
+ * Tag: xpram.ab9aa4
+ * Text: "%d is not a valid number of XPRAM devices\n"
+ * Severity: Error
+ * Parameter:
+ * @1: number of partitions
+ * Description:
+ * The number of XPRAM partitions specified for the 'devs' module parameter
+ * or with the 'xpram.parts' kernel parameter must be an integer in the
+ * range 1 to 32. The XPRAM device driver created a maximum of 32 partitions
+ * that are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * command line and restart Linux.
+ */
+
+/*?
+ * Tag: xpram.f004d1
+ * Text: "Not enough expanded memory available\n"
+ * Severity: Error
+ * Description:
+ * The amount of expanded memory required to set up your XPRAM partitions
+ * depends on the 'sizes' parameter specified for the xpram module or on
+ * the specifications for the 'xpram.parts' parameter if the XPRAM device
+ * driver has been compiled into the kernel. Your
+ * current specification exceed the amount of available expanded memory.
+ * Your XPRAM partitions are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the xpram module and load it again with an appropriate value
+ * for the 'sizes' module parameter. If the XPRAM device driver has been
+ * compiled into the kernel, adjust the 'xpram.parts' parameter in the
+ * kernel command line and restart Linux. If you need more than the
+ * available expanded memory, increase the expanded memory allocation for
+ * your virtual hardware or LPAR.
+ */
+
+/*?
+ * Tag: xpram.f6ae78
+ * Text: "No expanded memory available\n"
+ * Severity: Error
+ * Description:
+ * The XPRAM device driver has been loaded in a Linux instance that runs
+ * in an LPAR or virtual hardware without expanded memory.
+ * are created.
+ * User action:
+ * Allocate expanded memory for your LPAR or virtual hardware or do not
+ * load the xpram module. You can ignore this message, if you do not want
+ * to create XPRAM partitions.
+ */
+
+/*? Tag: xpram.fc5e30 Text: " number of devices (partitions): %d \n" */
+/*? Tag: xpram.9a3d44 Text: " size of partition %d: %u kB\n" */
+/*? Tag: xpram.d1b9da Text: " size of partition %d to be set automatically\n" */
+/*? Tag: xpram.758fd6 Text: " memory needed (for sized partitions): %lu kB\n" */
+/*? Tag: xpram.3fc92b Text: " partitions to be sized automatically: %d\n" */
+/*? Tag: xpram.6cdcc1 Text: " automatically determined partition size: %lu kB\n" */
+/*? Tag: xpram.546055 Text: " %u pages expanded memory found (%lu KB).\n" */
Index: kmsg-2.6/drivers/s390/block/xpram.c
===================================================================
--- kmsg-2.6.orig/drivers/s390/block/xpram.c
+++ kmsg-2.6/drivers/s390/block/xpram.c
@@ -25,6 +25,8 @@
* generic hard disk support to replace ad-hoc partitioning
*/
+#define KMSG_COMPONENT "xpram"
+
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/ctype.h> /* isdigit, isxdigit */
@@ -36,18 +38,13 @@
#include <linux/hdreg.h> /* HDIO_GETGEO */
#include <linux/sysdev.h>
#include <linux/bio.h>
+#include <linux/kmsg.h>
#include <asm/uaccess.h>
#define XPRAM_NAME "xpram"
#define XPRAM_DEVS 1 /* one partition */
#define XPRAM_MAX_DEVS 32 /* maximal number of devices (partitions) */
-#define PRINT_DEBUG(x...) printk(KERN_DEBUG XPRAM_NAME " debug:" x)
-#define PRINT_INFO(x...) printk(KERN_INFO XPRAM_NAME " info:" x)
-#define PRINT_WARN(x...) printk(KERN_WARNING XPRAM_NAME " warning:" x)
-#define PRINT_ERR(x...) printk(KERN_ERR XPRAM_NAME " error:" x)
-
-
typedef struct {
unsigned int size; /* size of xpram segment in pages */
unsigned int offset; /* start page of xpram segment */
@@ -263,7 +260,7 @@ static int __init xpram_setup_sizes(unsi
/* Check number of devices. */
if (devs <= 0 || devs > XPRAM_MAX_DEVS) {
- PRINT_ERR("invalid number %d of devices\n",devs);
+ kmsg_err("%d is not a valid number of XPRAM devices\n",devs);
return -EINVAL;
}
xpram_devs = devs;
@@ -294,22 +291,22 @@ static int __init xpram_setup_sizes(unsi
mem_auto_no++;
}
- PRINT_INFO(" number of devices (partitions): %d \n", xpram_devs);
+ kmsg_info(" number of devices (partitions): %d \n", xpram_devs);
for (i = 0; i < xpram_devs; i++) {
if (xpram_sizes[i])
- PRINT_INFO(" size of partition %d: %u kB\n",
- i, xpram_sizes[i]);
+ kmsg_info(" size of partition %d: %u kB\n",
+ i, xpram_sizes[i]);
else
- PRINT_INFO(" size of partition %d to be set "
- "automatically\n",i);
+ kmsg_info(" size of partition %d to be set "
+ "automatically\n",i);
}
- PRINT_DEBUG(" memory needed (for sized partitions): %lu kB\n",
- mem_needed);
- PRINT_DEBUG(" partitions to be sized automatically: %d\n",
- mem_auto_no);
+ kmsg_info(" memory needed (for sized partitions): %lu kB\n",
+ mem_needed);
+ kmsg_info(" partitions to be sized automatically: %d\n",
+ mem_auto_no);
if (mem_needed > pages * 4) {
- PRINT_ERR("Not enough expanded memory available\n");
+ kmsg_err("Not enough expanded memory available\n");
return -EINVAL;
}
@@ -321,8 +318,8 @@ static int __init xpram_setup_sizes(unsi
*/
if (mem_auto_no) {
mem_auto = ((pages - mem_needed / 4) / mem_auto_no) * 4;
- PRINT_INFO(" automatically determined "
- "partition size: %lu kB\n", mem_auto);
+ kmsg_info(" automatically determined "
+ "partition size: %lu kB\n", mem_auto);
for (i = 0; i < xpram_devs; i++)
if (xpram_sizes[i] == 0)
xpram_sizes[i] = mem_auto;
@@ -412,12 +409,12 @@ static int __init xpram_init(void)
/* Find out size of expanded memory. */
if (xpram_present() != 0) {
- PRINT_WARN("No expanded memory available\n");
+ kmsg_err("No expanded memory available\n");
return -ENODEV;
}
xpram_pages = xpram_highest_page_index() + 1;
- PRINT_INFO(" %u pages expanded memory found (%lu KB).\n",
- xpram_pages, (unsigned long) xpram_pages*4);
+ kmsg_info(" %u pages expanded memory found (%lu KB).\n",
+ xpram_pages, (unsigned long) xpram_pages*4);
rc = xpram_setup_sizes(xpram_pages);
if (rc)
return rc;
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* [patch 5/6] kmsg: convert vmcp to kmsg api.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
` (3 preceding siblings ...)
2008-09-25 16:28 ` [patch 4/6] kmsg: convert xpram messages to kmsg api Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-09-25 16:28 ` [patch 6/6] kmsg: convert lcs printk messages " Martin Schwidefsky
5 siblings, 0 replies; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Christian Borntraeger, Martin Schwidefsky
[-- Attachment #1: 804-kmsg-vmcp.diff --]
[-- Type: text/plain, Size: 2330 bytes --]
From: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
drivers/s390/char/vmcp.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
Index: kmsg-2.6/drivers/s390/char/vmcp.c
===================================================================
--- kmsg-2.6.orig/drivers/s390/char/vmcp.c
+++ kmsg-2.6/drivers/s390/char/vmcp.c
@@ -11,12 +11,15 @@
* The idea of this driver is based on cpint from Neale Ferguson and #CP in CMS
*/
+#define KMSG_COMPONENT "vmcp"
+
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/smp_lock.h>
+#include <linux/kmsg.h>
#include <asm/cpcmd.h>
#include <asm/debug.h>
#include <asm/uaccess.h>
@@ -26,8 +29,6 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Christian Borntraeger <borntraeger@de.ibm.com>");
MODULE_DESCRIPTION("z/VM CP interface");
-#define PRINTK_HEADER "vmcp: "
-
static debug_info_t *vmcp_debug;
static int vmcp_open(struct inode *inode, struct file *file)
@@ -193,7 +194,8 @@ static int __init vmcp_init(void)
int ret;
if (!MACHINE_IS_VM) {
- PRINT_WARN("z/VM CP interface is only available under z/VM\n");
+ kmsg_warn("The z/VM CP interface device driver cannot be "
+ "loaded without z/VM\n");
return -ENODEV;
}
@@ -216,6 +218,21 @@ static int __init vmcp_init(void)
return 0;
}
+/*?
+ * Tag: vmcp.42661a
+ * Text: "The z/VM CP interface device driver cannot be loaded without z/VM\n"
+ * Severity: Warning
+ * Description:
+ * With the z/VM CP interface you can issue z/VM CP commands from a Linux
+ * terminal session. On Linux instances that run in environments other than
+ * the z/VM hypervisor, the z/VM CP interface does not provide any useful
+ * function and the corresponding vmcp device driver cannot be loaded.
+ * User action:
+ * Load the vmcp device driver only on Linux instances that run as guest
+ * operating systems of the z/VM hypervisor. If the device driver has been
+ * compiled into the kernel, ignore this message.
+ */
+
static void __exit vmcp_exit(void)
{
misc_deregister(&vmcp_dev);
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* [patch 6/6] kmsg: convert lcs printk messages to kmsg api.
2008-09-25 16:28 [patch 0/6] [RFC] kmsg macros, take x+3 Martin Schwidefsky
` (4 preceding siblings ...)
2008-09-25 16:28 ` [patch 5/6] kmsg: convert vmcp " Martin Schwidefsky
@ 2008-09-25 16:28 ` Martin Schwidefsky
2008-12-08 6:04 ` kprintk patch and OSS Message Pedia Takahashi, Hideki
5 siblings, 1 reply; 17+ messages in thread
From: Martin Schwidefsky @ 2008-09-25 16:28 UTC (permalink / raw)
To: linux-kernel, linux-s390, lf_kernel_messages, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher
Cc: Klaus-D. Wacker, Martin Schwidefsky
[-- Attachment #1: 805-kmsg-lcs.diff --]
[-- Type: text/plain, Size: 15462 bytes --]
>From Klaus-D. Wacker <kdwacker@de.ibm.com>
Signed-off-by: Klaus-D. Wacker <kdwacker@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
Documentation/kmsg/s390/lcs | 170 ++++++++++++++++++++++++++++++++++++++++++++
drivers/s390/net/lcs.c | 78 +++++++++++---------
2 files changed, 216 insertions(+), 32 deletions(-)
Index: kmsg-2.6/Documentation/kmsg/s390/lcs
===================================================================
--- /dev/null
+++ kmsg-2.6/Documentation/kmsg/s390/lcs
@@ -0,0 +1,170 @@
+/*?
+ * Tag: lcs.1666ed
+ * Text: "%s: Allocating a socket buffer to interface %s failed\n"
+ * Severity: Error
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * @2: network interface
+ * Description:
+ * LAN channel station (LCS) devices require a socket buffer (SKB) structure
+ * for storing incoming data. The LCS device driver failed to allocate an SKB
+ * structure to the LCS device. A likely cause of this problem is memory
+ * constraints.
+ * User action:
+ * Free some memory and repeat the failed operation.
+ */
+
+/*?
+ * Tag: lcs.fd3431
+ * Text: "%s: Shutting down the LCS device failed\n "
+ * Severity: Error
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * Description:
+ * A request to shut down a LAN channel station (LCS) device resulted in an
+ * error. The error is logged in the LCS trace at trace level 4.
+ * User action:
+ * Try again to shut down the device. If the error persists, see the LCS trace
+ * to find out what causes the error.
+ */
+
+/*?
+ * Tag: lcs.c4ca7a
+ * Text: "%s: Detecting a network adapter for LCS devices failed with rc=%d (0x%x)\n"
+ * Severity: Error
+ * Parameter:
+ * @1: lcs_detect return code in decimal notation
+ * @2: lcs_detect return code in hexadecimal notation
+ * Description:
+ * The LCS device driver could not initialize a network adapter.
+ * User action:
+ * Note the return codes from the error message and contact IBM support.
+ */
+
+/*?
+ * Tag: lcs.abd525
+ * Text: "%s: A recovery process has been started for the LCS device\n"
+ * Severity: Warning
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * Description:
+ * The LAN channel station (LCS) device is shut down and restarted. The recovery
+ * process might have been initiated by a user or started automatically as a
+ * response to a device problem.
+ * User action:
+ * Wait until a message indicates the completion of the recovery process.
+ */
+
+/*?
+ * Tag: lcs.43b3aa
+ * Text: "%s: An I/O-error occurred on the LCS device\n"
+ * Severity: Warning
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * Description:
+ * The LAN channel station (LCS) device reported a problem that can be recovered
+ * by the LCS device driver. Repeated occurrences of this problem indicate a
+ * malfunctioning device.
+ * User action:
+ * If this problem occurs frequently, initiate a recovery process for the
+ * device, for example, by writing '1' to the 'recover' sysfs attribute of the
+ * device.
+ */
+
+/*?
+ * Tag: lcs.d96565
+ * Text: "%s: A command timed out on the LCS device\n"
+ * Severity: Warning
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * Description:
+ * The LAN channel station (LCS) device reported a problem that can be recovered
+ * by the LCS device driver. Repeated occurrences of this problem indicate a
+ * malfunctioning device.
+ * User action:
+ * If this problem occurs frequently, initiate a recovery process for the
+ * device, for example, by writing '1' to the 'recover' sysfs attribute of the
+ * device.
+ */
+
+/*?
+ * Tag: lcs.dae31d
+ * Text: "%s: An error occurred on the LCS device, rc=%ld\n"
+ * Severity: Warning
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * @2: return code
+ * Description:
+ * The LAN channel station (LCS) device reported a problem that can be recovered
+ * by the LCS device driver. Repeated occurrences of this problem indicate a
+ * malfunctioning device.
+ * User action:
+ * If this problem occurs frequently, initiate a recovery process for the
+ * device, for example, by writing '1' to the 'recover' sysfs attribute of the
+ * device.
+ */
+
+/*?
+* Tag: lcs.45e59d
+ * Text: "%s: The LCS device stopped because of an error, dstat=0x%X, cstat=0x%X \n"
+ * Severity: Warning
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * @2: device status
+ * @3: subchannel status
+ * Description:
+ * The LAN channel station (LCS) device reported an error. The LCS device driver
+ * might start a device recovery process.
+ * User action:
+ * If the device driver does not start a recovery process, initiate a recovery
+ * process, for example, by writing '1' to the 'recover' sysfs attribute of the
+ * device. If the problem persists, note the status information provided with
+ * the message and contact IBM support.
+ */
+
+/*?
+ * Tag: lcs.c16f9f
+ * Text: "%s: Starting an LCS device resulted in an error, rc=%d!\n"
+ * Severity: Error
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * @2: ccw_device_start return code in decimal notation
+ * Description:
+ * The LAN channel station (LCS) device driver failed to initialize an LCS
+ * device. The device is not operational.
+ * User action:
+ * Initiate a recovery process, for example, by writing '1' to the 'recover'
+ * sysfs attribute of the device. If the problem persists, contact IBM support.
+ */
+
+/*?
+ * Tag: lcs.c5d9db
+ * Text: "%s: Sending data from the LCS device to the LAN failed with rc=%d\n"
+ * Severity: Error
+ * Parameter:
+ * @1: bus ID of the LCS device
+ * @2: ccw_device_resume return code in decimal notation
+ * Description:
+ * The LAN channel station (LCS) device driver could not send data to the LAN
+ * using the LCS device. This might be a temporary problem. Operations continue
+ * on the LCS device.
+ * User action:
+ * If this problem occurs frequently, initiate a recovery process, for example,
+ * by writing '1' to the 'recover' sysfs attribute of the device. If the
+ * problem persists, contact IBM support.
+ */
+
+/*? Tag: lcs.1ba8a7 Text: "Query IPAssist failed. Assuming unsupported!\n" */
+/*? Tag: lcs.c4901b Text: "Stoplan for %s initiated by LGW.\n" */
+/*? Tag: lcs.0760e8 Text: "Not enough memory to add new multicast entry!\n" */
+/*? Tag: lcs.d6f064 Text: "Not enough memory for debug facility.\n" */
+/*? Tag: lcs.85e209 Text: "Adding multicast address failed. Table possibly full!\n" */
+/*? Tag: lcs.f3f857 Text: "Error in opening device!\n" */
+/*? Tag: lcs.0aabaa Text: "LCS device %s %s IPv6 support\n" */
+/*? Tag: lcs.453fea Text: "Device %s successfully recovered!\n" */
+/*? Tag: lcs.ea2a85 Text: "LCS device %s %s Multicast support\n" */
+/*? Tag: lcs.38cb90 Text: " Initialization failed\n" */
+/*? Tag: lcs.35862f Text: "Loading %s\n" */
+/*? Tag: lcs.f53f45 Text: "Initialization failed\n" */
+/*? Tag: lcs.c5a5fa Text: "Terminating lcs module.\n" */
+/*? Tag: lcs.535a08 Text: "Device %s could not be recovered!\n" */
Index: kmsg-2.6/drivers/s390/net/lcs.c
===================================================================
--- kmsg-2.6.orig/drivers/s390/net/lcs.c
+++ kmsg-2.6/drivers/s390/net/lcs.c
@@ -26,6 +26,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define KMSG_COMPONENT "lcs"
+
#include <linux/module.h>
#include <linux/if.h>
#include <linux/netdevice.h>
@@ -36,6 +38,7 @@
#include <linux/in.h>
#include <linux/igmp.h>
#include <linux/delay.h>
+#include <linux/kmsg.h>
#include <net/arp.h>
#include <net/ip.h>
@@ -54,8 +57,6 @@
#error Cannot compile lcs.c without some net devices switched on.
#endif
-#define PRINTK_HEADER " lcs: "
-
/**
* initialization string for output
*/
@@ -96,7 +97,7 @@ lcs_register_debug_facility(void)
lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
lcs_dbf_trace = debug_register("lcs_trace", 4, 1, 8);
if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
- PRINT_ERR("Not enough memory for debug facility.\n");
+ kmsg_err("Not enough memory for debug facility.\n");
lcs_unregister_debug_facility();
return -ENOMEM;
}
@@ -502,7 +503,9 @@ lcs_start_channel(struct lcs_channel *ch
spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
if (rc) {
LCS_DBF_TEXT_(4,trace,"essh%s", channel->ccwdev->dev.bus_id);
- PRINT_ERR("Error in starting channel, rc=%d!\n", rc);
+ dev_err(&channel->ccwdev->dev,
+ "Starting an LCS device resulted in an error,"
+ " rc=%d!\n", rc);
}
return rc;
}
@@ -636,7 +639,9 @@ __lcs_resume_channel(struct lcs_channel
rc = ccw_device_resume(channel->ccwdev);
if (rc) {
LCS_DBF_TEXT_(4, trace, "ersc%s", channel->ccwdev->dev.bus_id);
- PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc);
+ dev_warn(&channel->ccwdev->dev,
+ "Sending data from the LCS device to the LAN failed"
+ " with rc=%d\n",rc);
} else
channel->state = LCS_CH_STATE_RUNNING;
return rc;
@@ -1082,7 +1087,7 @@ lcs_check_multicast_support(struct lcs_c
cmd->cmd.lcs_qipassist.num_ip_pairs = 1;
rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb);
if (rc != 0) {
- PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n");
+ kmsg_err("Query IPAssist failed. Assuming unsupported!\n");
return -EOPNOTSUPP;
}
if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
@@ -1115,8 +1120,8 @@ list_modified:
rc = lcs_send_setipm(card, ipm);
spin_lock_irqsave(&card->ipm_lock, flags);
if (rc) {
- PRINT_INFO("Adding multicast address failed. "
- "Table possibly full!\n");
+ kmsg_info("Adding multicast address failed."
+ " Table possibly full!\n");
/* store ipm in failed list -> will be added
* to ipm_list again, so a retry will be done
* during the next call of this function */
@@ -1227,8 +1232,8 @@ lcs_set_mc_addresses(struct lcs_card *ca
ipm = (struct lcs_ipm_list *)
kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
if (ipm == NULL) {
- PRINT_INFO("Not enough memory to add "
- "new multicast entry!\n");
+ kmsg_info("Not enough memory to add"
+ " new multicast entry!\n");
break;
}
memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
@@ -1302,18 +1307,21 @@ lcs_check_irb_error(struct ccw_device *c
switch (PTR_ERR(irb)) {
case -EIO:
- PRINT_WARN("i/o-error on device %s\n", cdev->dev.bus_id);
+ dev_warn(&cdev->dev,
+ "An I/O-error occurred on the LCS device\n");
LCS_DBF_TEXT(2, trace, "ckirberr");
LCS_DBF_TEXT_(2, trace, " rc%d", -EIO);
break;
case -ETIMEDOUT:
- PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id);
+ dev_warn(&cdev->dev,
+ "A command timed out on the LCS device\n");
LCS_DBF_TEXT(2, trace, "ckirberr");
LCS_DBF_TEXT_(2, trace, " rc%d", -ETIMEDOUT);
break;
default:
- PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb),
- cdev->dev.bus_id);
+ dev_warn(&cdev->dev,
+ "An error occurred on the LCS device, rc=%ld\n",
+ PTR_ERR(irb));
LCS_DBF_TEXT(2, trace, "ckirberr");
LCS_DBF_TEXT(2, trace, " rc???");
}
@@ -1399,8 +1407,10 @@ lcs_irq(struct ccw_device *cdev, unsigne
/* Check for channel and device errors presented */
rc = lcs_get_problem(cdev, irb);
if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
- PRINT_WARN("check on device %s, dstat=0x%X, cstat=0x%X \n",
- cdev->dev.bus_id, dstat, cstat);
+ dev_warn(&cdev->dev,
+ "The LCS device stopped because of an error,"
+ " dstat=0x%X, cstat=0x%X \n",
+ dstat, cstat);
if (rc) {
channel->state = LCS_CH_STATE_ERROR;
}
@@ -1757,7 +1767,7 @@ lcs_get_control(struct lcs_card *card, s
lcs_schedule_recovery(card);
break;
case LCS_CMD_STOPLAN:
- PRINT_WARN("Stoplan for %s initiated by LGW.\n",
+ kmsg_warn("Stoplan for %s initiated by LGW.\n",
card->dev->name);
if (card->dev)
netif_carrier_off(card->dev);
@@ -1786,7 +1796,8 @@ lcs_get_skb(struct lcs_card *card, char
skb = dev_alloc_skb(skb_len);
if (skb == NULL) {
- PRINT_ERR("LCS: alloc_skb failed for device=%s\n",
+ dev_err(&card->dev->dev,
+ " Allocating a socket buffer to interface %s failed\n",
card->dev->name);
card->stats.rx_dropped++;
return;
@@ -1882,7 +1893,8 @@ lcs_stop_device(struct net_device *dev)
(card->write.state != LCS_CH_STATE_RUNNING));
rc = lcs_stopcard(card);
if (rc)
- PRINT_ERR("Try it again!\n ");
+ dev_err(&card->dev->dev,
+ " Shutting down the LCS device failed\n ");
return rc;
}
@@ -1901,7 +1913,7 @@ lcs_open_device(struct net_device *dev)
/* initialize statistics */
rc = lcs_detect(card);
if (rc) {
- PRINT_ERR("LCS:Error in opening device!\n");
+ kmsg_err("Error in opening device!\n");
} else {
dev->flags |= IFF_UP;
@@ -2109,8 +2121,9 @@ lcs_new_device(struct ccwgroup_device *c
rc = lcs_detect(card);
if (rc) {
LCS_DBF_TEXT(2, setup, "dtctfail");
- PRINT_WARN("Detection of LCS card failed with return code "
- "%d (0x%x)\n", rc, rc);
+ dev_warn(&card->dev->dev,
+ "Detecting a network adapter for LCS devices"
+ " failed with rc=%d (0x%x)\n", rc, rc);
lcs_stopcard(card);
goto out;
}
@@ -2140,7 +2153,7 @@ lcs_new_device(struct ccwgroup_device *c
#endif
default:
LCS_DBF_TEXT(3, setup, "errinit");
- PRINT_ERR("LCS: Initialization failed\n");
+ kmsg_err(" Initialization failed\n");
goto out;
}
if (!dev)
@@ -2172,11 +2185,11 @@ netdev_out:
goto out;
/* Print out supported assists: IPv6 */
- PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
+ kmsg_info("LCS device %s %s IPv6 support\n", card->dev->name,
(card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
"with" : "without");
/* Print out supported assist: Multicast */
- PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
+ kmsg_info("LCS device %s %s Multicast support\n", card->dev->name,
(card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
"with" : "without");
return 0;
@@ -2244,14 +2257,15 @@ lcs_recovery(void *ptr)
return 0;
LCS_DBF_TEXT(4, trace, "recover2");
gdev = card->gdev;
- PRINT_WARN("Recovery of device %s started...\n", gdev->dev.bus_id);
+ dev_warn(&gdev->dev,
+ "A recovery process has been started for the LCS device\n");
rc = __lcs_shutdown_device(gdev, 1);
rc = lcs_new_device(gdev);
if (!rc)
- PRINT_INFO("Device %s successfully recovered!\n",
+ kmsg_info("Device %s successfully recovered!\n",
card->dev->name);
else
- PRINT_INFO("Device %s could not be recovered!\n",
+ kmsg_info("Device %s could not be recovered!\n",
card->dev->name);
lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
return 0;
@@ -2304,17 +2318,17 @@ __init lcs_init_module(void)
{
int rc;
- PRINT_INFO("Loading %s\n",version);
+ kmsg_info("Loading %s\n", version);
rc = lcs_register_debug_facility();
LCS_DBF_TEXT(0, setup, "lcsinit");
if (rc) {
- PRINT_ERR("Initialization failed\n");
+ kmsg_err("Initialization failed\n");
return rc;
}
rc = register_cu3088_discipline(&lcs_group_driver);
if (rc) {
- PRINT_ERR("Initialization failed\n");
+ kmsg_err("Initialization failed\n");
return rc;
}
return 0;
@@ -2327,7 +2341,7 @@ __init lcs_init_module(void)
static void
__exit lcs_cleanup_module(void)
{
- PRINT_INFO("Terminating lcs module.\n");
+ kmsg_info("Terminating lcs module.\n");
LCS_DBF_TEXT(0, trace, "cleanup");
unregister_cu3088_discipline(&lcs_group_driver);
lcs_unregister_debug_facility();
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 17+ messages in thread* kprintk patch and OSS Message Pedia
2008-09-25 16:28 ` [patch 6/6] kmsg: convert lcs printk messages " Martin Schwidefsky
@ 2008-12-08 6:04 ` Takahashi, Hideki
0 siblings, 0 replies; 17+ messages in thread
From: Takahashi, Hideki @ 2008-12-08 6:04 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
lf_kernel_messages@lists.linux-foundation.org, Rusty Russell,
Greg KH, Kay Sievers, Joe Perches, Tim Hockin, Andrew Morton,
Michael Holzheu, Gerrit Huizenga, Randy Dunlap, Jan Kara,
Pavel Machek, Sam Ravnborg, Jochen Voß, Kunai Takashi,
Tim Bird, Jan Blunck, Rick Troth, Utz Bacher, Klaus-D. Wacker,
server-messagedb-tf@ipa.go.jp
Hello Mr. Martin schwidefsky,
I expect your patch will be merged into the kernel tree soon.
My friends and I have been working for providing a kernel
message online manual called "OSS Message Pedia" (mPedia) in
Japan.
I’d like to introduce mPedia briefly here because the kprintk
patch will affect our mPedia activities in Japan.
Development of OSS Message Pedia was partly supported by IPA
(Information-Technology Promotion Agency) Japan and it has
been opened to the public.
mPedia has internationalization function inside but currently
it has only Japanese contents except some sample English contents.
For example, you can find English contents with the following URL:
http://ossmpedia.org/messages/linux/2.6.9-34.EL/297.en
(You can change the tag 'languages' to "ja" to get Japanese
contents.)
Also you can find some English documentation about mPedia by
visiting the following URL:
http://ossmpedia.wiki.sourceforge.net/
We hope we could have some contribution to the kernel messaging
with the mPedia activities in Japan. Though we don't have a
particular solution about how to tie-up the kernel messaging at
this moment, we think some difficulties in the mPedia maintenance
and enhancements could be reduced with the kprintk patch.
(1) We have about 850 kernel message explanation contents in
Japanese. The each content includes meaning, actions, etc.
(2) We're now considering how to translate Japanese contents
into English. (No bright idea came yet.)
We appreciate your efforts for improving kernel messaging and
the patch integration.
(I added "server-messagedb-tf@ipa.go.jp" in CC.)
Thank you.
Best Regards,
Hideki Takahashi
^ permalink raw reply [flat|nested] 17+ messages in thread