Skip to contentSkip to conversation

kmsg macros, take x+3.

RFC PATCH In review Martin Schwidefsky 5 participants 17 messages Sep 25, 2008 – Dec 8, 2008

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover kmsg macros, take x+3.

Greetings,
after a short chat with Greg on the kernel summit here is now the hopefully final version of the kernel message catalog patches. As version x+2 this uses automatically generated message hashes. The new thing is that there are no more special kmsg_dev_xxx macros, this version uses the standard dev_xxx macros. If a KMSG_COMPONENT is defined then dev_xxx will include the message hash after the driver name in the format:

<driver-name>.<message hash>: <device name>: <message>

The problem with finding the correct driver name in the kmsg-doc script has been solved by requiring that the driver name and KMSG_COMPONENT have to match. See patch #2.

To convert a driver to use the message tags you need to do:
1) Add KMSG_COMPONENT to the start of each source file of the driver:
#define KMSG_COMPONENT "driver-name"
The define should be before any of the includes.
2) Replace all normal printks with kmsg_err/kmsg_warn/kmsg_info/.. The dev_xxx printks do not need to be changed in any way.
3) Compile the driver
4) Check for missing messages by running "make D=1 <?.o>" on each of the object files of the driver. For example if I want to check the lcs driver I do "make D=1 drivers/s390/net/lcs.o". Alternatively you can check all object files of your current configuration with just "make D=1". Be prepared that this will take a while..
For each message that misses its documentation you'll get a blueprint.
5) Fill in the ksmg blueprint of the messages and copy the result to either the source file where the respective message is located or to a text file with the component as its name in Documentation/kmsg.
6) Create the man pages your driver with "make D=2 <?.o>".

Greg: could you please comment on patch number #2 if this is ok with you now?

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#1 lore raw

PATCH 1/6 kmsg: tagged kernel messages.

From: Martin Schwidefsky <[email protected]>
From: Michael Holzheu <[email protected]>

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.

---

 arch/s390/Kconfig    |    9 +++++++++
 include/linux/kmsg.h |   42 ++++++++++++++++++++++++++++++++++++++++++
 kernel/printk.c      |   24 ++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
arch/s390/Kconfig +9 -0
Index: 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"
include/linux/kmsg.h new file +42 -0

42 lines not on this page · raw message

kernel/printk.c +24 -0
Index: 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
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#2 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Quoted 4 lines · On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
include/linux/kmsg.h new file +4 -0
+#define kmsg_emerg(fmt, ...) \
+	kmsg_printk_hash(KERN_EMERG, fmt, ##__VA_ARGS__)
+#define kmsg_alert(fmt, ...) \
+	kmsg_printk_hash(KERN_ALERT, fmt, ##__VA_ARGS__)

include/linux/kmsg.h line 32

Quoted 10 lines
include/linux/kmsg.h new file +10 -0
+#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.

#3 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Quoted 10 lines · Rusty Russell
Quoted 9 lines · On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
include/linux/kmsg.h new file +9 -0
+#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, ...) \
Quoted 8 lines

include/linux/kmsg.h line 32

Quoted 5 lines
include/linux/kmsg.h new file +5 -0
+	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?

Signature · 4 lines
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.
#4 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Quoted 20 lines · On Friday 26 September 2008 18:29:34 Martin Schwidefsky wrote:
Quoted 10 lines · Rusty Russell
Quoted 9 lines · On Friday 26 September 2008 02:28:28 Martin Schwidefsky wrote:
include/linux/kmsg.h new file +9 -0
+#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, ...) \
Quoted 8 lines

include/linux/kmsg.h line 32

Quoted 5 lines
include/linux/kmsg.h new file +5 -0
+	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?

Quoted 4 lines

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.

#5 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Quoted 11 lines · Rusty Russell
Quoted 4 lines

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?

Signature · 4 lines
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.
#6 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Quoted 9 lines · On Sunday 28 September 2008 09:16:40 Martin Schwidefsky wrote:
Quoted 5 lines · Rusty Russell

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.

#7 lore raw

Re: [patch 1/6] kmsg: tagged kernel messages.

Am Sonntag, 28. September 2008 schrieb Rusty Russell:

Quoted 11 lines · On Sunday 28 September 2008 09:16:40 Martin Schwidefsky wrote:
Quoted 9 lines · Rusty Russell
Quoted 5 lines

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

#8 lore raw

PATCH 2/6 kmsg: tagged device messages.

In reply to Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>
From: Michael Holzheu <[email protected]>

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__'.

---

 include/linux/device.h |   57 ++++++++++++++++++++++++++++++-------------------
 kernel/printk.c        |   22 ++++++++++++++++++
 2 files changed, 57 insertions(+), 22 deletions(-)
include/linux/device.h +35 -22
Index: 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. */
kernel/printk.c +22 -0
Index: 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
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
Acked-by on v1 2/6
#9 lore raw

Re: [patch 2/6] kmsg: tagged device messages.

Quoted 19 lines · Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>
From: Michael Holzheu <[email protected]>

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.

Quoted 6 lines

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__'.

Nice, thanks for reworking this. Feel free to add:

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

#10 lore raw

Re: [patch 2/6] kmsg: tagged device messages.

Quoted 3 lines · Greg KH

Nice, thanks for reworking this. Feel free to add:

here.

Good, I will do that.

Quoted 3 lines

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.

Signature · 4 lines
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.
#11 lore raw

Re: [patch 2/6] kmsg: tagged device messages.

Quoted 8 lines · Martin Schwidefsky
Quoted 3 lines · Greg KH

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

#12 lore raw

PATCH 3/6 kmsg: Kernel message catalog script.

In reply to Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>
From: Michael Holzheu <[email protected]>

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.

---

 Makefile               |   16 +
 scripts/Makefile.build |   14 +
 scripts/kmsg-doc       |  466 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 496 insertions(+)
Makefile +16 -0
Index: 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
scripts/kmsg-doc new file +466 -0

466 lines not on this page · raw message

scripts/Makefile.build +14 -0
Index: 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
 # ---------------------------------------------------------------------------
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#13 lore raw

PATCH 4/6 kmsg: convert xpram messages to kmsg api.

In reply to Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>

---

 Documentation/kmsg/s390/xpram |   61 ++++++++++++++++++++++++++++++++++++++++++
 drivers/s390/block/xpram.c    |   41 +++++++++++++---------------
 2 files changed, 80 insertions(+), 22 deletions(-)
Documentation/kmsg/s390/xpram new file +61 -0
Index: 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" */
drivers/s390/block/xpram.c +19 -22

92 lines not on this page · raw message

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#14 lore raw

PATCH 5/6 kmsg: convert vmcp to kmsg api.

In reply to Martin Schwidefsky

From: Christian Borntraeger <[email protected]>

---

 drivers/s390/char/vmcp.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/s390/char/vmcp.c +20 -3
Index: 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 <[email protected]>");
 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);
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#15 lore raw

PATCH 6/6 kmsg: convert lcs printk messages to kmsg api.

In reply to Martin Schwidefsky

From Klaus-D. Wacker <[email protected]>

---

 Documentation/kmsg/s390/lcs |  170 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/s390/net/lcs.c      |   78 +++++++++++---------
 2 files changed, 216 insertions(+), 32 deletions(-)
Documentation/kmsg/s390/lcs new file +170 -0
Index: 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" */
drivers/s390/net/lcs.c +46 -32

228 lines not on this page · raw message

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#16 lore raw

kprintk patch and OSS Message Pedia

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 "[email protected]" in CC.)

Thank you.

Best Regards,
Hideki Takahashi