linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 00/15] [RFC] kmsg macros and script.
@ 2008-07-28 17:53 Martin Schwidefsky
  2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
                   ` (14 more replies)
  0 siblings, 15 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:53 UTC (permalink / raw)
  To: linux-kernel, linux-s390

Greetings,
this is the next step of our project to document all s390 specific
kernel messages. The message cleanup patches have been integrated
into the upstream kernel. After we removed the meaningless messages
it is now time to brush up the remaining messages.

The first patch introduces a new set of wrapper macros around printk.
These macros add a prefix to each message and a message id can be
specified. The second patch adds a script to help writing the kmsg
comments that describe a kmsg and it can be used to write man pages
for the documented messages. The remaining 13 patches convert some of
the printk messages found in the s390 architecture files and some of
the s390 device drivers to demonstrate how all this is supposed to
work.

The code is currently only usable for s390. Should this be of interest
to other architectures as well we have to think about where to put
things. We'd be happy to get feedback on this.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
@ 2008-07-28 17:53 ` Martin Schwidefsky
  2008-07-28 18:12   ` Joe Perches
  2008-07-30  8:30   ` Andrew Morton
  2008-07-28 17:53 ` [patch 02/15] kmsg: Kernel message catalog script Martin Schwidefsky
                   ` (13 subsequent siblings)
  14 siblings, 2 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:53 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Michael Holzheu, Martin Schwidefsky

[-- Attachment #1: 800-kmsg-macros.diff --]
[-- Type: text/plain, Size: 6284 bytes --]

From: Michael Holzheu <holzheu@de.ibm.com>
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Introduce a new family of printk macros which prefixes each kmsg message
with a component name and allows to tag the printk with a message id.

The kmsg component name is defined per source file with the KMSG_COMPONENT
macro. The first argument of each kmsg printk is the message id. The
message id "0" is special as it will suppress the message id prefix.

If the message id 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/asm-s390/kmsg.h |  124 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

Index: quilt-2.6/arch/s390/Kconfig
===================================================================
--- quilt-2.6.orig/arch/s390/Kconfig
+++ quilt-2.6/arch/s390/Kconfig
@@ -568,6 +568,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: quilt-2.6/include/asm-s390/kmsg.h
===================================================================
--- /dev/null
+++ quilt-2.6/include/asm-s390/kmsg.h
@@ -0,0 +1,124 @@
+#ifndef _ASM_KMSG_H
+#define _ASM_KMSG_H
+
+#ifndef __KMSG_CHECKER
+#define __KMSG_CHECK(level, id) KERN_##level
+#endif
+
+#if defined(__KMSG_CHECKER) || !defined(CONFIG_KMSG_IDS)
+
+#define kmsg_dev_alert(id, dev, format, arg...) \
+	printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+		": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_err(id, dev, format, arg...) \
+	printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+		": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_warn(id, dev, format, arg...) \
+	printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+		": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_info(id, dev, format, arg...) \
+	printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+		": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_notice(id, dev, format, arg...) \
+	printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+		": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_alert(id, format, arg...) \
+	printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+		": " format, ## arg)
+
+#define kmsg_err(id, format, arg...) \
+	printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+		": " format, ## arg)
+
+#define kmsg_warn(id, format, arg...) \
+	printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+		": " format, ## arg)
+
+#define kmsg_info(id, format, arg...) \
+	printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+		": " format, ## arg)
+
+#define kmsg_notice(id, format, arg...) \
+	printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+		": " format, ## arg)
+
+#else  /* __KMSG_CHECKER || !CONFIG_KMSG_IDS */
+
+#define kmsg_dev_alert(id, dev, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+			"." #id ": %s: " format, (dev)->bus_id , ## arg) : \
+		printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+			": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_err(id, dev, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+			"." #id ": %s: " format, (dev)->bus_id , ## arg) : \
+		printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+			": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_warn(id, dev, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+			"." #id ": %s: " format, (dev)->bus_id , ## arg) : \
+		printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+			": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_info(id, dev, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+			"." #id ": %s: " format, (dev)->bus_id , ## arg) : \
+		printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+			": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_dev_notice(id, dev, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+			"." #id ": %s: " format, (dev)->bus_id , ## arg) : \
+		printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+			": %s: " format, (dev)->bus_id , ## arg)
+
+#define kmsg_alert(id, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+			"." #id ": " format, ## arg) : \
+		printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+			": " format, ## arg)
+
+#define kmsg_err(id, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+			"." #id ": " format, ## arg) : \
+		printk(__KMSG_CHECK(ERR, id) KMSG_COMPONENT \
+			": " format, ## arg)
+
+#define kmsg_warn(id, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+			"." #id ": " format, ## arg) : \
+		printk(__KMSG_CHECK(WARNING, id) KMSG_COMPONENT \
+			": " format, ## arg)
+
+#define kmsg_info(id, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+			"." #id ": " format, ## arg) : \
+		printk(__KMSG_CHECK(INFO, id) KMSG_COMPONENT \
+			": " format, ## arg)
+
+#define kmsg_notice(id, format, arg...) \
+	(__builtin_constant_p(id) && (id) > 0) ? \
+		printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+			"." #id ": " format, ## arg) : \
+		printk(__KMSG_CHECK(NOTICE, id) KMSG_COMPONENT \
+			": " format, ## arg)
+
+#endif /* __KMSG_CHECKER || !CONFIG_KMSG_IDS */
+
+#endif /* _ASM_KMSG_H */

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
  2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
@ 2008-07-28 17:53 ` Martin Schwidefsky
  2008-07-28 19:28   ` Sam Ravnborg
  2008-07-28 17:53 ` [patch 03/15] kmsg: convert cio message to kmsg api Martin Schwidefsky
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:53 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Michael Holzheu, Martin Schwidefsky

[-- Attachment #1: 801-kmsg-script.diff --]
[-- Type: text/plain, Size: 13704 bytes --]

From: Michael Holzheu <holzheu@de.ibm.com>
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Add a script and the calls to the make process that allows to check the
kmsg printk messages and to format man pages from the message descriptions.

The kmsg message description is a comment with the following format:

/*?
 * Tag: <component>.<id>
 * 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 script looks for a kmsg comment for a kmsg printk at two places,
the source file where the kmsg call is located and in the file
Documentation/s390/kmsg/<component>.

The kmsg check is invoked with "make K=1" and reads the source files for
all objects that are built by the current configuration and searches for
matching kmsg descriptions for the kmsg messages in the source which
have a messages id > 0. 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 K=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 |   15 ++
 scripts/kmsg-doc       |  358 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 389 insertions(+)

Index: quilt-2.6/Makefile
===================================================================
--- quilt-2.6.orig/Makefile
+++ quilt-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 K=1' to enable checking
+# Use 'make K=2' to create the message catalog
+
+ifdef K
+  ifeq ("$(origin K)", "command line")
+    KBUILD_KMSG_CHECK = $(K)
+  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
@@ -317,6 +331,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)
@@ -351,6 +366,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: quilt-2.6/scripts/kmsg-doc
===================================================================
--- /dev/null
+++ quilt-2.6/scripts/kmsg-doc
@@ -0,0 +1,358 @@
+#!/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;
+
+my $errors = 0;
+my $warnings = 0;
+my $srctree = "";
+my $objtree = "";
+my $kmsg_count = 0;
+
+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 =~ s/\" \"//g; # remove ...
+    $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, $id, $text, $sev, $argv) = @_;
+    my ($tag, $count, $parm);
+
+    if ($id == 0) {
+	return;
+    }
+    $text =~ s/\\n//g; # remove trailing newline character
+    $text =~ s/\" \"//g; # remove ...
+    $text =~ s/$component:\s*//g;
+    $tag = $component . "." . $id;
+    # Pretty print severity
+    $sev =~ s/EMERG/Emerg/;
+    $sev =~ s/ALERT/Alert/;
+    $sev =~ s/CRIT/Critical/;
+    $sev =~ s/ERR/Error/;
+    $sev =~ s/WARNING/Warning/;
+    $sev =~ s/NOTICE/Notice/;
+    $sev =~ s/INFO/Informational/;
+    $sev =~ s/DEBUG/Debug/;
+    $kmsg_print{$kmsg_count}->{'TAG'} = $tag;
+    $kmsg_print{$kmsg_count}->{'TEXT'} = $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 "<id>"
+	if (/^#define\s+KMSG_COMPONENT\s+\"(.*)\"[^\"]*$/o) {
+	    $component = $1;
+	}
+	if ($state == 0) {
+	    # kmsg message start: '/*?'
+	    if (/^\s*\/\*\?\s*$/o) {
+		$state = 1;
+		($tag, $text, $sev, $argv, $desc, $user) = ( "", "", "", "", "", "" );
+	    }
+	} elsif ($state == 1) {
+	    # kmsg message tag: ' * Tag: <tag>'
+	    if (/^\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 (/.*printk\(\s*__KMSG_CHECK\s*\(([^,]*)\,\s*(\d+)\s*\)\s*\"(.*)\"\s*,\s*(.*)\s*\)/o) {
+	    if ($component ne "") {
+		add_kmsg_print($component, $2, $3, $1, $4)
+	    } else {
+		warn "Error(${file}:$.): kmsg without component\n";
+		$errors++;
+	    }
+	} elsif (/.*printk\(\s*__KMSG_CHECK\s*\(([^,]*)\,\s*(\d+)\s*\)\s*\"(.*)\"\s*(.*)\s*\)/o) {
+	    if ($component ne "") {
+		add_kmsg_print($component, $2, $3, $1, $4)
+	    } 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";
+    @tags = keys %kmsg_desc;
+    @nums = ();
+    for (@tags) {
+	push @nums, /\.(\d+)/;
+    }
+    foreach $tag (@tags[ sort { $nums[$a] <=> $nums[$b] } 0..$#tags ]) {
+	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;
+	}
+	$file = $objtree . "man/" . $tag;
+	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(/,/,$kmsg_desc{$tag}->{'ARGV'});
+	    map{s/\s*//} @parms;
+	    foreach $parm (@parms) {
+		$parm =~ s/^\s+//;
+		if (!($parm eq "")) {
+		    print WR "$parm\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;
+}
+
+$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/s390/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: quilt-2.6/scripts/Makefile.build
===================================================================
--- quilt-2.6.orig/scripts/Makefile.build
+++ quilt-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,19 @@ $(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 = SRCTREE=$(srctree) OBJTREE=$(objtree) \
+			$(KMSG_CHECK) $(kmsg_cmd) $(CC) $(c_flags) $< ;
+endif
 
 # Descending
 # ---------------------------------------------------------------------------

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 03/15] kmsg: convert cio message to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
  2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
  2008-07-28 17:53 ` [patch 02/15] kmsg: Kernel message catalog script Martin Schwidefsky
@ 2008-07-28 17:53 ` Martin Schwidefsky
  2008-07-28 17:53 ` [patch 04/15] kmsg: convert vmcp " Martin Schwidefsky
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:53 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Michael Ernst, Martin Schwidefsky

[-- Attachment #1: 802-kmsg-cio.diff --]
[-- Type: text/plain, Size: 9395 bytes --]

From: Michael Ernst <mernst@de.ibm.com>

Signed-off-by: Michael Ernst <mernst@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/cio  |   97 +++++++++++++++++++++++++++++++++++++++++++
 drivers/s390/cio/blacklist.c |   14 +++---
 drivers/s390/cio/chsc.c      |    9 ++-
 drivers/s390/cio/cio.c       |    5 +-
 drivers/s390/cio/cmf.c       |    8 ++-
 drivers/s390/cio/css.c       |    7 ++-
 6 files changed, 126 insertions(+), 14 deletions(-)

Index: quilt-2.6/Documentation/s390/kmsg/cio
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/cio
@@ -0,0 +1,97 @@
+/*?
+ * Tag: cio.1
+ * Text: "%s is not a valid device for the cio_ignore kernel parameter"
+ * Severity: Warning
+ * Parameter:
+ *   @1: device bus-ID
+ * Description:
+ * The device specification for the cio_ignore kernel parameter is
+ * syntactically incorrect or specifies an unknown device. This device is not
+ * excluded from being sensed and analyzed.
+ * User action:
+ * Correct your device specification in the kernel parameter line to have the
+ * device excluded when you next reboot Linux. You can write the correct
+ * device specification to /proc/cio_ignore to add the device to the list of
+ * devices to be excluded. This does not immediately make the device
+ * inaccessible but the device is ignored if it disappears and later reappears.
+ */
+
+/*?
+ * Tag: cio.2
+ * Text: "0.%x.%04x to 0.%x.%04x is not a valid range for cio_ignore"
+ * Severity: Warning
+ * Parameter:
+ *   @1: from subchannel set ID
+ *   @2: from device number
+ *   @3: to subchannel set ID
+ *   @4: to device number
+ * Description:
+ * The device range specified for the cio_ignore kernel parameter is
+ * syntactically incorrect. No devices specified with this range are
+ * excluded from being sensed and analyzed.
+ * User action:
+ * Correct your range specification in the kernel parameter line to have the
+ * range of devices  excluded when you next reboot Linux. You can write the
+ * correct range specification to /proc/cio_ignore to add the range of devices
+ * to the list of devices to be excluded. This does not immediately make the
+ * devices in the range inaccessible but any of these devices are ignored if
+ * they disappear and later reappear.
+ */
+
+/*?
+ * Tag: cio.3
+ * Text: "Processing %s for channel path %x.%02x"
+ * Severity: Notice
+ * Parameter:
+ *   @1: configuration change
+ *   @2: channel subsystem ID
+ *   @3: CHPID
+ * Description:
+ * A configuration change is in progress for the given channel path.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: cio.4
+ * Text: "No CCW console was found"
+ * Severity: Warning
+ * Description:
+ * Linux did not find the expected CCW console and tries to use an alternative
+ * console. A possible reason why the console was not found is that the console
+ * has been specified in the cio_ignore list.
+ * User action:
+ * None, if an appropriate alternative console has been found, and you want
+ * to use this alternative console. If you want to use the CCW console, ensure
+ * that is not specified in the cio_ignore list, explicitly specify the console
+ * with the 'condev=' kernel parameter, and reboot Linux.
+ */
+
+/*?
+ * Tag: cio.5
+ * Text: "Channel measurement facility initialized using format %s (mode %s)"
+ * Severity: Informational
+ * Parameter:
+ *   @1: format
+ *   @2: mode
+ * Description:
+ * The channel measurement facility has been initialized successfully. Format
+ * 'extended' should be used for z990 and later mainframe systems. Format
+ * 'basic' is intended for earlier mainframes. Mode 'autodetected' means that
+ * the format has been set automatically. Mode 'parameter' means that the
+ * format has been set according to the 'format=' kernel parameter.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: cio.6
+ * Text: "The CSS device driver initialization failed with errno=%d"
+ * Severity: Alert
+ * Parameter:
+ *   @1: Return code
+ * Description:
+ * The channel subsystem bus could not be established.
+ * User action:
+ * See the errno man page to find out what caused the problem.
+ */
Index: quilt-2.6/drivers/s390/cio/blacklist.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/blacklist.c
+++ quilt-2.6/drivers/s390/cio/blacklist.c
@@ -19,12 +19,15 @@
 
 #include <asm/cio.h>
 #include <asm/uaccess.h>
+#include <asm/kmsg.h>
 
 #include "blacklist.h"
 #include "cio.h"
 #include "cio_debug.h"
 #include "css.h"
 
+#define KMSG_COMPONENT "cio"
+
 /*
  * "Blacklisting" of certain devices:
  * Device numbers given in the commandline as cio_ignore=... won't be known
@@ -49,9 +52,10 @@ static int blacklist_range(range_action 
 {
 	if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
 		if (msgtrigger)
-			printk(KERN_WARNING "cio: Invalid cio_ignore range "
-			       "0.%x.%04x-0.%x.%04x\n", from_ssid, from,
-			       to_ssid, to);
+			kmsg_warn(2, "0.%x.%04x to 0.%x.%04x is not a valid "
+				  "range for cio_ignore\n", from_ssid, from,
+				  to_ssid, to);
+
 		return 1;
 	}
 
@@ -139,8 +143,8 @@ static int parse_busid(char *str, unsign
 	rc = 0;
 out:
 	if (rc && msgtrigger)
-		printk(KERN_WARNING "cio: Invalid cio_ignore device '%s'\n",
-		       str);
+		kmsg_warn(1, "%s is not a valid device for the cio_ignore "
+			  "kernel parameter\n", str);
 
 	return rc;
 }
Index: quilt-2.6/drivers/s390/cio/chsc.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/chsc.c
+++ quilt-2.6/drivers/s390/cio/chsc.c
@@ -16,7 +16,7 @@
 #include <asm/cio.h>
 #include <asm/chpid.h>
 #include <asm/chsc.h>
-
+#include <asm/kmsg.h>
 #include "../s390mach.h"
 #include "css.h"
 #include "cio.h"
@@ -25,6 +25,8 @@
 #include "chp.h"
 #include "chsc.h"
 
+#define KMSG_COMPONENT "cio"
+
 static void *sei_page;
 
 /**
@@ -333,6 +335,7 @@ static void chsc_process_sei_chp_config(
 	struct chp_config_data *data;
 	struct chp_id chpid;
 	int num;
+	char *events[3] = {"configure", "deconfigure", "cancel deconfigure"};
 
 	CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n");
 	if (sei_area->rs != 0)
@@ -343,8 +346,8 @@ static void chsc_process_sei_chp_config(
 		if (!chp_test_bit(data->map, num))
 			continue;
 		chpid.id = num;
-		printk(KERN_WARNING "cio: processing configure event %d for "
-		       "chpid %x.%02x\n", data->op, chpid.cssid, chpid.id);
+		kmsg_notice(3, "Processing %s for channel path %x.%02x\n",
+			    events[data->op], chpid.cssid, chpid.id);
 		switch (data->op) {
 		case 0:
 			chp_cfg_schedule(chpid, 1);
Index: quilt-2.6/drivers/s390/cio/cio.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/cio.c
+++ quilt-2.6/drivers/s390/cio/cio.c
@@ -27,6 +27,7 @@
 #include <asm/isc.h>
 #include <asm/cpu.h>
 #include <asm/fcx.h>
+#include <asm/kmsg.h>
 #include "cio.h"
 #include "css.h"
 #include "chsc.h"
@@ -37,6 +38,8 @@
 #include "chp.h"
 #include "../s390mach.h"
 
+#define KMSG_COMPONENT "cio"
+
 debug_info_t *cio_debug_msg_id;
 debug_info_t *cio_debug_trace_id;
 debug_info_t *cio_debug_crw_id;
@@ -770,7 +773,7 @@ cio_probe_console(void)
 	sch_no = cio_get_console_sch_no();
 	if (sch_no == -1) {
 		console_subchannel_in_use = 0;
-		printk(KERN_WARNING "cio: No ccw console found!\n");
+		kmsg_warn(4, "No CCW console was found\n");
 		return ERR_PTR(-ENODEV);
 	}
 	memset(&console_subchannel, 0, sizeof(struct subchannel));
Index: quilt-2.6/drivers/s390/cio/cmf.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/cmf.c
+++ quilt-2.6/drivers/s390/cio/cmf.c
@@ -38,6 +38,7 @@
 #include <asm/cio.h>
 #include <asm/cmb.h>
 #include <asm/div64.h>
+#include <asm/kmsg.h>
 
 #include "cio.h"
 #include "css.h"
@@ -45,6 +46,8 @@
 #include "ioasm.h"
 #include "chsc.h"
 
+#define KMSG_COMPONENT "cio"
+
 /*
  * parameter to enable cmf during boot, possible uses are:
  *  "s390cmf" -- enable cmf and allocate 2 MB of ram so measuring can be
@@ -1359,9 +1362,8 @@ static int __init init_cmf(void)
 	default:
 		return 1;
 	}
-
-	printk(KERN_INFO "cio: Channel measurement facility using %s "
-	       "format (%s)\n", format_string, detect_string);
+	kmsg_info(5, "Channel measurement facility initialized using format "
+		  "%s (mode %s)\n", format_string, detect_string);
 	return 0;
 }
 
Index: quilt-2.6/drivers/s390/cio/css.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/css.c
+++ quilt-2.6/drivers/s390/cio/css.c
@@ -14,6 +14,7 @@
 #include <linux/list.h>
 #include <linux/reboot.h>
 #include <asm/isc.h>
+#include <asm/kmsg.h>
 
 #include "../s390mach.h"
 #include "css.h"
@@ -25,6 +26,8 @@
 #include "idset.h"
 #include "chp.h"
 
+#define KMSG_COMPONENT "cio"
+
 int css_init_done = 0;
 static int need_reprobe = 0;
 static int max_ssid = 0;
@@ -841,8 +844,8 @@ out:
 	s390_unregister_crw_handler(CRW_RSC_CSS);
 	chsc_free_sei_area();
 	kfree(slow_subchannel_set);
-	printk(KERN_WARNING"cio: failed to initialize css driver (%d)!\n",
-	       ret);
+	kmsg_alert(6, "The CSS device driver initialization failed with "
+		   "errno=%d\n", ret);
 	return ret;
 }
 

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 04/15] kmsg: convert vmcp to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (2 preceding siblings ...)
  2008-07-28 17:53 ` [patch 03/15] kmsg: convert cio message to kmsg api Martin Schwidefsky
@ 2008-07-28 17:53 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 05/15] kmsg: convert cpcmd " Martin Schwidefsky
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:53 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Christian Borntraeger, Martin Schwidefsky

[-- Attachment #1: 803-kmsg-vmcp.diff --]
[-- Type: text/plain, Size: 2149 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>
---

 Documentation/s390/kmsg/vmcp |   15 +++++++++++++++
 drivers/s390/char/vmcp.c     |    6 ++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

Index: quilt-2.6/Documentation/s390/kmsg/vmcp
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/vmcp
@@ -0,0 +1,15 @@
+/*?
+ * Tag: vmcp.1
+ * Text: "The z/VM CP interface device driver cannot be loaded without z/VM"
+ * 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.
+ */
+
Index: quilt-2.6/drivers/s390/char/vmcp.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/vmcp.c
+++ quilt-2.6/drivers/s390/char/vmcp.c
@@ -19,6 +19,7 @@
 #include <linux/smp_lock.h>
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
+#include <asm/kmsg.h>
 #include <asm/uaccess.h>
 #include "vmcp.h"
 
@@ -26,7 +27,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Christian Borntraeger <borntraeger@de.ibm.com>");
 MODULE_DESCRIPTION("z/VM CP interface");
 
-#define PRINTK_HEADER "vmcp: "
+#define KMSG_COMPONENT "vmcp"
 
 static debug_info_t *vmcp_debug;
 
@@ -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(1, "The z/VM CP interface device driver cannot be "
+			     "loaded without z/VM\n");
 		return -ENODEV;
 	}
 

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 05/15] kmsg: convert cpcmd to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (3 preceding siblings ...)
  2008-07-28 17:53 ` [patch 04/15] kmsg: convert vmcp " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 06/15] kmsg: convert vmur " Martin Schwidefsky
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Christian Borntraeger, Martin Schwidefsky

[-- Attachment #1: 804-kmsg-cpcmd.diff --]
[-- Type: text/plain, Size: 2344 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>
---

 Documentation/s390/kmsg/cpcmd |   18 ++++++++++++++++++
 arch/s390/kernel/cpcmd.c      |    7 +++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

Index: quilt-2.6/arch/s390/kernel/cpcmd.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/cpcmd.c
+++ quilt-2.6/arch/s390/kernel/cpcmd.c
@@ -15,9 +15,12 @@
 #include <linux/string.h>
 #include <asm/ebcdic.h>
 #include <asm/cpcmd.h>
+#include <asm/kmsg.h>
 #include <asm/system.h>
 #include <asm/io.h>
 
+#define KMSG_COMPONENT "cpcmd"
+
 static DEFINE_SPINLOCK(cpcmd_lock);
 static char cpcmd_buf[241];
 
@@ -104,8 +107,8 @@ int cpcmd(const char *cmd, char *respons
 			(((unsigned long)response + rlen) >> 31)) {
 		lowbuf = kmalloc(rlen, GFP_KERNEL | GFP_DMA);
 		if (!lowbuf) {
-			printk(KERN_WARNING
-				"cpcmd: could not allocate response buffer\n");
+			kmsg_warn(1, "The cpcmd kernel function failed to "
+				     "allocate a response buffer\n");
 			return -ENOMEM;
 		}
 		spin_lock_irqsave(&cpcmd_lock, flags);
Index: quilt-2.6/Documentation/s390/kmsg/cpcmd
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/cpcmd
@@ -0,0 +1,18 @@
+/*?
+ * Text: "The cpcmd kernel function failed to allocate a response buffer"
+ * Tag: cpcmd.1
+ * Severity: Warning
+ * Description:
+ * IPL code, console detection, and device drivers like vmcp or vmlogrdr use
+ * the cpcmd kernel function to send commands to the z/VM control program (CP).
+ * If a program that uses the cpcmd function does not allocate a contiguous
+ * response buffer below 2 GB guest real storage, cpcmd creates a bounce buffer
+ * to be used as the response buffer. Because of low memory or memory
+ * fragmentation, cpcmd could not create the bounce buffer.
+ * User action:
+ * Look for related page allocation failure messages and at the stack trace to
+ * find out which program or operation failed. Free some memory and retry the
+ * failed operation. Consider allocating more memory to your z/VM guest virtual
+ * machine.
+ */
+

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 06/15] kmsg: convert vmur to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (4 preceding siblings ...)
  2008-07-28 17:54 ` [patch 05/15] kmsg: convert cpcmd " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 07/15] kmsg: convert xpram messages " Martin Schwidefsky
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Frank Munzert, Martin Schwidefsky

[-- Attachment #1: 805-kmsg-vmur.diff --]
[-- Type: text/plain, Size: 3795 bytes --]

From: Frank Munzert <munzert@de.ibm.com>

Signed-off-by: Frank Munzert <munzert@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/vmur |   33 +++++++++++++++++++++++++++++++++
 drivers/s390/char/vmur.c     |   13 ++++++++-----
 2 files changed, 41 insertions(+), 5 deletions(-)

Index: quilt-2.6/Documentation/s390/kmsg/vmur
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/vmur
@@ -0,0 +1,33 @@
+/*?
+ * Tag: vmur.1
+ * Text: "The %s cannot be loaded without z/VM"
+ * Severity: Error
+ * Parameter:
+ *   @1: z/VM virtual unit record device driver
+ * Description:
+ * The z/VM virtual unit record device driver provides Linux with access to
+ * z/VM virtual unit record devices like punch card readers, card punches, and
+ * line printers. On Linux instances that run in environments other than the
+ * z/VM hypervisor, the device driver does not provide any useful function and
+ * the corresponding vmur module cannot be loaded.
+ * User action:
+ * Load the vmur module only on Linux instances that run as guest operating
+ * systems of the z/VM hypervisor. If the z/VM virtual unit record device
+ * has been compiled into the kernel, ignore this message.
+ */
+
+/*?
+ * Tag: vmur.2
+ * Text: "Kernel function alloc_chrdev_region failed with error code %d"
+ * Severity: Error
+ * Parameter:
+ *   @1: error code according to errno definitions
+ * Description:
+ * The z/VM virtual unit record device driver (vmur) needs to register a range
+ * of character device minor numbers from 0x0000 to 0xffff.
+ * This registration failed, probably because of memory constraints.
+ * User action:
+ * Free some memory and reload the vmur module. If the z/VM virtual unit
+ * record device driver has been compiled into the kernel reboot Linux.
+ * Consider assigning more memory to your LPAR or z/VM guest virtual machine.
+ */
Index: quilt-2.6/drivers/s390/char/vmur.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/vmur.c
+++ quilt-2.6/drivers/s390/char/vmur.c
@@ -16,6 +16,7 @@
 #include <asm/ccwdev.h>
 #include <asm/debug.h>
 #include <asm/diag.h>
+#include <asm/kmsg.h>
 
 #include "vmur.h"
 
@@ -40,7 +41,7 @@ MODULE_AUTHOR("IBM Corporation");
 MODULE_DESCRIPTION("s390 z/VM virtual unit record device driver");
 MODULE_LICENSE("GPL");
 
-#define PRINTK_HEADER "vmur: "
+#define KMSG_COMPONENT "vmur"
 
 static dev_t ur_first_dev_maj_min;
 static struct class *vmur_class;
@@ -988,7 +989,8 @@ static int __init ur_init(void)
 	dev_t dev;
 
 	if (!MACHINE_IS_VM) {
-		PRINT_ERR("%s is only available under z/VM.\n", ur_banner);
+		kmsg_err(1, "The %s cannot be loaded without z/VM\n",
+			 ur_banner);
 		return -ENODEV;
 	}
 
@@ -1007,7 +1009,8 @@ static int __init ur_init(void)
 
 	rc = alloc_chrdev_region(&dev, 0, NUM_MINORS, "vmur");
 	if (rc) {
-		PRINT_ERR("alloc_chrdev_region failed: err = %d\n", rc);
+		kmsg_err(2, "Kernel function alloc_chrdev_region failed with "
+			 "error code %d\n", rc);
 		goto fail_unregister_driver;
 	}
 	ur_first_dev_maj_min = MKDEV(MAJOR(dev), 0);
@@ -1017,7 +1020,7 @@ static int __init ur_init(void)
 		rc = PTR_ERR(vmur_class);
 		goto fail_unregister_region;
 	}
-	PRINT_INFO("%s loaded.\n", ur_banner);
+	kmsg_info(0, "%s loaded.\n", ur_banner);
 	return 0;
 
 fail_unregister_region:
@@ -1035,7 +1038,7 @@ static void __exit ur_exit(void)
 	unregister_chrdev_region(ur_first_dev_maj_min, NUM_MINORS);
 	ccw_driver_unregister(&ur_driver);
 	debug_unregister(vmur_dbf);
-	PRINT_INFO("%s unloaded.\n", ur_banner);
+	kmsg_info(0, "%s unloaded.\n", ur_banner);
 }
 
 module_init(ur_init);

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 07/15] kmsg: convert xpram messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (5 preceding siblings ...)
  2008-07-28 17:54 ` [patch 06/15] kmsg: convert vmur " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 08/15] kmsg: convert cpacf printk " Martin Schwidefsky
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Martin Schwidefsky

[-- Attachment #1: 806-kmsg-xpram.diff --]
[-- Type: text/plain, Size: 6204 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/xpram |   54 ++++++++++++++++++++++++++++++++++++++++++
 drivers/s390/block/xpram.c    |   41 ++++++++++++++-----------------
 2 files changed, 73 insertions(+), 22 deletions(-)

Index: quilt-2.6/Documentation/s390/kmsg/xpram
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/xpram
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1
+ * Text: "%d is not a valid number of XPRAM devices"
+ * 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 complied 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
+ * parameter line and restart Linux.
+ */
+
+/*?
+ * Tag: xpram.2
+ * Text: "Not enough expanded memory available"
+ * 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 complied 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 parameter 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.3
+ * Text: "No expanded memory available"
+ * 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.
+ */
+
Index: quilt-2.6/drivers/s390/block/xpram.c
===================================================================
--- quilt-2.6.orig/drivers/s390/block/xpram.c
+++ quilt-2.6/drivers/s390/block/xpram.c
@@ -37,17 +37,14 @@
 #include <linux/sysdev.h>
 #include <linux/bio.h>
 #include <asm/uaccess.h>
+#include <asm/kmsg.h>
+
+#define KMSG_COMPONENT "xpram"
 
 #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(1, "%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(0, "  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(0, "  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(0, "  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(0, "  memory needed (for sized partitions): %lu kB\n",
+		  mem_needed);
+	kmsg_info(0, "  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(2, "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(0, "  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(3, "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(0, "  %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] 27+ messages in thread

* [patch 08/15] kmsg: convert cpacf printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (6 preceding siblings ...)
  2008-07-28 17:54 ` [patch 07/15] kmsg: convert xpram messages " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 09/15] kmsg: convert time " Martin Schwidefsky
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Jan Glauber

[-- Attachment #1: 808-kmsg-cpacf.diff --]
[-- Type: text/plain, Size: 3377 bytes --]

From: Jan Glauber <jang@linux.vnet.ibm.com>

Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
---

 Documentation/s390/kmsg/aes_s390 |   32 ++++++++++++++++++++++++++++++++
 arch/s390/crypto/aes_s390.c      |   14 +++++++++-----
 2 files changed, 41 insertions(+), 5 deletions(-)

Index: quilt-2.6/arch/s390/crypto/aes_s390.c
===================================================================
--- quilt-2.6.orig/arch/s390/crypto/aes_s390.c
+++ quilt-2.6/arch/s390/crypto/aes_s390.c
@@ -22,8 +22,11 @@
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <asm/kmsg.h>
 #include "crypt_s390.h"
 
+#define KMSG_COMPONENT "aes_s390"
+
 #define AES_KEYLEN_128		1
 #define AES_KEYLEN_192		2
 #define AES_KEYLEN_256		4
@@ -169,7 +172,8 @@ static int fallback_init_cip(struct cryp
 			CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
 
 	if (IS_ERR(sctx->fallback.cip)) {
-		printk(KERN_ERR "Error allocating fallback algo %s\n", name);
+		kmsg_err(1, "Allocating AES fallback algorithm %s failed\n",
+			 name);
 		return PTR_ERR(sctx->fallback.blk);
 	}
 
@@ -349,7 +353,8 @@ static int fallback_init_blk(struct cryp
 			CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
 
 	if (IS_ERR(sctx->fallback.blk)) {
-		printk(KERN_ERR "Error allocating fallback algo %s\n", name);
+		kmsg_err(1, "Allocating AES fallback algorithm %s failed\n",
+			 name);
 		return PTR_ERR(sctx->fallback.blk);
 	}
 
@@ -515,9 +520,8 @@ static int __init aes_s390_init(void)
 
 	/* z9 109 and z9 BC/EC only support 128 bit key length */
 	if (keylen_flag == AES_KEYLEN_128)
-		printk(KERN_INFO
-		       "aes_s390: hardware acceleration only available for "
-		       "128 bit keys\n");
+		kmsg_info(2, "AES hardware acceleration is only available for"
+			  " 128-bit keys\n");
 
 	ret = crypto_register_alg(&aes_alg);
 	if (ret)
Index: quilt-2.6/Documentation/s390/kmsg/aes_s390
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/aes_s390
@@ -0,0 +1,32 @@
+/*?
+ * Tag: aes_s390.1
+ * Text: "Allocating AES fallback algorithm %s failed"
+ * Severity: Error
+ * Parameter:
+ *   @1: algorithm name
+ * Description:
+ * The advanced encryption standard (AES) algorithm includes three modes with
+ * 128-bit, 192-bit, and 256-bit keys. Your hardware system only provides
+ * hardware acceleration for the 128-bit mode. The aes_s390 module failed to
+ * allocate a software fallback for the AES modes that are not supported by the
+ * hardware. A possible reason for this problem is that the aes_generic module
+ * that provides the fallback algorithms is not available.
+ * User action:
+ * Use the 128-bit mode only or ensure that the aes_generic module is available
+ * and loaded and reload the aes_s390 module.
+ */
+
+/*?
+ * Tag: aes_s390.2
+ * Text: "AES hardware acceleration is only available for 128-bit keys"
+ * Severity: Informational
+ * Description:
+ * The advanced encryption standard (AES) algorithm includes three modes with
+ * 128-bit, 192-bit, and 256-bit keys. Your hardware system only provides
+ * hardware acceleration for the 128-bit key mode. The aes_s390 module
+ * will use the less performant software fallback algorithm for the 192-bit
+ * and 256-bit key modes.
+ * User action:
+ * None.
+ */
+

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 09/15] kmsg: convert time printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (7 preceding siblings ...)
  2008-07-28 17:54 ` [patch 08/15] kmsg: convert cpacf printk " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 10/15] kmsg: convert hypfs " Martin Schwidefsky
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Martin Schwidefsky

[-- Attachment #1: 809-kmsg-time.diff --]
[-- Type: text/plain, Size: 3539 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/time |   39 +++++++++++++++++++++++++++++++++++++++
 arch/s390/kernel/time.c      |   14 +++++++++-----
 2 files changed, 48 insertions(+), 5 deletions(-)

Index: quilt-2.6/arch/s390/kernel/time.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/time.c
+++ quilt-2.6/arch/s390/kernel/time.c
@@ -41,6 +41,9 @@
 #include <asm/timer.h>
 #include <asm/etr.h>
 #include <asm/cio.h>
+#include <asm/kmsg.h>
+
+#define KMSG_COMPONENT "time"
 
 /* change this if you have some constant time drift */
 #define USECS_PER_JIFFY     ((unsigned long) 1000000/HZ)
@@ -289,8 +292,8 @@ static unsigned long long adjust_time(un
 	}
 	jiffies_timer_cc += delta;
 	if (adjust.offset != 0) {
-		printk(KERN_NOTICE "etr: time adjusted by %li micro-seconds\n",
-		       adjust.offset);
+		kmsg_notice(1, "The ETR interface has adjusted the clock "
+			    "by %li microseconds\n", adjust.offset);
 		adjust.modes = ADJ_OFFSET_SINGLESHOT;
 		do_adjtimex(&adjust);
 	}
@@ -441,8 +444,8 @@ static void etr_reset(void)
 		etr_tolec = get_clock();
 		set_bit(CLOCK_SYNC_HAS_ETR, &clock_sync_flags);
 	} else if (etr_port0_online || etr_port1_online) {
-		printk(KERN_WARNING "Running on non ETR capable "
-		       "machine, only local mode available.\n");
+		kmsg_warn(2, "The real or virtual hardware system does "
+			  "not provide an ETR interface\n");
 		etr_port0_online = etr_port1_online = 0;
 	}
 }
@@ -1357,7 +1360,8 @@ static void stp_reset(void)
 	if (rc == 1)
 		set_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags);
 	else if (stp_online) {
-		printk(KERN_WARNING "Running on non STP capable machine.\n");
+		kmsg_warn(3, "The real or virtual hardware system does "
+			  "not provide an STP interface\n");
 		free_bootmem((unsigned long) stp_page, PAGE_SIZE);
 		stp_page = NULL;
 		stp_online = 0;
Index: quilt-2.6/Documentation/s390/kmsg/time
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/time
@@ -0,0 +1,39 @@
+/*?
+ * Tag: time.1
+ * Text: "The ETR interface has adjusted the clock by %li microseconds"
+ * Severity: Notice
+ * Parameter:
+ *   @1: number of microseconds
+ * Description:
+ * The external time reference (ETR) interface has synchronized the system
+ * clock  with the external reference and set it to a new value. The time
+ * difference between the old and new clock value has been passed to the
+ * network time protocol (NTP) as a single shot adjustment.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: time.2
+ * Text: "The real or virtual hardware system does not provide an ETR interface"
+ * Severity: Warning
+ * Description:
+ * The 'etr=' parameter has been passed on the kernel parameter line for
+ * a Linux instance that does not have access to the external time reference
+ * (ETR) facility.
+ * User action:
+ * To avoid this warning remove the 'etr=' kernel parameter.
+ */
+
+/*?
+ * Tag: time.3
+ * Text: "The real or virtual hardware system does not provide an STP interface"
+ * Severity: Warning
+ * Description:
+ * The 'stp=' parameter has been passed on the kernel parameter line for
+ * a Linux instance that does not have access to the server time protocol
+ * (STP) facility.
+ * User action:
+ * To avoid this warning remove the 'stp=' kernel parameter.
+ */
+

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 10/15] kmsg: convert hypfs printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (8 preceding siblings ...)
  2008-07-28 17:54 ` [patch 09/15] kmsg: convert time " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 11/15] kmsg: convert setup " Martin Schwidefsky
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Michael Holzheu, Martin Schwidefsky

[-- Attachment #1: 810-kmsg-hypfs.diff --]
[-- Type: text/plain, Size: 5402 bytes --]

From: Michael Holzheu <holzheu@de.ibm.com>

Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/hypfs |   60 ++++++++++++++++++++++++++++++++++++++++++
 arch/s390/hypfs/hypfs_diag.c  |    9 ++++--
 arch/s390/hypfs/inode.c       |   13 ++++-----
 3 files changed, 73 insertions(+), 9 deletions(-)

Index: quilt-2.6/arch/s390/hypfs/hypfs_diag.c
===================================================================
--- quilt-2.6.orig/arch/s390/hypfs/hypfs_diag.c
+++ quilt-2.6/arch/s390/hypfs/hypfs_diag.c
@@ -3,7 +3,7 @@
  *    Hypervisor filesystem for Linux on s390. Diag 204 and 224
  *    implementation.
  *
- *    Copyright (C) IBM Corp. 2006
+ *    Copyright IBM Corp. 2006, 2008
  *    Author(s): Michael Holzheu <holzheu@de.ibm.com>
  */
 
@@ -12,8 +12,10 @@
 #include <linux/string.h>
 #include <linux/vmalloc.h>
 #include <asm/ebcdic.h>
+#include <asm/kmsg.h>
 #include "hypfs.h"
 
+#define KMSG_COMPONENT "hypfs"
 #define LPAR_NAME_LEN 8		/* lpar name len in diag 204 data */
 #define CPU_NAME_LEN 16		/* type name len of cpus in diag224 name table */
 #define TMP_SIZE 64		/* size of temporary buffers */
@@ -527,13 +529,14 @@ __init int hypfs_diag_init(void)
 	int rc;
 
 	if (diag204_probe()) {
-		printk(KERN_ERR "hypfs: diag 204 not working.");
+		kmsg_err(1, "The hardware system does not support hypfs");
 		return -ENODATA;
 	}
 	rc = diag224_get_name_table();
 	if (rc) {
 		diag204_free_buffer();
-		printk(KERN_ERR "hypfs: could not get name table.\n");
+		kmsg_err(2, "The hardware system does not provide all "
+			 "functions required by hypfs\n");
 	}
 	return rc;
 }
Index: quilt-2.6/arch/s390/hypfs/inode.c
===================================================================
--- quilt-2.6.orig/arch/s390/hypfs/inode.c
+++ quilt-2.6/arch/s390/hypfs/inode.c
@@ -2,7 +2,7 @@
  *  arch/s390/hypfs/inode.c
  *    Hypervisor filesystem for Linux on s390.
  *
- *    Copyright (C) IBM Corp. 2006
+ *    Copyright IBM Corp. 2006, 2008
  *    Author(s): Michael Holzheu <holzheu@de.ibm.com>
  */
 
@@ -20,8 +20,10 @@
 #include <linux/seq_file.h>
 #include <linux/mount.h>
 #include <asm/ebcdic.h>
+#include <asm/kmsg.h>
 #include "hypfs.h"
 
+#define KMSG_COMPONENT "hypfs"
 #define HYPFS_MAGIC 0x687970	/* ASCII 'hyp' */
 #define TMP_SIZE 64		/* size of temporary buffers */
 
@@ -200,7 +202,7 @@ static ssize_t hypfs_aio_write(struct ki
 	else
 		rc = hypfs_diag_create_files(sb, sb->s_root);
 	if (rc) {
-		printk(KERN_ERR "hypfs: Update failed\n");
+		kmsg_err(3, "Updating the hypfs tree failed\n");
 		hypfs_delete_tree(sb->s_root);
 		goto out;
 	}
@@ -252,8 +254,7 @@ static int hypfs_parse_options(char *opt
 			break;
 		case opt_err:
 		default:
-			printk(KERN_ERR "hypfs: Unrecognized mount option "
-			       "\"%s\" or missing value\n", str);
+			kmsg_err(4, "%s is not a valid mount option", str);
 			return -EINVAL;
 		}
 	}
@@ -317,7 +318,7 @@ static int hypfs_fill_super(struct super
 	}
 	hypfs_update_update(sb);
 	sb->s_root = root_dentry;
-	printk(KERN_INFO "hypfs: Hypervisor filesystem mounted\n");
+	kmsg_info(0, "Hypervisor filesystem mounted\n");
 	return 0;
 
 err_tree:
@@ -513,7 +514,7 @@ fail_sysfs:
 	if (!MACHINE_IS_VM)
 		hypfs_diag_exit();
 fail_diag:
-	printk(KERN_ERR "hypfs: Initialization failed with rc = %i.\n", rc);
+	kmsg_err(5, "Initialization of hypfs failed with rc=%i\n", rc);
 	return rc;
 }
 
Index: quilt-2.6/Documentation/s390/kmsg/hypfs
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/hypfs
@@ -0,0 +1,60 @@
+/*?
+ * Tag: hypfs.1
+ * Text: "The hardware system does not support hypfs"
+ * Severity: Error
+ * Description:
+ * hypfs requires DIAGNOSE Code X'204' but this diagnose code is not available
+ * on your hardware. You need more recent hardware to use hypfs.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: hypfs.2
+ * Text: "The hardware system does not provide all functions required by hypfs"
+ * Severity: Error
+ * Description:
+ * hypfs requires DIAGNOSE Code X'224' but this diagnode code is not available
+ * on your hardware. You need more recent hardware to use hypfs.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: hypfs.3
+ * Text: "Updating the hypfs tree failed"
+ * Severity: Error
+ * Description:
+ * There was not enough memory available to update the hypfs tree.
+ * User action:
+ * Free some memory and try again to update the hypfs tree. Consider assigning
+ * more memory to your LPAR or z/VM guest virtual machine.
+ */
+
+/*?
+ * Tag: hypfs.4
+ * Text: "%s is not a valid mount option"
+ * Severity: Error
+ * Parameter:
+ *   @1: mount option
+ * Description:
+ * hypfs has detected mount options that are not valid.
+ * User action:
+ * See "Device Drivers Features and Commands" for information about valid
+ * mount options for hypfs.
+ */
+
+/*?
+ * Tag: hypfs.5
+ * Text: "Initialization of hypfs failed with rc=%i"
+ * Severity: Error
+ * Parameter:
+ *   @1: error code
+ * Description:
+ * Initialization of hypfs failed because of resource or hardware constraints.
+ * Possible reasons for this problem are insufficient free memory or missing
+ * hardware interfaces.
+ * User action:
+ * See errno.h for information about the error codes.
+ */
+

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 11/15] kmsg: convert setup printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (9 preceding siblings ...)
  2008-07-28 17:54 ` [patch 10/15] kmsg: convert hypfs " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 12/15] kmsg: convert appldata " Martin Schwidefsky
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Martin Schwidefsky

[-- Attachment #1: 811-kmsg-setup.diff --]
[-- Type: text/plain, Size: 11066 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/setup |  164 ++++++++++++++++++++++++++++++++++++++++++
 arch/s390/kernel/setup.c      |   78 ++++++++++++-------
 2 files changed, 213 insertions(+), 29 deletions(-)

Index: quilt-2.6/arch/s390/kernel/setup.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/setup.c
+++ quilt-2.6/arch/s390/kernel/setup.c
@@ -55,6 +55,9 @@
 #include <asm/ebcdic.h>
 #include <asm/compat.h>
 #include <asm/kvm_virtio.h>
+#include <asm/kmsg.h>
+
+#define KMSG_COMPONENT "setup"
 
 long psw_kernel_bits	= (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY |
 			   PSW_MASK_MCHECK | PSW_DEFAULT_KEY);
@@ -291,8 +294,8 @@ unsigned int switch_amode = 0;
 #endif
 EXPORT_SYMBOL_GPL(switch_amode);
 
-static void set_amode_and_uaccess(unsigned long user_amode,
-				  unsigned long user32_amode)
+static int set_amode_and_uaccess(unsigned long user_amode,
+				 unsigned long user32_amode)
 {
 	psw_user_bits = PSW_BASE_BITS | PSW_MASK_DAT | user_amode |
 			PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK |
@@ -309,11 +312,11 @@ static void set_amode_and_uaccess(unsign
 			  PSW_MASK_MCHECK | PSW_DEFAULT_KEY;
 
 	if (MACHINE_HAS_MVCOS) {
-		printk("mvcos available.\n");
 		memcpy(&uaccess, &uaccess_mvcos_switch, sizeof(uaccess));
+		return 1;
 	} else {
-		printk("mvcos not available.\n");
 		memcpy(&uaccess, &uaccess_pt, sizeof(uaccess));
+		return 0;
 	}
 }
 
@@ -328,9 +331,10 @@ static int __init early_parse_switch_amo
 early_param("switch_amode", early_parse_switch_amode);
 
 #else /* CONFIG_S390_SWITCH_AMODE */
-static inline void set_amode_and_uaccess(unsigned long user_amode,
-					 unsigned long user32_amode)
+static inline int set_amode_and_uaccess(unsigned long user_amode,
+					unsigned long user32_amode)
 {
+	return 0;
 }
 #endif /* CONFIG_S390_SWITCH_AMODE */
 
@@ -355,11 +359,20 @@ early_param("noexec", early_parse_noexec
 static void setup_addressing_mode(void)
 {
 	if (s390_noexec) {
-		printk("S390 execute protection active, ");
-		set_amode_and_uaccess(PSW_ASC_SECONDARY, PSW32_ASC_SECONDARY);
+		if (set_amode_and_uaccess(PSW_ASC_SECONDARY,
+					  PSW32_ASC_SECONDARY))
+			kmsg_info(1, "Execute protection active, "
+				  "mvcos available\n");
+		else
+			kmsg_info(2, "Execute protection active, "
+				  "mvcos not available\n");
 	} else if (switch_amode) {
-		printk("S390 address spaces switched, ");
-		set_amode_and_uaccess(PSW_ASC_PRIMARY, PSW32_ASC_PRIMARY);
+		if (set_amode_and_uaccess(PSW_ASC_PRIMARY, PSW32_ASC_PRIMARY))
+			kmsg_info(3, "Address spaces switched, "
+				  "mvcos available\n");
+		else
+			kmsg_info(4, "Address spaces switched, "
+				  "mvcos not available\n");
 	}
 #ifdef CONFIG_TRACE_IRQFLAGS
 	sysc_restore_trace_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
@@ -572,15 +585,15 @@ setup_memory(void)
 			start = PFN_PHYS(start_pfn) + bmap_size + PAGE_SIZE;
 
 			if (start + INITRD_SIZE > memory_end) {
-				printk("initrd extends beyond end of memory "
-				       "(0x%08lx > 0x%08lx)\n"
-				       "disabling initrd\n",
-				       start + INITRD_SIZE, memory_end);
+				kmsg_err(5, "initrd extends beyond end of "
+					 "memory (0x%08lx > 0x%08lx) "
+					 "disabling initrd\n",
+					 start + INITRD_SIZE, memory_end);
 				INITRD_START = INITRD_SIZE = 0;
 			} else {
-				printk("Moving initrd (0x%08lx -> 0x%08lx, "
-				       "size: %ld)\n",
-				       INITRD_START, start, INITRD_SIZE);
+				kmsg_info(6, "Moving initrd (0x%08lx -> "
+					  "0x%08lx, size: %ld)\n",
+					  INITRD_START, start, INITRD_SIZE);
 				memmove((void *) start, (void *) INITRD_START,
 					INITRD_SIZE);
 				INITRD_START = start;
@@ -642,9 +655,10 @@ setup_memory(void)
 			initrd_start = INITRD_START;
 			initrd_end = initrd_start + INITRD_SIZE;
 		} else {
-			printk("initrd extends beyond end of memory "
-			       "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-			       initrd_start + INITRD_SIZE, memory_end);
+			kmsg_err(5, "initrd extends beyond end of "
+				 "memory (0x%08lx > 0x%08lx)\n"
+				 "disabling initrd\n",
+				 initrd_start + INITRD_SIZE, memory_end);
 			initrd_start = initrd_end = 0;
 		}
 	}
@@ -756,21 +770,27 @@ setup_arch(char **cmdline_p)
          * print what head.S has found out about the machine
          */
 #ifndef CONFIG_64BIT
-	printk((MACHINE_IS_VM) ?
-	       "We are running under VM (31 bit mode)\n" :
-	       "We are running native (31 bit mode)\n");
-	printk((MACHINE_HAS_IEEE) ?
-	       "This machine has an IEEE fpu\n" :
-	       "This machine has no IEEE fpu\n");
+	if (MACHINE_IS_VM)
+		kmsg_info(7, "Linux is running as a z/VM "
+			  "guest operating system in 31-bit mode\n");
+	else
+		kmsg_info(8, "Linux is running natively in 31-bit mode\n");
+	if (MACHINE_HAS_IEEE)
+		kmsg_info(9, "The hardware system has IEEE compatible "
+			  "floating point units\n");
+	else
+		kmsg_info(10, "The hardware system has no IEEE compatible "
+			  "floating point units\n");
 #else /* CONFIG_64BIT */
 	if (MACHINE_IS_VM)
-		printk("We are running under VM (64 bit mode)\n");
+		kmsg_info(11, "Linux is running as a z/VM "
+			  "guest operating system in 64-bit mode\n");
 	else if (MACHINE_IS_KVM) {
-		printk("We are running under KVM (64 bit mode)\n");
+		kmsg_info(13, "Linux is running under KVM in 64-bit mode\n");
 		add_preferred_console("hvc", 0, NULL);
 		s390_virtio_console_init();
 	} else
-		printk("We are running native (64 bit mode)\n");
+		kmsg_info(12, "Linux is running natively in 64-bit mode\n");
 #endif /* CONFIG_64BIT */
 
 	/* Have one command line that is parsed and saved in /proc/cmdline */
Index: quilt-2.6/Documentation/s390/kmsg/setup
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/setup
@@ -0,0 +1,164 @@
+/*?
+ * Tag: setup.1
+ * Text: "Execute protection active, mvcos available"
+ * Severity: Informational
+ * Description:
+ * The kernel parameter 'noexec' has been specified. The kernel will
+ * honor the execute bit of mappings and will use the mvcos instruction
+ * to copy between the user and kernel address space.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.2
+ * Text: "Execute protection active, mvcos not available"
+ * Severity: Informational
+ * Description:
+ * The kernel parameter 'noexec' has been specified. The kernel will
+ * honor the execute bit of mappings. The mvcos instruction is not
+ * available and the kernel will use the slower page table walk method
+ * to copy between the user and kernel address space.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.3
+ * Text: "Address spaces switched, mvcos available"
+ * Severity: Informational
+ * Description:
+ * The kernel parameter 'switch_amode' has been specified. The kernel
+ * will use the primary address space for user space processes and the
+ * home address space for the kernel. The mvcos instruction is used to
+ * copy between the user and kernel address space.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.4
+ * Text: "Address spaces switched, mvcos not available"
+ * Severity: Informational
+ * Description:
+ * The kernel parameter 'switch_amode' has been specified. The kernel
+ * will use the primary address space for user space processes and the
+ * home address space for the kernel. The mvcos instruction is not
+ * available and the kernel will use the slower page table walk method
+ * to copy between the user and kernel address space.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.5
+ * Text: "initrd extends beyond end of memory (0x%08lx > 0x%08lx) disabling initrd"
+ * Severity: Error
+ * Parameter:
+ *   @1: start address of the initial RAM disk
+ *   @2: memory end address
+ * Description:
+ * The load address and the size of the initial RAM disk result in an end
+ * address of the initial RAM disk that is beyond the end of the system
+ * memory.
+ * User action:
+ * Lower the load address of the initial RAM disk, reduce the size of the
+ * initial RAM disk, or increase the size if the system memory to make the
+ * initial RAM disk fit into the memory.
+ */
+
+/*?
+ * Tag: setup.6
+ * Text: "Moving initrd (0x%08lx -> 0x%08lx, size: %ld)"
+ * Severity: Informational
+ * Parameter:
+ *   @1: old start address of the initial RAM disk
+ *   @2: new start address of the initial RAM disk
+ *   @3: size of the initial RAM disk
+ * Description:
+ * The location of the initial RAM disk conflicted with the boot memory bitmap.
+ * To resolve the conflict the initial RAM disk has been moved to a new
+ * location.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.7
+ * Text: "Linux is running as a z/VM guest operating system in 31-bit mode"
+ * Severity: Informational
+ * Description:
+ * The 31-bit Linux kernel detected that it is running as a guest operating
+ * system of the z/VM hypervisor.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.8
+ * Text: "Linux is running natively in 31-bit mode"
+ * Severity: Informational
+ * Description:
+ * The 31-bit Linux kernel detected that it is running on an IBM mainframe,
+ * either as the sole operating system in an LPAR or as the sole operating
+ * system on the entire mainframe. The Linux kernel is not running as a
+ * guest operating system of the z/VM hypervisor.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.9
+ * Text: "The hardware system has IEEE compatible floating point units"
+ * Severity: Informational
+ * Description:
+ * The Linux kernel detected that it is running on a hardware system with
+ * CPUs that have IEEE compatible floating point units.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.10
+ * Text: "The hardware system has no IEEE compatible floating point units"
+ * Severity: Informational
+ * Description:
+ * The Linux kernel detected that it is running on a hardware system with
+ * CPUs that do not have IEEE compatible floating point units.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.11
+ * Text: "Linux is running as a z/VM guest operating system in 64-bit mode"
+ * Severity: Informational
+ * Description:
+ * The 64-bit Linux kernel detected that it is running as a guest operating
+ * system of the z/VM hypervisor.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.12
+ * Text: "Linux is running natively in 64-bit mode"
+ * Severity: Informational
+ * Description:
+ * The 64-bit Linux kernel detected that it is running on an IBM mainframe,
+ * either as the sole operating system in an LPAR or as the sole operating
+ * system on the entire mainframe. The Linux kernel is not running as a
+ * guest operating system of the z/VM hypervisor.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: setup.13
+ * Text: "Linux is running under KVM in 64-bit mode"
+ * Severity: Informational
+ * Description:
+ * The 64-bit kernel detected that it is running under the KVM hypervisor.
+ * User action:
+ * None.
+ */

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 12/15] kmsg: convert appldata printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (10 preceding siblings ...)
  2008-07-28 17:54 ` [patch 11/15] kmsg: convert setup " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 13/15] kmsg: convert monreader " Martin Schwidefsky
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Gerald Schaefer, Martin Schwidefsky

[-- Attachment #1: 812-kmsg-appldata.diff --]
[-- Type: text/plain, Size: 8308 bytes --]

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/appldata   |   93 +++++++++++++++++++++++++++++++++++++
 arch/s390/appldata/appldata.h      |    4 -
 arch/s390/appldata/appldata_base.c |   11 ++--
 arch/s390/appldata/appldata_os.c   |   20 +++----
 4 files changed, 107 insertions(+), 21 deletions(-)

Index: quilt-2.6/arch/s390/appldata/appldata_base.c
===================================================================
--- quilt-2.6.orig/arch/s390/appldata/appldata_base.c
+++ quilt-2.6/arch/s390/appldata/appldata_base.c
@@ -28,11 +28,12 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/smp.h>
+#include <asm/kmsg.h>
 
 #include "appldata.h"
 
 
-#define MY_PRINT_NAME	"appldata"		/* for debug messages, etc. */
+#define KMSG_COMPONENT	"appldata"
 #define APPLDATA_CPU_INTERVAL	10000		/* default (CPU) time for
 						   sampling interval in
 						   milliseconds */
@@ -390,8 +391,8 @@ appldata_generic_handler(ctl_table *ctl,
 					(unsigned long) ops->data, ops->size,
 					ops->mod_lvl);
 		if (rc != 0) {
-			P_ERROR("START DIAG 0xDC for %s failed, "
-				"return code: %d\n", ops->name, rc);
+			kmsg_err(1, "Starting the data collection for %s "
+				 "failed with rc=%d\n", ops->name, rc);
 			module_put(ops->owner);
 		} else
 			ops->active = 1;
@@ -401,8 +402,8 @@ appldata_generic_handler(ctl_table *ctl,
 				(unsigned long) ops->data, ops->size,
 				ops->mod_lvl);
 		if (rc != 0)
-			P_ERROR("STOP DIAG 0xDC for %s failed, "
-				"return code: %d\n", ops->name, rc);
+			kmsg_err(2, "Stopping the data collection for %s "
+				 "failed with rc=%d\n", ops->name, rc);
 		module_put(ops->owner);
 	}
 	spin_unlock(&appldata_ops_lock);
Index: quilt-2.6/arch/s390/appldata/appldata.h
===================================================================
--- quilt-2.6.orig/arch/s390/appldata/appldata.h
+++ quilt-2.6/arch/s390/appldata/appldata.h
@@ -26,10 +26,6 @@
 #define CTL_APPLDATA_NET_SUM	2125
 #define CTL_APPLDATA_PROC	2126
 
-#define P_INFO(x...)	printk(KERN_INFO MY_PRINT_NAME " info: " x)
-#define P_ERROR(x...)	printk(KERN_ERR MY_PRINT_NAME " error: " x)
-#define P_WARNING(x...)	printk(KERN_WARNING MY_PRINT_NAME " status: " x)
-
 struct appldata_ops {
 	struct list_head list;
 	struct ctl_table_header *sysctl_header;
Index: quilt-2.6/arch/s390/appldata/appldata_os.c
===================================================================
--- quilt-2.6.orig/arch/s390/appldata/appldata_os.c
+++ quilt-2.6/arch/s390/appldata/appldata_os.c
@@ -18,11 +18,12 @@
 #include <linux/sched.h>
 #include <asm/appldata.h>
 #include <asm/smp.h>
+#include <asm/kmsg.h>
 
 #include "appldata.h"
 
 
-#define MY_PRINT_NAME	"appldata_os"		/* for debug messages, etc. */
+#define KMSG_COMPONENT	"appldata"
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
 
@@ -143,21 +144,16 @@ static void appldata_get_os_data(void *d
 					   (unsigned long) ops.data, new_size,
 					   ops.mod_lvl);
 			if (rc != 0)
-				P_ERROR("os: START NEW DIAG 0xDC failed, "
-					"return code: %d, new size = %i\n", rc,
-					new_size);
+				kmsg_err(3, "Starting a new OS data collection "
+					 "failed with rc=%d\n", rc);
 
 			rc = appldata_diag(APPLDATA_RECORD_OS_ID,
 					   APPLDATA_STOP_REC,
 					   (unsigned long) ops.data, ops.size,
 					   ops.mod_lvl);
 			if (rc != 0)
-				P_ERROR("os: STOP OLD DIAG 0xDC failed, "
-					"return code: %d, old size = %i\n", rc,
-					ops.size);
-			else
-				P_INFO("os: old record size = %i stopped\n",
-					ops.size);
+				kmsg_err(4, "Stopping a faulty OS data "
+					 "collection failed with rc=%d\n", rc);
 		}
 		ops.size = new_size;
 	}
@@ -178,8 +174,8 @@ static int __init appldata_os_init(void)
 	max_size = sizeof(struct appldata_os_data) +
 		   (NR_CPUS * sizeof(struct appldata_os_per_cpu));
 	if (max_size > APPLDATA_MAX_REC_SIZE) {
-		P_ERROR("Max. size of OS record = %i, bigger than maximum "
-			"record size (%i)\n", max_size, APPLDATA_MAX_REC_SIZE);
+		kmsg_err(5, "Maximum OS record size %i exceeds the maximum "
+			 "record size %i\n", max_size, APPLDATA_MAX_REC_SIZE);
 		rc = -ENOMEM;
 		goto out;
 	}
Index: quilt-2.6/Documentation/s390/kmsg/appldata
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/appldata
@@ -0,0 +1,93 @@
+/*?
+ * Tag: appldata.1
+ * Text: "Starting the data collection for %s failed with rc=%d"
+ * Severity: Error
+ * Parameter:
+ *   @1: appldata module
+ *   @2: return code
+ * Description:
+ * The specified data collection module used the z/VM diagnose call
+ * DIAG 0xDC to start writing data. z/VM returned an error and the data
+ * collection could not start. If the return code is 5, your z/VM guest
+ * virtual machine is not authorized to write data records.
+ * User action:
+ * If the return code is 5, ensure that your z/VM guest virtual machine's
+ * entry in the z/VM directory includes the OPTION APPLMON statement.
+ * For other return codes see the section about DIAGNOSE Code X'DC'
+ * in "z/VM CP Programming Services".
+ */
+
+/*?
+ * Tag: appldata.2
+ * Text: "Stopping the data collection for %s failed with rc=%d"
+ * Severity: Error
+ * Parameter:
+ *   @1: appldata module
+ *   @2: return code
+ * Description:
+ * The specified data collection module used the z/VM diagnose call DIAG 0xDC
+ * to stop writing data. z/VM returned an error and the data collection
+ * continues.
+ * User action:
+ * See the section about DIAGNOSE Code X'DC' in "z/VM CP Programming Services".
+ */
+
+/*?
+ * Tag: appldata.3
+ * Text: "Starting a new OS data collection failed with rc=%d"
+ * Severity: Error
+ * Parameter:
+ *   @1: return code
+ * Description:
+ * After a CPU hotplug event, the record size for the running operating
+ * system data collection is no longer correct. The appldata_os module tried
+ * to start a new data collection with the correct record size but received
+ * an error from the z/VM diagnose call DIAG 0xDC. Any data collected with
+ * the current record size might be faulty.
+ * User action:
+ * Start a new data collection with the cappldata_os module. For information
+ * about starting data collections see "Device Drivers, Features, and
+ * Commands". For information about the return codes see the section about
+ * DIAGNOSE Code X'DC' in "z/VM CP Programming Services".
+ */
+
+/*?
+ * Tag: appldata.4
+ * Text: "Stopping a faulty OS data collection failed with rc=%d"
+ * Severity: Error
+ * Parameter:
+ *   @1: return code
+ * Description:
+ * After a CPU hotplug event, the record size for the running operating
+ * system data collection is no longer correct. The appldata_os module tried
+ * to stop the faulty data collection but received an error from the z/VM
+ * diagnose call DIAG 0xDC. Any data collected with the current record size
+ * might be faulty.
+ * User action:
+ * Try to restart appldata_os monitoring. For information about stopping
+ * and starting data collections see "Device Drivers, Features, and
+ * Commands". For information about the return codes see the section about
+ * DIAGNOSE Code X'DC' in "z/VM CP Programming Services".
+ */
+
+/*?
+ * Tag: appldata.5
+ * Text: "Maximum OS record size %i exceeds the maximum record size %i"
+ * Severity: Error
+ * Parameter:
+ *   @1: no of bytes
+ *   @2: no of bytes
+ * Description:
+ * The OS record size grows with the number of CPUs and is adjusted by the
+ * appldata_os module in response to CPU hotplug events. For more than 110
+ * CPUs the record size would exceed the maximum record size of 4024 bytes
+ * that is  supported by the z/VM hypervisor. To prevent the maximum supported
+ * record size from being exceeded while data collection is in progress,
+ * you cannot load the appldata_os module on Linux instances that are
+ * configured for a maximum of more than 110 CPUs.
+ * User action:
+ * If you do not want to collect operating system data, you can ignore this
+ * message. If you want to collect operating system data, reconfigure your
+ * Linux instance to support less than 110 CPUs.
+ */
+

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 13/15] kmsg: convert monreader printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (11 preceding siblings ...)
  2008-07-28 17:54 ` [patch 12/15] kmsg: convert appldata " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 14/15] kmsg: convert s390 debug feature " Martin Schwidefsky
  2008-07-28 17:54 ` [patch 15/15] kmsg: convert monwriter printk messages " Martin Schwidefsky
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Gerald Schaefer, Martin Schwidefsky

[-- Attachment #1: 813-kmsg-monreader.diff --]
[-- Type: text/plain, Size: 10216 bytes --]

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/monreader |  135 ++++++++++++++++++++++++++++++++++++++
 drivers/s390/char/monreader.c     |   39 ++++------
 2 files changed, 151 insertions(+), 23 deletions(-)

Index: quilt-2.6/Documentation/s390/kmsg/monreader
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/monreader
@@ -0,0 +1,135 @@
+/*?
+ * Tag: monreader.1
+ * Text: "Reading monitor data failed with rc=%i"
+ * Severity: Error
+ * Parameter:
+ *   @1: return code
+ * Description:
+ * The z/VM *MONITOR record device driver failed to read monitor data
+ * because the IUCV REPLY function failed. The read function against
+ * the monitor record device returns EIO. All monitor data that has been read
+ * since the last read with 0 size is incorrect.
+ * User action:
+ * Disregard all monitor data that has been read since the last read with
+ * 0 size. If the device driver has been compiled as a separate module, unload
+ * and reload the monreader module. If the device driver has been compiled
+ * into the kernel, reboot Linux. For more information about possible causes
+ * of the error see the IUCV section in "z/VM CP Programming Services" and
+ * the *MONITOR section in "z/VM Performance".
+ */
+
+/*?
+ * Tag: monreader.2
+ * Text: "z/VM *MONITOR system service disconnected with rc=%i"
+ * Severity: Error
+ * Parameter:
+ *   @1: IPUSER SEVER return code
+ * Description:
+ * The z/VM *MONITOR record device driver receives monitor records through
+ * an IUCV connection to the z/VM *MONITOR system service. This connection
+ * has been severed and the read function of the z/VM *MONITOR device driver
+ * returns EIO. All data received since the last read with 0 size is incorrect.
+ * User action:
+ * Disregard all monitor data read since the last read with 0 size. Close and
+ * reopen the monitor record device. For information about the IPUSER SEVER
+ * return codes see "z/VM Performance".
+ */
+
+/*?
+ * Tag: monreader.3
+ * Text: "The read queue for monitor data is full"
+ * Severity: Warning
+ * Description:
+ * The read function of the z/VM *MONITOR device driver returns EOVERFLOW
+ * because not enough monitor data has been read since the monitor device
+ * has been opened. Monitor data already read are valid and subsequent reads
+ * return valid data but some intermediate data might be missing.
+ * User action:
+ * Be aware that monitor data might be missing. Assure that you regularly
+ * read monitor data after opening the monitor record device.
+ */
+
+/*?
+ * Tag: monreader.4
+ * Text: "Connecting to the z/VM *MONITOR system service failed with rc=%i"
+ * Severity: Error
+ * Parameter:
+ *   @1: IUCV CONNECT return code
+ * Description:
+ * The z/VM *MONITOR record device driver receives monitor records through
+ * an IUCV connection to the z/VM *MONITOR system service. This connection
+ * could not be established when the monitor record device was opened. If
+ * the return code is 15, your z/VM guest virtual machine is not authorized
+ * to connect to the *MONITOR system service.
+ * User action:
+ * If the return code is 15, ensure that the IUCV *MONITOR statement is
+ * included in the z/VM directory entry for your z/VM guest virtual machine.
+ * For other IUCV CONNECT return codes see the IUCV section in "CP Programming
+ * Services" and the *MONITOR section in "z/VM  Performance".
+ */
+
+/*?
+ * Tag: monreader.5
+ * Text: "Disconnecting the z/VM *MONITOR system service failed with rc=%i"
+ * Severity: Warning
+ * Parameter:
+ *   @1: IUCV SEVER return code
+ * Description:
+ * The z/VM *MONITOR record device driver receives monitor data through an
+ * IUCV connection to the z/VM *MONITOR system service. This connection
+ * could not be closed when the monitor record device was closed. You might
+ * not be able to resume monitoring.
+ * User action:
+ * No immediate action is necessary. If you cannot open the monitor record
+ * device in the future, reboot Linux. For information about the IUCV SEVER
+ * return codes see the IUCV section in "CP Programming Services" and the
+ * *MONITOR section in "z/VM  Performance".
+ */
+
+/*?
+ * Tag: monreader.6
+ * Text: "The z/VM *MONITOR record device driver cannot be loaded without z/VM"
+ * Severity: Error
+ * Description:
+ * The z/VM *MONITOR record device driver uses z/VM system services to provide
+ * monitor data about z/VM guest operating systems to applications on Linux.
+ * On Linux instances that run in environments other than the z/VM hypervisor,
+ * the z/VM *MONITOR record device driver does not provide any useful
+ * function and the corresponding monreader module cannot be loaded.
+ * User action:
+ * Load the z/VM *MONITOR record device driver only on Linux instances that run
+ * as guest operating systems of the z/VM hypervisor. If the z/VM *MONITOR
+ * record device driver has been compiled into the kernel, ignore this message.
+ */
+
+/*?
+ * Tag: monreader.7
+ * Text: "The z/VM *MONITOR record device driver failed to register with IUCV"
+ * Severity: Error
+ * Description:
+ * The z/VM *MONITOR record device driver receives monitor data through an IUCV
+ * connection and needs to register with the IUCV device driver. This
+ * registration failed and the z/VM *MONITOR record device driver was not
+ * loaded. A possible cause of this problem is insufficient memory.
+ * User action:
+ * Free some memory and try again to load the module. If the z/VM *MONITOR
+ * record device driver has been compiled into the kernel, you might have to
+ * configure more memory and reboot Linux. If you do not want to read monitor
+ * data, ignore this message.
+ */
+
+/*?
+ * Tag: monreader.8
+ * Text: "The specified *MONITOR DCSS %s does not have the required type SC"
+ * Severity: Error
+ * Parameter:
+ *   @1: DCSS name
+ * Description:
+ * The DCSS that was specified with the monreader.mondcss kernel parameter or
+ * with the mondcss module parameter cannot be a *MONITOR DCSS because it is
+ * not of type SC.
+ * User action:
+ * Confirm that you are using the name of the DCSS that has been configured as
+ * the *MONITOR DCSS on the z/VM hypervisor. If the default name, MONDCSS, is
+ * used, omit the monreader.mondcss or mondcss parameter.
+ */
Index: quilt-2.6/drivers/s390/char/monreader.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/monreader.c
+++ quilt-2.6/drivers/s390/char/monreader.c
@@ -23,20 +23,10 @@
 #include <asm/uaccess.h>
 #include <asm/ebcdic.h>
 #include <asm/extmem.h>
+#include <asm/kmsg.h>
 
-//#define MON_DEBUG			/* Debug messages on/off */
 
-#define MON_NAME "monreader"
-
-#define P_INFO(x...)	printk(KERN_INFO MON_NAME " info: " x)
-#define P_ERROR(x...)	printk(KERN_ERR MON_NAME " error: " x)
-#define P_WARNING(x...)	printk(KERN_WARNING MON_NAME " warning: " x)
-
-#ifdef MON_DEBUG
-#define P_DEBUG(x...)   printk(KERN_DEBUG MON_NAME " debug: " x)
-#else
-#define P_DEBUG(x...)   do {} while (0)
-#endif
+#define KMSG_COMPONENT "monreader"
 
 #define MON_COLLECT_SAMPLE 0x80
 #define MON_COLLECT_EVENT  0x40
@@ -172,7 +162,7 @@ static int mon_send_reply(struct mon_msg
 	} else
 		monmsg->replied_msglim = 1;
 	if (rc) {
-		P_ERROR("read, IUCV reply failed with rc = %i\n\n", rc);
+		kmsg_err(1, "Reading monitor data failed with rc=%i\n", rc);
 		return -EIO;
 	}
 	return 0;
@@ -251,7 +241,8 @@ static void mon_iucv_path_severed(struct
 {
 	struct mon_private *monpriv = path->private;
 
-	P_ERROR("IUCV connection severed with rc = 0x%X\n", ipuser[0]);
+	kmsg_err(2, "z/VM *MONITOR system service disconnected with rc=%i\n",
+		 ipuser[0]);
 	iucv_path_sever(path, NULL);
 	atomic_set(&monpriv->iucv_severed, 1);
 	wake_up(&mon_conn_wait_queue);
@@ -266,8 +257,7 @@ static void mon_iucv_message_pending(str
 	memcpy(&monpriv->msg_array[monpriv->write_index]->msg,
 	       msg, sizeof(*msg));
 	if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) {
-		P_WARNING("IUCV message pending, message limit (%i) reached\n",
-			  MON_MSGLIM);
+		kmsg_warn(3, "The read queue for monitor data is full\n");
 		monpriv->msg_array[monpriv->write_index]->msglim_reached = 1;
 	}
 	monpriv->write_index = (monpriv->write_index + 1) % MON_MSGLIM;
@@ -311,8 +301,8 @@ static int mon_open(struct inode *inode,
 	rc = iucv_path_connect(monpriv->path, &monreader_iucv_handler,
 			       MON_SERVICE, NULL, user_data_connect, monpriv);
 	if (rc) {
-		P_ERROR("iucv connection to *MONITOR failed with "
-			"IPUSER SEVER code = %i\n", rc);
+		kmsg_err(4, "Connecting to the z/VM *MONITOR system service "
+			    "failed with rc=%i\n", rc);
 		rc = -EIO;
 		goto out_path;
 	}
@@ -353,7 +343,8 @@ static int mon_close(struct inode *inode
 	 */
 	rc = iucv_path_sever(monpriv->path, user_data_sever);
 	if (rc)
-		P_ERROR("close, iucv_sever failed with rc = %i\n", rc);
+		kmsg_warn(5, "Disconnecting the z/VM *MONITOR system service "
+			     "failed with rc=%i\n", rc);
 
 	atomic_set(&monpriv->iucv_severed, 0);
 	atomic_set(&monpriv->iucv_connected, 0);
@@ -469,7 +460,8 @@ static int __init mon_init(void)
 	int rc;
 
 	if (!MACHINE_IS_VM) {
-		P_ERROR("not running under z/VM, driver not loaded\n");
+		kmsg_err(6, "The z/VM *MONITOR record device driver cannot be "
+			    "loaded without z/VM\n");
 		return -ENODEV;
 	}
 
@@ -478,7 +470,8 @@ static int __init mon_init(void)
 	 */
 	rc = iucv_register(&monreader_iucv_handler, 1);
 	if (rc) {
-		P_ERROR("failed to register with iucv driver\n");
+		kmsg_err(7, "The z/VM *MONITOR record device driver failed to "
+			    "register with IUCV\n");
 		return rc;
 	}
 
@@ -488,8 +481,8 @@ static int __init mon_init(void)
 		goto out_iucv;
 	}
 	if (rc != SEG_TYPE_SC) {
-		P_ERROR("segment %s has unsupported type, should be SC\n",
-			mon_dcss_name);
+		kmsg_err(8, "The specified *MONITOR DCSS %s does not have the "
+			    "required type SC\n", mon_dcss_name);
 		rc = -EINVAL;
 		goto out_iucv;
 	}

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 14/15] kmsg: convert s390 debug feature to kmsg api
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (12 preceding siblings ...)
  2008-07-28 17:54 ` [patch 13/15] kmsg: convert monreader " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  2008-07-28 17:54 ` [patch 15/15] kmsg: convert monwriter printk messages " Martin Schwidefsky
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Michael Holzheu, Martin Schwidefsky

[-- Attachment #1: 814-kmsg-debug.diff --]
[-- Type: text/plain, Size: 7521 bytes --]

From: Michael Holzheu <holzheu@de.ibm.com>

Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/s390dbf |   84 ++++++++++++++++++++++++++++++++++++++++
 arch/s390/kernel/debug.c        |   37 +++++++++--------
 2 files changed, 103 insertions(+), 18 deletions(-)

Index: quilt-2.6/arch/s390/kernel/debug.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/debug.c
+++ quilt-2.6/arch/s390/kernel/debug.c
@@ -23,6 +23,9 @@
 #include <linux/debugfs.h>
 
 #include <asm/debug.h>
+#include <asm/kmsg.h>
+
+#define KMSG_COMPONENT "s390dbf"
 
 #define DEBUG_PROLOG_ENTRY -1
 
@@ -693,8 +696,8 @@ debug_info_t *debug_register_mode(const 
 	/* Since debugfs currently does not support uid/gid other than root, */
 	/* we do not allow gid/uid != 0 until we get support for that. */
 	if ((uid != 0) || (gid != 0))
-		printk(KERN_WARNING "debug: Warning - Currently only uid/gid "
-		       "= 0 are supported. Using root as owner now!");
+		kmsg_warn(1, "Root becomes the owner of all s390dbf files "
+			  "in sysfs");
 	if (!initialized)
 		BUG();
 	mutex_lock(&debug_mutex);
@@ -709,7 +712,7 @@ debug_info_t *debug_register_mode(const 
 	debug_register_view(rc, &debug_pages_view);
 out:
         if (!rc){
-		printk(KERN_ERR "debug: debug_register failed for %s\n",name);
+		kmsg_err(2, "Registering debug feature %s failed\n", name);
         }
 	mutex_unlock(&debug_mutex);
 	return rc;
@@ -763,8 +766,8 @@ debug_set_size(debug_info_t* id, int nr_
 	if(pages_per_area > 0){
 		new_areas = debug_areas_alloc(pages_per_area, nr_areas);
 		if(!new_areas) {
-			printk(KERN_WARNING "debug: could not allocate memory "\
-					 "for pagenumber: %i\n",pages_per_area);
+			kmsg_info(6, "Allocating memory for %i pages failed",
+				  pages_per_area);
 			rc = -ENOMEM;
 			goto out;
 		}
@@ -780,8 +783,7 @@ debug_set_size(debug_info_t* id, int nr_
 	memset(id->active_entries,0,sizeof(int)*id->nr_areas);
 	memset(id->active_pages, 0, sizeof(int)*id->nr_areas);
 	spin_unlock_irqrestore(&id->lock,flags);
-	printk(KERN_INFO "debug: %s: set new size (%i pages)\n"\
-			 ,id->name, pages_per_area);
+	kmsg_info(0, "%s: set new size (%i pages)\n" ,id->name, pages_per_area);
 out:
 	return rc;
 }
@@ -800,10 +802,9 @@ debug_set_level(debug_info_t* id, int ne
 	spin_lock_irqsave(&id->lock,flags);
         if(new_level == DEBUG_OFF_LEVEL){
                 id->level = DEBUG_OFF_LEVEL;
-                printk(KERN_INFO "debug: %s: switched off\n",id->name);
+                kmsg_info(0, "%s: switched off\n",id->name);
         } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
-                printk(KERN_INFO
-                        "debug: %s: level %i is out of range (%i - %i)\n",
+                kmsg_info(0, "%s: level %i is out of range (%i - %i)\n",
                         id->name, new_level, 0, DEBUG_MAX_LEVEL);
         } else {
                 id->level = new_level;
@@ -1108,8 +1109,8 @@ debug_register_view(debug_info_t * id, s
 	pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry,
 				id , &debug_file_ops);
 	if (!pde){
-		printk(KERN_WARNING "debug: debugfs_create_file() failed!"\
-			" Cannot register view %s/%s\n", id->name,view->name);
+		kmsg_err(0, "Registering view %s/%s failed due to out of "
+			 "memory", id->name,view->name);
 		rc = -1;
 		goto out;
 	}
@@ -1119,10 +1120,8 @@ debug_register_view(debug_info_t * id, s
 			break;
 	}
 	if (i == DEBUG_MAX_VIEWS) {
-		printk(KERN_WARNING "debug: cannot register view %s/%s\n",
-			id->name,view->name);
-		printk(KERN_WARNING 
-			"debug: maximum number of views reached (%i)!\n", i);
+		kmsg_err(3, "Registering view %s/%s would exceed the maximum "
+			 "number of views %i", id->name, view->name, i);
 		debugfs_remove(pde);
 		rc = -1;
 	} else {
@@ -1303,7 +1302,8 @@ debug_input_level_fn(debug_info_t * id, 
 		new_level = debug_get_uint(str);
 	}
 	if(new_level < 0) {
-		printk(KERN_INFO "debug: level `%s` is not valid\n", str);
+		kmsg_warn(4, "%s is not a valid level for a debug "
+			  "feature\n", str);
 		rc = -EINVAL;
 	} else {
 		debug_set_level(id, new_level);
@@ -1380,7 +1380,8 @@ debug_input_flush_fn(debug_info_t * id, 
                 goto out;
         }
 
-        printk(KERN_INFO "debug: area `%c` is not valid\n", input_buf[0]);
+        kmsg_info(5, "Flushing debug data failed because %c is not a valid "
+		  "area\n", input_buf[0]);
 
 out:
         *offset += user_len;
Index: quilt-2.6/Documentation/s390/kmsg/s390dbf
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/s390dbf
@@ -0,0 +1,84 @@
+/*?
+ * Tag: s390dbf.1
+ * Text: "Root becomes the owner of all s390dbf files in sysfs"
+ * Severity: Warning
+ * Description:
+ * The S/390 debug feature you are using only supports uid/gid = 0.
+ * User action:
+ * None.
+ */
+
+/*?
+ * Tag: s390dbf.2
+ * Text: "Registering debug feature %s failed"
+ * Severity: Error
+ * Parameter:
+ *   @1: feature name
+ * Description:
+ * The initialization of an S/390 debug feature failed. A likely cause of this
+ * problem is memory constraints. The system keeps running, but the debug
+ * data for this feature will not be available in sysfs.
+ * User action:
+ * Consider assigning more memory to your LPAR or z/VM guest virtual machine.
+ */
+
+/*?
+ * Tag: s390dbf.3
+ * Text: "Registering view %s/%s would exceed the maximum number of views %i"
+ * Severity: Error
+ * Parameter:
+ *   @1: feature name
+ *   @2: view name
+ *   @3: maximum
+ * Description:
+ * The maximum number of allowed debug feature views has been reached. The
+ * view has not been registered. The system keeps running but the new view
+ * will not be available in sysfs. This is a program error.
+ * User action:
+ * Report this problem to your support partner.
+ */
+
+/*?
+ * Tag: s390dbf.4
+ * Text: "%s is not a valid level for a debug feature"
+ * Severity: Warning
+ * Parameter:
+ *   @1: level
+ * Description:
+ * Setting a new level for a debug feature by using the 'level' sysfs attribute
+ * failed. Valid levels are the minus sign (-) and the integers in the
+ * range 0 to 6. The minus sign switches off the feature. The numbers switch
+ * the feature on, where higher numbers produce more debug output.
+ * User action:
+ * Write a valid value to the 'level' sysfs attribute.
+ */
+
+/*?
+ * Tag: s390dbf.5
+ * Text: "Flushing debug data failed because %c is not a valid area"
+ * Severity: Warning
+ * Parameter:
+ *   @1: debug area number
+ * Description:
+ * Flushing a debug area by using the 'flush' sysfs attribute failed. Valid
+ * values are the minus sign (-) for flushing all areas, or the number of the
+ * respective area for flushing a single area.
+ * User action:
+ * Write a valid area number or the minus sign (-) to the 'flush' sysfs
+ * attribute.
+ */
+
+/*?
+ * Tag: s390dbf.6
+ * Text: "Allocating memory for %i pages failed"
+ * Severity: Error
+ * Parameter:
+ *   @1: number of pages
+ * Description:
+ * Setting the debug feature size by using the 'page' sysfs attribute failed.
+ * Linux did not have enough memory for expanding the debug feature to the
+ * requested size.
+ * User action:
+ * Use a smaller number of pages for the debug feature or allocate more
+ * memory to your LPAR or z/VM guest virtual machine.
+ */

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [patch 15/15] kmsg: convert monwriter printk messages to kmsg api.
  2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
                   ` (13 preceding siblings ...)
  2008-07-28 17:54 ` [patch 14/15] kmsg: convert s390 debug feature " Martin Schwidefsky
@ 2008-07-28 17:54 ` Martin Schwidefsky
  14 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-28 17:54 UTC (permalink / raw)
  To: linux-kernel, linux-s390; +Cc: Melissa Howland, Martin Schwidefsky

[-- Attachment #1: 815-kmsg-monwriter.diff --]
[-- Type: text/plain, Size: 1994 bytes --]

From: Melissa Howland <melissah@us.ibm.com>

Signed-off-by: Melissa Howland <melissah@us.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 Documentation/s390/kmsg/monwriter |   17 +++++++++++++++++
 drivers/s390/char/monwriter.c     |    4 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

Index: quilt-2.6/Documentation/s390/kmsg/monwriter
===================================================================
--- /dev/null
+++ quilt-2.6/Documentation/s390/kmsg/monwriter
@@ -0,0 +1,17 @@
+/*?
+ * Tag: monwriter.1
+ * Text: "Writing monitor data failed with rc=%i"
+ * Severity: Error
+ * Parameter:
+ *   @1: return code
+ * Description:
+ * The monitor stream application device driver used the z/VM diagnose call
+ * DIAG X'DC' to start writing monitor data. z/VM returned an error and the
+ * monitor data cannot be written. If the return code is 5, your z/VM guest
+ * virtual machine is not authorized to write monitor data.
+ * User action:
+ * If the return code is 5, ensure that your z/VM guest virtual machine's
+ * entry in the z/VM directory includes the OPTION APPLMON statement.
+ * For other return codes see the section about DIAGNOSE Code X'DC'
+ * in "z/VM CP Programming Services".
+ */
Index: quilt-2.6/drivers/s390/char/monwriter.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/monwriter.c
+++ quilt-2.6/drivers/s390/char/monwriter.c
@@ -24,7 +24,9 @@
 #include <asm/io.h>
 #include <asm/appldata.h>
 #include <asm/monwriter.h>
+#include <asm/kmsg.h>
 
+#define KMSG_COMPONENT "monwriter"
 #define MONWRITE_MAX_DATALEN	4010
 
 static int mon_max_bufs = 255;
@@ -66,7 +68,7 @@ static int monwrite_diag(struct monwrite
 		return rc;
 	if (rc == 5)
 		return -EPERM;
-	printk("DIAG X'DC' error with return code: %i\n", rc);
+	kmsg_err(1,"Writing monitor data failed with rc=%i\n", rc);
 	return -EINVAL;
 }
 

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
@ 2008-07-28 18:12   ` Joe Perches
  2008-07-29  8:07     ` Martin Schwidefsky
  2008-07-30  8:30   ` Andrew Morton
  1 sibling, 1 reply; 27+ messages in thread
From: Joe Perches @ 2008-07-28 18:12 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Mon, 2008-07-28 at 19:53 +0200, Martin Schwidefsky wrote:
> The kmsg component name is defined per source file with the KMSG_COMPONENT
> macro.

Why not use KBUILD_MODNAME?


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-28 17:53 ` [patch 02/15] kmsg: Kernel message catalog script Martin Schwidefsky
@ 2008-07-28 19:28   ` Sam Ravnborg
  2008-07-29  8:42     ` Martin Schwidefsky
  0 siblings, 1 reply; 27+ messages in thread
From: Sam Ravnborg @ 2008-07-28 19:28 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-kernel, linux-s390, Michael Holzheu

> 
> The kmsg man page creation is invoked with "make K=2" and reads the source
> files for all built objects, looks up the message description and writes
> a man page to $(objtree)/man.
Can we use M=2 instead of K=?
I have sort of reserved 'K' for Kconfig usage.

> Index: quilt-2.6/scripts/Makefile.build
> ===================================================================
> --- quilt-2.6.orig/scripts/Makefile.build
> +++ quilt-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,19 @@ $(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 = SRCTREE=$(srctree) OBJTREE=$(objtree) \
> +			$(KMSG_CHECK) $(kmsg_cmd) $(CC) $(c_flags) $< ;
> +endif
We are executing with $(objtree) as current directory so no need
to specify $(objtree) in the above.

You can used non-recursive assignments for kmsg_cmd (use ':=').

Do you really need the uppercase SRCTREE, OBJTREE?
Other scripts uses the lower cases variants direct.

	Sam

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-28 18:12   ` Joe Perches
@ 2008-07-29  8:07     ` Martin Schwidefsky
  0 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-29  8:07 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Mon, 2008-07-28 at 11:12 -0700, Joe Perches wrote:
> On Mon, 2008-07-28 at 19:53 +0200, Martin Schwidefsky wrote:
> > The kmsg component name is defined per source file with the KMSG_COMPONENT
> > macro.
> 
> Why not use KBUILD_MODNAME?

Because sometimes we might want to use the same kmsg prefix for multiple
modules. And the message tag is supposed to stay the same even if the
code structure changes. I'd rather not use KBUILD_MODNAME.

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-28 19:28   ` Sam Ravnborg
@ 2008-07-29  8:42     ` Martin Schwidefsky
  2008-07-29  8:45       ` Sam Ravnborg
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-29  8:42 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Mon, 2008-07-28 at 21:28 +0200, Sam Ravnborg wrote:
> > 
> > The kmsg man page creation is invoked with "make K=2" and reads the source
> > files for all built objects, looks up the message description and writes
> > a man page to $(objtree)/man.
> Can we use M=2 instead of K=?
> I have sort of reserved 'K' for Kconfig usage.

Ok, K= is taken but I can't use M= either because that is used for KBUILD_EXTMOD.
If tested with D= for "documentation", would that be okay ?

> > @@ -339,6 +341,19 @@ $(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 = SRCTREE=$(srctree) OBJTREE=$(objtree) \
> > +			$(KMSG_CHECK) $(kmsg_cmd) $(CC) $(c_flags) $< ;
> > +endif
> We are executing with $(objtree) as current directory so no need
> to specify $(objtree) in the above.

Ok, dropped $(objtree) from the shell command.

> You can used non-recursive assignments for kmsg_cmd (use ':=').

Will do.

> Do you really need the uppercase SRCTREE, OBJTREE?
> Other scripts uses the lower cases variants direct.

Ok, I'll fix the script to use srctree and objtree directly.

Thanks Sam.

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-29  8:42     ` Martin Schwidefsky
@ 2008-07-29  8:45       ` Sam Ravnborg
  2008-07-29 11:09         ` Martin Schwidefsky
  0 siblings, 1 reply; 27+ messages in thread
From: Sam Ravnborg @ 2008-07-29  8:45 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Tue, Jul 29, 2008 at 10:42:30AM +0200, Martin Schwidefsky wrote:
> On Mon, 2008-07-28 at 21:28 +0200, Sam Ravnborg wrote:
> > > 
> > > The kmsg man page creation is invoked with "make K=2" and reads the source
> > > files for all built objects, looks up the message description and writes
> > > a man page to $(objtree)/man.
> > Can we use M=2 instead of K=?
> > I have sort of reserved 'K' for Kconfig usage.
> 
> Ok, K= is taken but I can't use M= either because that is used for KBUILD_EXTMOD.
> If tested with D= for "documentation", would that be okay ?

D sounds fine with me.

Dunno what drugs I was on when I suggested M :-(

	Sam

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-29  8:45       ` Sam Ravnborg
@ 2008-07-29 11:09         ` Martin Schwidefsky
  2008-07-29 15:01           ` Jochen Voß
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-29 11:09 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Tue, 2008-07-29 at 10:45 +0200, Sam Ravnborg wrote:
> On Tue, Jul 29, 2008 at 10:42:30AM +0200, Martin Schwidefsky wrote:
> > On Mon, 2008-07-28 at 21:28 +0200, Sam Ravnborg wrote:
> > > > 
> > > > The kmsg man page creation is invoked with "make K=2" and reads the source
> > > > files for all built objects, looks up the message description and writes
> > > > a man page to $(objtree)/man.
> > > Can we use M=2 instead of K=?
> > > I have sort of reserved 'K' for Kconfig usage.
> > 
> > Ok, K= is taken but I can't use M= either because that is used for KBUILD_EXTMOD.
> > If tested with D= for "documentation", would that be okay ?
> 
> D sounds fine with me.
> 
> Dunno what drugs I was on when I suggested M :-(

Or not enough drugs: It is by caffeine alone I set my mind in motion, ..

The new patch with your proposed changes below. I still do not feel too
comfortable with changing the main Makefiles, the kmsg-doc script
currently only works for s390 and the D= option is added for all
architectures. I was thinking about replacing the hardcoded s390 with
$ARCH and keep the option to add the second path Documentation/kmsg for
common code kmsgs if a miracle happens and they get used by common code.
If that should happen the kmsg.h header would have to be moved out of
asm-s390 as well. Makes sense?

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.

--
Subject: [PATCH] kmsg: Kernel message catalog script.

From: Michael Holzheu <holzheu@de.ibm.com>
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Add a script and the calls to the make process that allows to check the
kmsg printk messages and to format man pages from the message descriptions.

The kmsg message description is a comment with the following format:

/*?
 * Tag: <component>.<id>
 * 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 script looks for a kmsg comment for a kmsg printk at two places,
the source file where the kmsg call is located and in the file
Documentation/s390/kmsg/<component>.

The kmsg check is invoked with "make K=1" and reads the source files for
all objects that are built by the current configuration and searches for
matching kmsg descriptions for the kmsg messages in the source which
have a messages id > 0. 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 K=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       |  358 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 388 insertions(+)

diff -urpN linux-2.6/Makefile linux-2.6-patched/Makefile
--- linux-2.6/Makefile	2008-07-29 11:32:45.000000000 +0200
+++ linux-2.6-patched/Makefile	2008-07-29 11:33:06.000000000 +0200
@@ -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
diff -urpN linux-2.6/scripts/kmsg-doc linux-2.6-patched/scripts/kmsg-doc
--- linux-2.6/scripts/kmsg-doc	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6-patched/scripts/kmsg-doc	2008-07-29 11:33:06.000000000 +0200
@@ -0,0 +1,358 @@
+#!/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;
+
+my $errors = 0;
+my $warnings = 0;
+my $srctree = "";
+my $objtree = "";
+my $kmsg_count = 0;
+
+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 =~ s/\" \"//g; # remove ...
+    $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, $id, $text, $sev, $argv) = @_;
+    my ($tag, $count, $parm);
+
+    if ($id == 0) {
+	return;
+    }
+    $text =~ s/\\n//g; # remove trailing newline character
+    $text =~ s/\" \"//g; # remove ...
+    $text =~ s/$component:\s*//g;
+    $tag = $component . "." . $id;
+    # Pretty print severity
+    $sev =~ s/EMERG/Emerg/;
+    $sev =~ s/ALERT/Alert/;
+    $sev =~ s/CRIT/Critical/;
+    $sev =~ s/ERR/Error/;
+    $sev =~ s/WARNING/Warning/;
+    $sev =~ s/NOTICE/Notice/;
+    $sev =~ s/INFO/Informational/;
+    $sev =~ s/DEBUG/Debug/;
+    $kmsg_print{$kmsg_count}->{'TAG'} = $tag;
+    $kmsg_print{$kmsg_count}->{'TEXT'} = $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 "<id>"
+	if (/^#define\s+KMSG_COMPONENT\s+\"(.*)\"[^\"]*$/o) {
+	    $component = $1;
+	}
+	if ($state == 0) {
+	    # kmsg message start: '/*?'
+	    if (/^\s*\/\*\?\s*$/o) {
+		$state = 1;
+		($tag, $text, $sev, $argv, $desc, $user) = ( "", "", "", "", "", "" );
+	    }
+	} elsif ($state == 1) {
+	    # kmsg message tag: ' * Tag: <tag>'
+	    if (/^\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 (/.*printk\(\s*__KMSG_CHECK\s*\(([^,]*)\,\s*(\d+)\s*\)\s*\"(.*)\"\s*,\s*(.*)\s*\)/o) {
+	    if ($component ne "") {
+		add_kmsg_print($component, $2, $3, $1, $4)
+	    } else {
+		warn "Error(${file}:$.): kmsg without component\n";
+		$errors++;
+	    }
+	} elsif (/.*printk\(\s*__KMSG_CHECK\s*\(([^,]*)\,\s*(\d+)\s*\)\s*\"(.*)\"\s*(.*)\s*\)/o) {
+	    if ($component ne "") {
+		add_kmsg_print($component, $2, $3, $1, $4)
+	    } 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";
+    @tags = keys %kmsg_desc;
+    @nums = ();
+    for (@tags) {
+	push @nums, /\.(\d+)/;
+    }
+    foreach $tag (@tags[ sort { $nums[$a] <=> $nums[$b] } 0..$#tags ]) {
+	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;
+	}
+	$file = $objtree . "man/" . $tag;
+	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(/,/,$kmsg_desc{$tag}->{'ARGV'});
+	    map{s/\s*//} @parms;
+	    foreach $parm (@parms) {
+		$parm =~ s/^\s+//;
+		if (!($parm eq "")) {
+		    print WR "$parm\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;
+}
+
+$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/s390/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);
diff -urpN linux-2.6/scripts/Makefile.build linux-2.6-patched/scripts/Makefile.build
--- linux-2.6/scripts/Makefile.build	2008-07-13 23:51:29.000000000 +0200
+++ linux-2.6-patched/scripts/Makefile.build	2008-07-29 11:33:06.000000000 +0200
@@ -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
 # ---------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-29 11:09         ` Martin Schwidefsky
@ 2008-07-29 15:01           ` Jochen Voß
  2008-07-29 15:15             ` Martin Schwidefsky
  0 siblings, 1 reply; 27+ messages in thread
From: Jochen Voß @ 2008-07-29 15:01 UTC (permalink / raw)
  To: schwidefsky; +Cc: Sam Ravnborg, linux-kernel, linux-s390, Michael Holzheu

Hi Martin,

I think the changelog needs fixing, too:

2008/7/29 Martin Schwidefsky <schwidefsky@de.ibm.com>:
> The kmsg check is invoked with "make K=1" and reads the source files for
> all objects that are built by the current configuration and searches for
> matching kmsg descriptions for the kmsg messages in the source which
> have a messages id > 0. 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 K=2" and reads the source
> files for all built objects, looks up the message description and writes
> a man page to $(objtree)/man.
This should be "D=1" and "D=2" now, shouldn't it?

I hope this helps,
Jochen
-- 
http://seehuhn.de/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 02/15] kmsg: Kernel message catalog script.
  2008-07-29 15:01           ` Jochen Voß
@ 2008-07-29 15:15             ` Martin Schwidefsky
  0 siblings, 0 replies; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-29 15:15 UTC (permalink / raw)
  To: Jochen Voß; +Cc: Sam Ravnborg, linux-kernel, linux-s390, Michael Holzheu

On Tue, 2008-07-29 at 16:01 +0100, Jochen Voß wrote:
> Hi Martin,
> 
> I think the changelog needs fixing, too:
> 
> 2008/7/29 Martin Schwidefsky <schwidefsky@de.ibm.com>:
> > The kmsg check is invoked with "make K=1" and reads the source files for
> > all objects that are built by the current configuration and searches for
> > matching kmsg descriptions for the kmsg messages in the source which
> > have a messages id > 0. 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 K=2" and reads the source
> > files for all built objects, looks up the message description and writes
> > a man page to $(objtree)/man.
> This should be "D=1" and "D=2" now, shouldn't it?

Yes, indeed. Thanks.

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
  2008-07-28 18:12   ` Joe Perches
@ 2008-07-30  8:30   ` Andrew Morton
  2008-07-30  9:13     ` Martin Schwidefsky
  1 sibling, 1 reply; 27+ messages in thread
From: Andrew Morton @ 2008-07-30  8:30 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Mon, 28 Jul 2008 19:53:56 +0200 Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:

> Introduce a new family of printk macros which prefixes each kmsg message
> with a component name and allows to tag the printk with a message id.
> 
> The kmsg component name is defined per source file with the KMSG_COMPONENT
> macro. The first argument of each kmsg printk is the message id. The
> message id "0" is special as it will suppress the message id prefix.
> 
> If the message id 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/asm-s390/kmsg.h |  124 ++++++++++++++++++++++++++++++++++++++++++++++++

Numerous people want a facility like this for other-than-s390 use. 
Progress has been intermittent and appears to have stopped.  The
apparently-dead mailing list is archived here:
https://lists.linux-foundation.org/pipermail/lf_kernel_messages/.

I don't know what the future holds for that development effort, but the
requirement won't go away.  So one day someone is going to go and yank
your implementation out of arch/s390 and into generic code.

So I'd suggest that you start out that way.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-30  8:30   ` Andrew Morton
@ 2008-07-30  9:13     ` Martin Schwidefsky
  2008-07-30  9:23       ` Andrew Morton
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Schwidefsky @ 2008-07-30  9:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Wed, 2008-07-30 at 01:30 -0700, Andrew Morton wrote:
> On Mon, 28 Jul 2008 19:53:56 +0200 Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:
> Numerous people want a facility like this for other-than-s390 use. 
> Progress has been intermittent and appears to have stopped.  The
> apparently-dead mailing list is archived here:
> https://lists.linux-foundation.org/pipermail/lf_kernel_messages/.
> 
> I don't know what the future holds for that development effort, but the
> requirement won't go away.  So one day someone is going to go and yank
> your implementation out of arch/s390 and into generic code.
> 
> So I'd suggest that you start out that way.

Somehow I have hoped for an answer like that :-) The only thing that
we'd have to do is find a proper place for the kmsg header file,
include/linux/kmsg.h comes to mind. The kmsg-doc script can easily be
change to check for multiple documentation directories, I was thinking
about Documentation/kmsg/$ARCH for the architecture specific things and
Documentation/kmsg for the generic parts.

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [patch 01/15] kmsg: Kernel message catalog macros.
  2008-07-30  9:13     ` Martin Schwidefsky
@ 2008-07-30  9:23       ` Andrew Morton
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew Morton @ 2008-07-30  9:23 UTC (permalink / raw)
  To: schwidefsky; +Cc: linux-kernel, linux-s390, Michael Holzheu

On Wed, 30 Jul 2008 11:13:41 +0200 Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:

> On Wed, 2008-07-30 at 01:30 -0700, Andrew Morton wrote:
> > On Mon, 28 Jul 2008 19:53:56 +0200 Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:
> > Numerous people want a facility like this for other-than-s390 use. 
> > Progress has been intermittent and appears to have stopped.  The
> > apparently-dead mailing list is archived here:
> > https://lists.linux-foundation.org/pipermail/lf_kernel_messages/.
> > 
> > I don't know what the future holds for that development effort, but the
> > requirement won't go away.  So one day someone is going to go and yank
> > your implementation out of arch/s390 and into generic code.
> > 
> > So I'd suggest that you start out that way.
> 
> Somehow I have hoped for an answer like that :-) The only thing that
> we'd have to do is find a proper place for the kmsg header file,
> include/linux/kmsg.h comes to mind. The kmsg-doc script can easily be
> change to check for multiple documentation directories, I was thinking
> about Documentation/kmsg/$ARCH for the architecture specific things and
> Documentation/kmsg for the generic parts.
> 

No objections from me.

It would be wonderful if someone could troll those list archives and
see if they can wake up the people who were involved in that effort. 
They probably won't help much with development but it would be useful if
we could get their review/design input.


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2008-07-30  9:25 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 17:53 [patch 00/15] [RFC] kmsg macros and script Martin Schwidefsky
2008-07-28 17:53 ` [patch 01/15] kmsg: Kernel message catalog macros Martin Schwidefsky
2008-07-28 18:12   ` Joe Perches
2008-07-29  8:07     ` Martin Schwidefsky
2008-07-30  8:30   ` Andrew Morton
2008-07-30  9:13     ` Martin Schwidefsky
2008-07-30  9:23       ` Andrew Morton
2008-07-28 17:53 ` [patch 02/15] kmsg: Kernel message catalog script Martin Schwidefsky
2008-07-28 19:28   ` Sam Ravnborg
2008-07-29  8:42     ` Martin Schwidefsky
2008-07-29  8:45       ` Sam Ravnborg
2008-07-29 11:09         ` Martin Schwidefsky
2008-07-29 15:01           ` Jochen Voß
2008-07-29 15:15             ` Martin Schwidefsky
2008-07-28 17:53 ` [patch 03/15] kmsg: convert cio message to kmsg api Martin Schwidefsky
2008-07-28 17:53 ` [patch 04/15] kmsg: convert vmcp " Martin Schwidefsky
2008-07-28 17:54 ` [patch 05/15] kmsg: convert cpcmd " Martin Schwidefsky
2008-07-28 17:54 ` [patch 06/15] kmsg: convert vmur " Martin Schwidefsky
2008-07-28 17:54 ` [patch 07/15] kmsg: convert xpram messages " Martin Schwidefsky
2008-07-28 17:54 ` [patch 08/15] kmsg: convert cpacf printk " Martin Schwidefsky
2008-07-28 17:54 ` [patch 09/15] kmsg: convert time " Martin Schwidefsky
2008-07-28 17:54 ` [patch 10/15] kmsg: convert hypfs " Martin Schwidefsky
2008-07-28 17:54 ` [patch 11/15] kmsg: convert setup " Martin Schwidefsky
2008-07-28 17:54 ` [patch 12/15] kmsg: convert appldata " Martin Schwidefsky
2008-07-28 17:54 ` [patch 13/15] kmsg: convert monreader " Martin Schwidefsky
2008-07-28 17:54 ` [patch 14/15] kmsg: convert s390 debug feature " Martin Schwidefsky
2008-07-28 17:54 ` [patch 15/15] kmsg: convert monwriter printk messages " Martin Schwidefsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).