Skip to contentSkip to conversation

kmsg macros and script, take x+1.

RFC PATCH In review Martin Schwidefsky 12 participants 71 messages Jul 30, 2008 – Sep 2, 2008 1 message not in the archive

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

cover kmsg macros and script, take x+1.

Greetings,
the last kmsg patches on lkml got some useful feedback and Andrew advised to extend the scope of the this discussion to lf_kernel_messages. I've added all individuals I could find who participated in the kernel messages discussions last year.
Since then we continued to work on the kernel messages for s390 and the three patches in this series is the gist of it.

The lastest changes:
* kmsg.h has been moved from include/asm-s390 to include/linux
* The s390 specific documentation is now in Documentation/kmsg/s390
* The script checks for messages in the source file, Documentation/kmsg and Documentation/kmsg/$SRCARCH
* I've reduced the number of patches to three, a single example how the kmsg interface is used should be enough.

The initial approach has been to keep the kmsg interface local to s390, but Andrew thinks it has potential for common use. That is where all the people on Cc: come into play: what is your opinion? Can we go ahead with it?

Signature · 4 lines
blue skies,
   Martin.

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

PATCH 1/3 kmsg: Kernel message catalog macros.

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

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.

---

 arch/s390/Kconfig    |    9 +++
 include/linux/kmsg.h |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)
arch/s390/Kconfig +9 -0
Index: linux-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"
include/linux/kmsg.h new file +124 -0

124 lines not on this page · raw message

Signature · 4 lines
blue skies,
   Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 48 lines · Martin Schwidefsky

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

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.

---

 arch/s390/Kconfig    |    9 +++
 include/linux/kmsg.h |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

Index: linux-2.6/arch/s390/Kconfig
===================================================================

arch/s390/Kconfig +9 -0
@@ -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: linux-2.6/include/linux/kmsg.h
===================================================================

include/linux/kmsg.h line 6

Quoted 6 lines
include/linux/kmsg.h new file +6 -0
@@ -0,0 +1,124 @@
+#ifndef _LINUX_KMSG_H
+#define _LINUX_KMSG_H
+
+#ifndef __KMSG_CHECKER
+#define __KMSG_CHECK(level, id) KERN_##level
+#endif

What if __KMSG_CHECKER is enabled? What does __KMSG_CHECK resolve to then?

And what sets __KMSG_CHECKER?

thanks,

greg k-h

#3 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 15 lines · Greg KH

include/linux/kmsg.h line 6

Quoted 11 lines

Index: linux-2.6/include/linux/kmsg.h
===================================================================

include/linux/kmsg.h new file +6 -0
@@ -0,0 +1,124 @@
+#ifndef _LINUX_KMSG_H
+#define _LINUX_KMSG_H
+
+#ifndef __KMSG_CHECKER
+#define __KMSG_CHECK(level, id) KERN_##level
+#endif

What if __KMSG_CHECKER is enabled? What does __KMSG_CHECK resolve to then?

Quoted 1 line

And what sets __KMSG_CHECKER?

The kmsg-doc script sets __KMSG_CHECKER and nothing else should ever define it. It is used to preprocess the .c files to get at the kernel messages. See process_cpp_file in the kmsg-doc script.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Martin Schwidefsky

include/linux/kmsg.h line 12

Quoted 3 lines · Martin Schwidefsky
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Thanks,
Kay

#5 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 8 lines · Kay Sievers

include/linux/kmsg.h line 12

Quoted 3 lines · Martin Schwidefsky
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Hm, just use dev_printk() instead, it handles all of these kinds of changes automatically.

thanks,

greg k-h

#6 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 4 lines · Greg KH
Quoted 3 lines · Kay Sievers

On Wed, Jul 30, 2008 at 18:56, Martin Schwidefsky
<[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Hm, just use dev_printk() instead, it handles all of these kinds of changes automatically.

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 14 lines · Martin Schwidefsky
Quoted 4 lines · Greg KH
Quoted 3 lines · Kay Sievers

On Wed, Jul 30, 2008 at 18:56, Martin Schwidefsky
<[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Hm, just use dev_printk() instead, it handles all of these kinds of changes automatically.

Quoted 6 lines

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

And if not, fix up dev_printk() to properly delinate when we have missing fields, why create a totally new thing here that we need to convert subsystems into?

thanks,

greg k-h

#8 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 22 lines · Greg KH
Quoted 14 lines · Martin Schwidefsky
Quoted 4 lines · Greg KH
Quoted 3 lines · Kay Sievers

On Wed, Jul 30, 2008 at 18:56, Martin Schwidefsky
<[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Hm, just use dev_printk() instead, it handles all of these kinds of changes automatically.

Quoted 6 lines

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

Quoted 2 lines

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

The missing field is the message tag. Which is the key for the message lookup. As far as the kmsg catalog is concerned this is a pretty important field that may not be missing from the printk itself.

Quoted 3 lines

And if not, fix up dev_printk() to properly delinate when we have missing fields, why create a totally new thing here that we need to convert subsystems into?

To "fix" dev_printk would mean to add the message tag. Which requires to change all callers. The better approach is to add a new printk wrapper and decide for each subsystem if it shouuld be converted. I'm not advocating to change everything. The kmsg macros is a way to document the message from a piece of code if you choose to use these macros.

What could be done is to move the kmsg_dev_xxx macros to include/linux/device.h if you want to keep all device printk related definitions in one place. Would that be more acceptable ?

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 23 lines · Martin Schwidefsky
Quoted 22 lines · Greg KH
Quoted 20 lines · Martin Schwidefsky
Quoted 4 lines · Greg KH
Quoted 3 lines · Kay Sievers

On Wed, Jul 30, 2008 at 18:56, Martin Schwidefsky
<[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Hm, just use dev_printk() instead, it handles all of these kinds of changes automatically.

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

Quoted 6 lines
Quoted 2 lines

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

The missing field is the message tag. Which is the key for the message lookup. As far as the kmsg catalog is concerned this is a pretty important field that may not be missing from the printk itself.

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

thanks,

greg k-h

#10 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 10 lines · Greg KH
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

Quoted 6 lines
Quoted 3 lines

The missing field is the message tag. Which is the key for the message lookup. As far as the kmsg catalog is concerned this is a pretty important field that may not be missing from the printk itself.

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

Hmm, you are proposing to introduce a second format for the kmsg messages to avoid the need for some more printk wrapper macros. To me it seems that this has two problems:
1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.
2) The message tag for a driver message usually already includes the driver name, the dev_printk will print it again. This is ugly and reduces the quality of the message.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

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

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

Hmm, you are proposing to introduce a second format for the kmsg messages to avoid the need for some more printk wrapper macros. To me it seems that this has two problems:
1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.

I think the message tag today is not useful for a user.

It seems a barely useful maintainer value.

Perhaps the message tag allows for run-time language translation and maybe a bit better selective logging.

Quoted 3 lines

2) The message tag for a driver message usually already includes the driver name, the dev_printk will print it again. This is ugly and reduces the quality of the message.

Ugly is a beholder problem.

Either printk or dev_printk could reorder the output.

#12 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 10 lines · Joe Perches
Quoted 8 lines · Martin Schwidefsky
Quoted 2 lines · Greg KH

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

Hmm, you are proposing to introduce a second format for the kmsg messages to avoid the need for some more printk wrapper macros. To me it seems that this has two problems:
1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.

Quoted 6 lines

I think the message tag today is not useful for a user.

It seems a barely useful maintainer value.

Perhaps the message tag allows for run-time language translation and maybe a bit better selective logging.

Aehhm, .. what ? If a user does not understand a message directly how can he NOT be interested in the kmsg tag? As a random example consider the situation when the user gets the message

monwriter.1: Writing monitor data failed with rc=5

Usually a user will go "Huh?" except if he is a z/VM expert. Looking at the source code won't help too much either:

static int monwrite_diag(struct monwrite_hdr *myhdr, char *buffer, int fcn)

{
        struct appldata_product_id id;
        int rc;

        strcpy(id.prod_nr, "LNXAPPL");
        id.prod_fn = myhdr->applid;
        id.record_nr = myhdr->record_num;
        id.version_nr = myhdr->version;
        id.release_nr = myhdr->release;
        id.mod_lvl = myhdr->mod_level;
        rc = appldata_asm(&id, fcn, (void *) buffer, myhdr->datalen);
        if (rc <= 0)
                return rc;
        if (rc == 5)
                return -EPERM;
        kmsg_err(1,"Writing monitor data failed with rc=%i\n", rc);
        return -EINVAL;
}

What the user should do is to cut-copy-paste the kmsg tag monwriter.1 and pass it to man:

# man monwriter.1

What the user will then get is the man page that has been generated from the kmsg comment with "make D=2":

--- snip
monwriter.1(9) monwriter.1(9)

Message
monwriter.1: Writing monitor data failed with rc=%i

Severity
Error

Parameters
@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".

LINUX Linux Messages monwriter.1(9)
--- snip

Now the user actually gets help: the description tells him that rc=5 probably is because the virtual machine is not authorized. The key to be able to get to the description associated to a message is the kmsg tag.

By the way the kmsg comment for monwriter.1 is as follows just in case you are wondering:

/*?
* 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".
*/

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 63 lines · Martin Schwidefsky
Quoted 7 lines · Joe Perches
Quoted 2 lines · Martin Schwidefsky

1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.

I think the message tag today is not useful for a user. It seems a barely useful maintainer value. Perhaps the message tag allows for run-time language translation and maybe a bit better selective logging.

Aehhm, .. what ? If a user does not understand a message directly how can he NOT be interested in the kmsg tag? As a random example consider the situation when the user gets the message

monwriter.1: Writing monitor data failed with rc=5

Usually a user will go "Huh?" except if he is a z/VM expert. Looking at the source code won't help too much either:

static int monwrite_diag(struct monwrite_hdr *myhdr, char *buffer, int fcn)

{
        struct appldata_product_id id;
        int rc;

        strcpy(id.prod_nr, "LNXAPPL");
        id.prod_fn = myhdr->applid;
        id.record_nr = myhdr->record_num;
        id.version_nr = myhdr->version;
        id.release_nr = myhdr->release;
        id.mod_lvl = myhdr->mod_level;
        rc = appldata_asm(&id, fcn, (void *) buffer, myhdr->datalen);
        if (rc <= 0)
                return rc;
        if (rc == 5)
                return -EPERM;
        kmsg_err(1,"Writing monitor data failed with rc=%i\n", rc);
        return -EINVAL;
}

What the user should do is to cut-copy-paste the kmsg tag monwriter.1 and pass it to man:

# man monwriter.1

What the user will then get is the man page that has been generated from the kmsg comment with "make D=2":

--- snip
monwriter.1(9) monwriter.1(9)

Message
monwriter.1: Writing monitor data failed with rc=%i

Severity
Error

Parameters
@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.

Quoted 5 lines

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".

Doesn't this example better illustrate the barely useful user value of such a message and documentation?

In your example, monwriter.1 with a return code of 5 isn't possible.

#14 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 4 lines · Joe Perches

Doesn't this example better illustrate the barely useful user value of such a message and documentation?

In your example, monwriter.1 with a return code of 5 isn't possible.

That is true, thanks for pointing out this bug. I doesn't change anything about the need for a message documentation though, it only proves that the documentation can have errors. At least the customers running linux on System z want to have the documentation.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Martin Schwidefsky
Quoted 15 lines · Martin Schwidefsky
Quoted 14 lines · Greg KH
Quoted 13 lines
Quoted 9 lines
Quoted 6 lines

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

The missing field is the message tag. Which is the key for the message lookup. As far as the kmsg catalog is concerned this is a pretty important field that may not be missing from the printk itself.

Quoted 6 lines
Quoted 2 lines

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

Hmm, you are proposing to introduce a second format for the kmsg messages to avoid the need for some more printk wrapper macros. To me it seems that this has two problems:

No, only 1 format, use dev_printk() instead of printk() in your macro.

Quoted 2 lines

1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.

How would it not be in a fixed position with dev_printk()?

Quoted 3 lines

2) The message tag for a driver message usually already includes the driver name, the dev_printk will print it again. This is ugly and reduces the quality of the message.

Then the message needs to change and remove that "driver name", as it is redundant, saving a tiny ammount of space :)

thanks,

greg k-h

#16 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 16 lines · Greg KH
Quoted 15 lines · Martin Schwidefsky
Quoted 14 lines · Greg KH
Quoted 13 lines
Quoted 9 lines
Quoted 6 lines

Using dev_printk won't work because of the order of the elements of the printk. The kmsg tag should not have a "random" position in the printk but should be the first element. If we use dev_printk the kmsg tag will be the third element, for other kmsg printks it will be the first. In addition the kmsg message tag for the device drivers already includes the driver name ..

But the structure of dev_printk() is well definied and should be pretty trival to parse even with missing fields.

The missing field is the message tag. Which is the key for the message lookup. As far as the kmsg catalog is concerned this is a pretty important field that may not be missing from the printk itself.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

No, I mean use dev_printk() as the base for your logging macro. Add your message tag as the first field after the dev_printk() information.

Hmm, you are proposing to introduce a second format for the kmsg messages to avoid the need for some more printk wrapper macros. To me it seems that this has two problems:

No, only 1 format, use dev_printk() instead of printk() in your macro.

No, there are more printks in the system then just dev_printk. The kmsg interface is supposed to cover all of them.

Quoted 4 lines
Quoted 2 lines

1) The message tag is for the user of the system. If it does not have a fixed position it gets confusing.

How would it not be in a fixed position with dev_printk()?

It is fixed in the macro for standard kmsg printks, there the message tag is the first field. It is fixed in the macro for the dev_printk variant of the kmsg message, there it is the third field. This mismatch I refer to as not have a fixed position, for some message (the standard ones) it is at the start of the final message, for others (the dev_printk ones) it is in the middle of the message. Not good.

Quoted 6 lines
Quoted 3 lines

2) The message tag for a driver message usually already includes the driver name, the dev_printk will print it again. This is ugly and reduces the quality of the message.

Then the message needs to change and remove that "driver name", as it is redundant, saving a tiny ammount of space :)

Then lets look at how this will look like. First a standard printk message and its conversion to kmsg:

	printk(KERN_WARNING
               "cpcmd: could not allocate response buffer\n");
vs.
	kmsg_warn(1, "The cpcmd kernel function failed "
                     "to allocate a response buffer\n");

The message comes out as
cpcmd: cound not allocate response buffer
vs.
cpcmd.1: The cpcmd kernel function failed to allocate a response buffer

As an example for a dev_printk I use a message from the zfcp driver:

	dev_warn(&req->adapter->ccw_device->dev,
                 "The local link is down: no light detected.\n");
vs.
        kmsg_dev_warn(27, &req->adapter->ccw_device->dev,
                 "The local link is down: no light detected.\n");

The dev_printk versus the original kmsg macro comes out as
zfcp: 0.0.1234: The local link is down: no light detected.
vs.
zfcp.27: 0.0.1234: The local link is down: no light detected.

If I would just use dev_printk in kmsg_dev_warn as proposed by Greg:
zfcp: 0.0.1234: zfcp.27: The local link is down: no light detected.

If the message component is skipped from the message tag:
zfcp: 0.0.1234: 27: The local link is down: no light detected.

Is it just me who thinks that the later two message variants are crap?

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

On Sun 10-08-08 02:03:41, Martin Schwidefsky wrote:
...

Quoted 25 lines

Then lets look at how this will look like. First a standard printk message and its conversion to kmsg:

	printk(KERN_WARNING
               "cpcmd: could not allocate response buffer\n");
vs.
	kmsg_warn(1, "The cpcmd kernel function failed "
                     "to allocate a response buffer\n");

The message comes out as
cpcmd: cound not allocate response buffer
vs.
cpcmd.1: The cpcmd kernel function failed to allocate a response buffer

As an example for a dev_printk I use a message from the zfcp driver:

	dev_warn(&req->adapter->ccw_device->dev,
                 "The local link is down: no light detected.\n");
vs.
        kmsg_dev_warn(27, &req->adapter->ccw_device->dev,
                 "The local link is down: no light detected.\n");

The dev_printk versus the original kmsg macro comes out as
zfcp: 0.0.1234: The local link is down: no light detected.
vs.
zfcp.27: 0.0.1234: The local link is down: no light detected.

Quoted 7 lines

If I would just use dev_printk in kmsg_dev_warn as proposed by Greg:
zfcp: 0.0.1234: zfcp.27: The local link is down: no light detected.

If the message component is skipped from the message tag:
zfcp: 0.0.1234: 27: The local link is down: no light detected.

Is it just me who thinks that the later two message variants are crap?

If I may vote in this poll ;) I agree with you that the first two device
messages look better (more comprehensible) than the last two...

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#18 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Kay Sievers
Quoted 8 lines · Kay Sievers

include/linux/kmsg.h line 12

Quoted 3 lines · Martin Schwidefsky
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+       printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+               ": %s: " format, (dev)->bus_id , ## arg)

Care to use dev_name(), bus_id will be removed soon.

Yes, will do. Thanks.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Martin Schwidefsky
Quoted 5 lines · Martin Schwidefsky

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

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.

We've been talking about doing something like this, just this week. AKPM pointed me at this thread. Good timing. :)

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+    printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+        ": %s: " format, (dev)->bus_id , ## arg)

Rather than the gcc-specific '## arg', shouldn't we use the standard C99
form: '##__VA_ARGS__' ?

As a format, I would argue to leave out the spaces after colons, making the inevitable string splitting even easier.

I don't care for the magic file-global KMSG_COMPONENT. It just feels wrong. In most cases, I want the prefix to be hierarchical. For example, rather than "tg3" I want "net.tg3" or "netdev:tg3" or something.

Further, We want to make a clearer denotation between "just another printk()" and these things, which are really "important events". Maybe a global prefix that makes it easy to seperate them out? Or a parallel "event" interface that logs to printk() and a netlink socket?

Tim

#20 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 10 lines · Tim Hockin
Quoted 5 lines · Martin Schwidefsky

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

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.

We've been talking about doing something like this, just this week. AKPM pointed me at this thread. Good timing. :)

Good to hear that we are not the only one working on this.

Quoted 6 lines

include/linux/kmsg.h line 12

Quoted 3 lines
include/linux/kmsg.h new file +3 -0
+#define kmsg_dev_alert(id, dev, format, arg...) \
+    printk(__KMSG_CHECK(ALERT, id) KMSG_COMPONENT \
+        ": %s: " format, (dev)->bus_id , ## arg)

Rather than the gcc-specific '## arg', shouldn't we use the standard C99
form: '##__VA_ARGS__' ?

Ok, I changed the macros accordingly.

Quoted 2 lines

As a format, I would argue to leave out the spaces after colons, making the inevitable string splitting even easier.

Makes sense and it does not make the message harder to read.

Quoted 3 lines

I don't care for the magic file-global KMSG_COMPONENT. It just feels wrong. In most cases, I want the prefix to be hierarchical. For example, rather than "tg3" I want "net.tg3" or "netdev:tg3" or something.

But what is the alternative to the #define to specify the base name of the message tag? KBUILD_MODNAME has been proposed but I don't think this is a good idea since I want the message tags to be independent of the code structure.

Quoted 4 lines

Further, We want to make a clearer denotation between "just another printk()" and these things, which are really "important events". Maybe a global prefix that makes it easy to seperate them out? Or a parallel "event" interface that logs to printk() and a netlink socket?

Well the kmsg macros distinguish between id==0 and id>0 messages. For a id==0 message there is no documentation required and the kmsg prefix will be just the KMSG_COMPONENT. You could consider that to be "just another printk". For id>0 the kmsg macros will create the tuppel KMSG_COMPONENT.ID so you already can separate "normal" and "important" prinkts.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 8 lines · Martin Schwidefsky
Quoted 3 lines

I don't care for the magic file-global KMSG_COMPONENT. It just feels wrong. In most cases, I want the prefix to be hierarchical. For example, rather than "tg3" I want "net.tg3" or "netdev:tg3" or something.

But what is the alternative to the #define to specify the base name of the message tag? KBUILD_MODNAME has been proposed but I don't think this is a good idea since I want the message tags to be independent of the code structure.

We had talked internally about something like this:

globally:

    // this is the actual implementation
    extern void send_kmsg(int level, const char *fmt, ...);

    // this is a convenience wrapper, maybe not needed as they get combinatoric
    #define kmsg_err(fmt, ...) \
    	send_kmsg(KERN_ERROR, fmt, ##__VA_ARGS__)

inside a subsystem-specific header:

    #define mysubsys_kmsg_err(fmt, ...) \
    	kmsg_err("mysubsys:" fmt "\n", ##__VA_ARGS__)

inside each subsystem-driver:

    #define mydriver_kmsg_err(fmt, ...) \
    	mysubsys_kmsg_err("mydriver:" fmt, ##__VA_ARGS__)

then the driver just calls:

    mydriver_kmsg_err("something happened");

and you get, at the bottom:

    printk(KERN_ERROR "mysubsy:mydriver:something happened\n");

I'm not sure how your ID number fits in there, propbably

    printk(KERN_ERROR "mysubsy:mydriver.%d something happened\n", id);

That way, the hierarchy is defined by the meaningful hierarchy of subsystems and busses and drivers. Subsystems which have device structs can add them into the mix (netdev, ATA, etc). The core infrastructure stays small, while providing driver and subsys maintainers the flexibility to define their own event hierarchies.

Quoted 11 lines
Quoted 4 lines

Further, We want to make a clearer denotation between "just another printk()" and these things, which are really "important events". Maybe a global prefix that makes it easy to seperate them out? Or a parallel "event" interface that logs to printk() and a netlink socket?

Well the kmsg macros distinguish between id==0 and id>0 messages. For a id==0 message there is no documentation required and the kmsg prefix will be just the KMSG_COMPONENT. You could consider that to be "just another printk". For id>0 the kmsg macros will create the tuppel KMSG_COMPONENT.ID so you already can separate "normal" and "important" prinkts.

That works, I suppose. I'd still advocate for a netlink-style conduit (maybe with buffering?) for "important event" kmsgs, separate from plain old printk.

I'd also advocate that maybe we should go a bit further with the structure, by providing a soft-structured set of key-value pairs. I'm not 100% on the details, but something like:

    printk(KERN_ERROR
    	"mysubsy:mydriver.%d something happened -- pid=%d status=0x%04x\n",
    	id, pid, status);

Where everything after "--" (or some other delimiter) is a key=value.

Quoted 10 lines
Quoted 6 lines

What I want to see is the elevation of these call-sites from "it's just a printk()" to "it's a report-worthy event and part of our user<->kernel API". I want people to add them when it's appropriate and then not change the strings later. I don't care if, in the end, they are structured strings. I do care if I have to run dozens of regexes against thousands of log-lines on thousands of systems.

Yes, and this has already happened with the s390 device driver messages. With the conversion to kmsg our developers removed a lot of crud from the code, this alone makes it worthwhile.

Do you see *every* printk() becoming a kmsg? Just printk() in drivers? Or just some hand-chosen printk()s ?

Tim

#22 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 5 lines · Tim Hockin
    // this is the actual implementation
    extern void send_kmsg(int level, const char *fmt, ...);
    // this is a convenience wrapper, maybe not needed as they get combinatoric
    #define kmsg_err(fmt, ...) \
    	send_kmsg(KERN_ERROR, fmt, ##__VA_ARGS__)
Quoted 8 lines

inside a subsystem-specific header:

    #define mysubsys_kmsg_err(fmt, ...) \
    	kmsg_err("mysubsys:" fmt "\n", ##__VA_ARGS__)
  inside each subsystem-driver:
    #define mydriver_kmsg_err(fmt, ...) \
    	mysubsys_kmsg_err("mydriver:" fmt, ##__VA_ARGS__)
  then the driver just calls:
    mydriver_kmsg_err("something happened");

I think adding system/subsystem/driver prefixes
to function names is not good.

Though Martin Schwidefsky thinks KMSG_COMPONENT is necessary, I am unconvinced.

Perhaps using something like Jason Baron's new dynamic debug infrastructure, all the event logging functions could optionally print KBUILD_MODNAME, __func__ and __line__ if desired.

Quoted 3 lines

Do you see *every* printk() becoming a kmsg?
Just printk() in drivers?
Or just some hand-chosen printk()s ?

I'd prefer every printk(KERN_<level> become pr_<level> and kernel.h be reorganized so that all logging functions are declared in a separate include file, maybe logging.h

kmsg_<level> could eventually live in logging.h

Here's a reorganization of kernel.h:
----------------------

Create <linux/logging.h>
Move content of <linux/ratelimit.h> into <linux/logging.h> Delete <linux/ratelimit.h>
Move logging content from <linux/kernel.h> into <linux/logging.h>

---
 include/linux/kernel.h    |  109 +----------------------------------
 include/linux/logging.h   |  139 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/ratelimit.h |   27 ---------
 3 files changed, 141 insertions(+), 134 deletions(-)
include/linux/kernel.h +2 -107
index 2651f80..63e647b 100644
@@ -15,13 +15,11 @@
 #include <linux/bitops.h>
 #include <linux/log2.h>
 #include <linux/typecheck.h>
-#include <linux/ratelimit.h>
+#include <linux/logging.h>
+
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
-extern const char linux_banner[];
-extern const char linux_proc_banner[];
-
 #define USHORT_MAX	((u16)(~0U))
 #define SHORT_MAX	((s16)(USHORT_MAX>>1))
 #define SHORT_MIN	(-SHORT_MAX - 1)
@@ -81,29 +79,6 @@ extern const char linux_proc_banner[];
  */
 #define lower_32_bits(n) ((u32)(n))
 
-#define	KERN_EMERG	"<0>"	/* system is unusable			*/
-#define	KERN_ALERT	"<1>"	/* action must be taken immediately	*/
-#define	KERN_CRIT	"<2>"	/* critical conditions			*/
-#define	KERN_ERR	"<3>"	/* error conditions			*/
-#define	KERN_WARNING	"<4>"	/* warning conditions			*/
-#define	KERN_NOTICE	"<5>"	/* normal but significant condition	*/
-#define	KERN_INFO	"<6>"	/* informational			*/
-#define	KERN_DEBUG	"<7>"	/* debug-level messages			*/
-
-/*
- * Annotation for a "continued" line of log printout (only done after a
- * line that had no enclosing \n). Only to be used by core/arch code
- * during early bootup (a continued line is not SMP-safe otherwise).
- */
-#define	KERN_CONT	""
-
-extern int console_printk[];
-
-#define console_loglevel (console_printk[0])
-#define default_message_loglevel (console_printk[1])
-#define minimum_console_loglevel (console_printk[2])
-#define default_console_loglevel (console_printk[3])
-
 struct completion;
 struct pt_regs;
 struct user;
@@ -190,48 +165,8 @@ extern int kernel_text_address(unsigned long addr);
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
 
-#ifdef CONFIG_PRINTK
-asmlinkage int vprintk(const char *fmt, va_list args)
-	__attribute__ ((format (printf, 1, 0)));
-asmlinkage int printk(const char * fmt, ...)
-	__attribute__ ((format (printf, 1, 2))) __cold;
-
-extern struct ratelimit_state printk_ratelimit_state;
-extern int printk_ratelimit(void);
-extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
-				   unsigned int interval_msec);
-#else
-static inline int vprintk(const char *s, va_list args)
-	__attribute__ ((format (printf, 1, 0)));
-static inline int vprintk(const char *s, va_list args) { return 0; }
-static inline int printk(const char *s, ...)
-	__attribute__ ((format (printf, 1, 2)));
-static inline int __cold printk(const char *s, ...) { return 0; }
-static inline int printk_ratelimit(void) { return 0; }
-static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
-					  unsigned int interval_msec)	\
-		{ return false; }
-#endif
-
-extern void asmlinkage __attribute__((format(printf, 1, 2)))
-	early_printk(const char *fmt, ...);
-
 unsigned long int_sqrt(unsigned long);
 
-static inline void console_silent(void)
-{
-	console_loglevel = 0;
-}
-
-static inline void console_verbose(void)
-{
-	if (console_loglevel)
-		console_loglevel = 15;
-}
-
-extern void bust_spinlocks(int yes);
-extern void wake_up_klogd(void);
-extern int oops_in_progress;		/* If set, an oops, panic(), BUG() or die() is in progress */
 extern int panic_timeout;
 extern int panic_on_oops;
 extern int panic_on_unrecovered_nmi;
@@ -261,22 +196,6 @@ extern enum system_states {
 #define TAINT_OVERRIDDEN_ACPI_TABLE	(1<<8)
 #define TAINT_WARN			(1<<9)
 
-extern void dump_stack(void) __cold;
-
-enum {
-	DUMP_PREFIX_NONE,
-	DUMP_PREFIX_ADDRESS,
-	DUMP_PREFIX_OFFSET
-};
-extern void hex_dump_to_buffer(const void *buf, size_t len,
-				int rowsize, int groupsize,
-				char *linebuf, size_t linebuflen, bool ascii);
-extern void print_hex_dump(const char *level, const char *prefix_str,
-				int prefix_type, int rowsize, int groupsize,
-				const void *buf, size_t len, bool ascii);
-extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
-			const void *buf, size_t len);
-
 extern const char hex_asc[];
 #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
@@ -288,30 +207,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
 	return buf;
 }
 
-#define pr_emerg(fmt, arg...) \
-	printk(KERN_EMERG fmt, ##arg)
-#define pr_alert(fmt, arg...) \
-	printk(KERN_ALERT fmt, ##arg)
-#define pr_crit(fmt, arg...) \
-	printk(KERN_CRIT fmt, ##arg)
-#define pr_err(fmt, arg...) \
-	printk(KERN_ERR fmt, ##arg)
-#define pr_warning(fmt, arg...) \
-	printk(KERN_WARNING fmt, ##arg)
-#define pr_notice(fmt, arg...) \
-	printk(KERN_NOTICE fmt, ##arg)
-#define pr_info(fmt, arg...) \
-	printk(KERN_INFO fmt, ##arg)
-
-#ifdef DEBUG
-/* If you are writing a driver, please use dev_dbg instead */
-#define pr_debug(fmt, arg...) \
-	printk(KERN_DEBUG fmt, ##arg)
-#else
-#define pr_debug(fmt, arg...) \
-	({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; })
-#endif
-
 /*
  *      Display an IP address in readable format.
  */
include/linux/logging.h new file +139 -0

139 lines not on this page · raw message

include/linux/ratelimit.h deleted +0 -27
deleted file mode 100644
index 18a5b9b..0000000
@@ -1,27 +0,0 @@
-#ifndef _LINUX_RATELIMIT_H
-#define _LINUX_RATELIMIT_H
-#include <linux/param.h>
-
-#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ)
-#define DEFAULT_RATELIMIT_BURST 10
-
-struct ratelimit_state {
-	int interval;
-	int burst;
-	int printed;
-	int missed;
-	unsigned long begin;
-};
-
-#define DEFINE_RATELIMIT_STATE(name, interval, burst)		\
-		struct ratelimit_state name = {interval, burst,}
-
-extern int __ratelimit(struct ratelimit_state *rs);
-
-static inline int ratelimit(void)
-{
-	static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
-					DEFAULT_RATELIMIT_BURST);
-	return __ratelimit(&rs);
-}
-#endif
#23 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 15 lines · Joe Perches
Quoted 5 lines · Tim Hockin
    // this is the actual implementation
    extern void send_kmsg(int level, const char *fmt, ...);
    // this is a convenience wrapper, maybe not needed as they get combinatoric
    #define kmsg_err(fmt, ...) \
    	send_kmsg(KERN_ERROR, fmt, ##__VA_ARGS__)
Quoted 8 lines

inside a subsystem-specific header:

    #define mysubsys_kmsg_err(fmt, ...) \
    	kmsg_err("mysubsys:" fmt "\n", ##__VA_ARGS__)
  inside each subsystem-driver:
    #define mydriver_kmsg_err(fmt, ...) \
    	mysubsys_kmsg_err("mydriver:" fmt, ##__VA_ARGS__)
  then the driver just calls:
    mydriver_kmsg_err("something happened");
Quoted 2 lines

I think adding system/subsystem/driver prefixes
to function names is not good.

Eeek!

What is wrong with what we have already agreed to standardise on here people? dev_printk() for devices! It uniquely shows the device, what driver is bound to it (if any), the bus id, and everything else.

It's in a parseable, standard format, that everyone agreed a few years was going to be the way to go!

And now you want to create your own new one? Come on, please don't be that foolish. Please work with what we already have. Extend it or something to have these "magic tokens" that you all want to index off of, that's fine, I really could care less (and I really think it's going to be a pain in the end, does everyone forget how frickin fast this body of software moves?)

But whatever you do, don't create yet-another-printk-macro that you are going to want everyone to use in their drivers/modules. We've already done that, and we are still slowly converting people over to them (I did just that for a large number USB drivers just today...)

Work off of dev_printk() and friends, don't do something new.

thanks,

greg k-h

#24 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 4 lines · Greg KH

What is wrong with what we have already agreed to standardise on here people? dev_printk() for devices! It uniquely shows the device, what driver is bound to it (if any), the bus id, and everything else.

Part of the problem, imho, is the "if any" part. But I am more than happy to build on existing solutions. All the world is not a dev, though. I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

Tim

#25 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 11 lines · Tim Hockin
Quoted 4 lines · Greg KH

What is wrong with what we have already agreed to standardise on here people? dev_printk() for devices! It uniquely shows the device, what driver is bound to it (if any), the bus id, and everything else.

Part of the problem, imho, is the "if any" part. But I am more than happy to build on existing solutions. All the world is not a dev, though. I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

If I interpret Martins patches correctly he wants to be able to put add extended information to specific messages the kernel is printing. This is a good way to explain the rational of certain situations to people unwilling to read the sources ;)

I don't think that he wants to unify all the printk's in the system. I don't think that reporting all errors "in the same way as an ATA error" makes any sense. That would just lead to very stupid and unnatural messages for all errors that are not like "ATA errors". Annotation of existing errors is a much more flexible and feasible solution to that problem.

#26 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 14 lines · Jan Blunck
Quoted 11 lines · Tim Hockin
Quoted 4 lines · Greg KH

What is wrong with what we have already agreed to standardise on here people? dev_printk() for devices! It uniquely shows the device, what driver is bound to it (if any), the bus id, and everything else.

Part of the problem, imho, is the "if any" part. But I am more than happy to build on existing solutions. All the world is not a dev, though. I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

Quoted 5 lines

I don't think that he wants to unify all the printk's in the system. I don't think that reporting all errors "in the same way as an ATA error" makes any sense. That would just lead to very stupid and unnatural messages for all errors that are not like "ATA errors". Annotation of existing errors is a much more flexible and feasible solution to that problem.

Please don't misinterpret. I don't want to make other errors parse like an ATA error, I want to make the plumbing be parallel. I want one umbrella mechanism for reporting things that are more important than just-another-printk().

Because frankly, "parse dmesg" is a pretty crappy way to have to monitor your system for failures, and I am tired of explaining to people why we still do that.

Tim

#27 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Hi!

Quoted 6 lines
Quoted 5 lines

I don't think that he wants to unify all the printk's in the system. I don't think that reporting all errors "in the same way as an ATA error" makes any sense. That would just lead to very stupid and unnatural messages for all errors that are not like "ATA errors". Annotation of existing errors is a much more flexible and feasible solution to that problem.

Quoted 8 lines

Please don't misinterpret. I don't want to make other errors parse like an ATA error, I want to make the plumbing be parallel. I want one umbrella mechanism for reporting things that are more important than just-another-printk().

Because frankly, "parse dmesg" is a pretty crappy way to have to monitor your system for failures, and I am tired of explaining to people why we still do that.

"parse dmesg" does not work for monitoring your system for failures; dmesg buffer can overflow.

If something fails, you should get errno returned for userspace, and that's where you should be doing the monitoring.

So... what parts don't return enough information to userspace so that you need to parse dmesg? Lets fix them.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#28 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 17 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 5 lines

I don't think that he wants to unify all the printk's in the system. I don't think that reporting all errors "in the same way as an ATA error" makes any sense. That would just lead to very stupid and unnatural messages for all errors that are not like "ATA errors". Annotation of existing errors is a much more flexible and feasible solution to that problem.

Quoted 8 lines

Please don't misinterpret. I don't want to make other errors parse like an ATA error, I want to make the plumbing be parallel. I want one umbrella mechanism for reporting things that are more important than just-another-printk().

Because frankly, "parse dmesg" is a pretty crappy way to have to monitor your system for failures, and I am tired of explaining to people why we still do that.

Quoted 5 lines

"parse dmesg" does not work for monitoring your system for failures; dmesg buffer can overflow.

If something fails, you should get errno returned for userspace, and that's where you should be doing the monitoring.

Yes, but there are far to few errno's to identify the problem. Imagine
how many different causes can result in EIO. Or have you ever tried to find out why the crappy filesystem doesn't want to mount without looking into kernel messages - the returned errno is always the same :). So I don't think errno is a solution...

Quoted 2 lines

So... what parts don't return enough information to userspace so that you need to parse dmesg? Lets fix them.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#29 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Pavel Machek
Quoted 17 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 5 lines

I don't think that he wants to unify all the printk's in the system. I don't think that reporting all errors "in the same way as an ATA error" makes any sense. That would just lead to very stupid and unnatural messages for all errors that are not like "ATA errors". Annotation of existing errors is a much more flexible and feasible solution to that problem.

Quoted 8 lines

Please don't misinterpret. I don't want to make other errors parse like an ATA error, I want to make the plumbing be parallel. I want one umbrella mechanism for reporting things that are more important than just-another-printk().

Because frankly, "parse dmesg" is a pretty crappy way to have to monitor your system for failures, and I am tired of explaining to people why we still do that.

Quoted 8 lines

"parse dmesg" does not work for monitoring your system for failures; dmesg buffer can overflow.

If something fails, you should get errno returned for userspace, and that's where you should be doing the monitoring.

So... what parts don't return enough information to userspace so that you need to parse dmesg? Lets fix them.

If I get a DMA timeout on my disk, I want to know about it. If I get an OOM kill, I want to know about it. Etc.

I *don't* want every application to participate in system monitoring, and that's what it seems you're suggesting. I want a monitoring daemon which is notified of important system events. We like to report these things in various ways, including squirting them out onto the network.

I *don't* want to run regexes against dmesg or /var/log/messages or /var/log/kernel every N seconds, that's just a gross hack. I really want first-class notifications of significant events. I don't mind having to do parsing of events - as I said before, they can even be loosely structured strings. They just need to be more important than a plain old printk(), and preferably come through a different channel.

I understand that many users will not want this level of monitoring, and that's why it should be flexible enough to devolve into printk(). But we have thousands of systems. I need a better view of what is happening.

Tim

#30 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Tim Hockin
Quoted 8 lines · Tim Hockin
Quoted 4 lines · Greg KH

What is wrong with what we have already agreed to standardise on here people? dev_printk() for devices! It uniquely shows the device, what driver is bound to it (if any), the bus id, and everything else.

Part of the problem, imho, is the "if any" part. But I am more than happy to build on existing solutions. All the world is not a dev, though.

No, but way over half the kernel is.

Quoted 4 lines

I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

That's great, then create something that can handle both! Don't throw away some wonderful information that way over half the kernel has access to just because the minority doesn't. That would mean that we would loose information in those drivers overall.

thanks,

greg k-h

#31 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 9 lines · Greg KH
Quoted 4 lines

I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

That's great, then create something that can handle both! Don't throw away some wonderful information that way over half the kernel has access to just because the minority doesn't. That would mean that we would loose information in those drivers overall.

Sorry, I never meant to imply that dev_printk() was to be ignored, my examples was meant to be trivial to demonstrate :) dev_printk() is good. We should keep it :)

#32 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 6 lines · Tim Hockin
Quoted 5 lines · Greg KH
Quoted 4 lines

I'd like to be able to report something like an OOM kill in (roughly) the same way as an ATA error, and I want (though could be talked out of) a way to tell these "events" (for lack of a better word) apart from plain-old-printk()s.

Quoted 8 lines
Quoted 4 lines

That's great, then create something that can handle both! Don't throw away some wonderful information that way over half the kernel has access to just because the minority doesn't. That would mean that we would loose information in those drivers overall.

Sorry, I never meant to imply that dev_printk() was to be ignored, my examples was meant to be trivial to demonstrate :) dev_printk() is good. We should keep it :)

The invention of dev_printk was a good thing. It adds structure to the messages if it is about a device. Before we had a simple printk that did or did not include information about the device driver and the device name. dev_printk makes sure that this information is always added. BUT, what dev_printk does not do is to make sure that the message can be uniquely identified so that the description of the message can be found in the message catalog. Our approach is to combine the driver name and a simple index into a message tag. The original dev_printk remains almost unchanged. A typical hunk in the code looks like this:

@@ -24,8 +27,8 @@ static int zfcp_ccw_probe(struct ccw_dev

        down(&zfcp_data.config_sema);
        if (zfcp_adapter_enqueue(ccw_device)) {
-               dev_err(&ccw_device->dev,
-                       "Setup of data structures failed.\n");
+               kmsg_dev_err(73, &ccw_device->dev,
+                            "Setup of data structures failed.\n");
                retval = -EINVAL;
        }
        up(&zfcp_data.config_sema);

The kmsg_dev_printk still has almost the same structure, only the message id is added. There is one real difference though:
the driver name is specified with KMSG_COMPONENT and not via dev_driver_string(dev). We do that so that the kmsg-doc script can actually find the driver name. The dev_driver_string(dev) is dynamic and a static tool has a hard time to find the actual driver string.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Martin Schwidefsky
Quoted 5 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Rusty.

#34 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

But there are a number of places that have different strings for the same meaning: "Can't" vs "can't" vs "can not" vs "failed to", etc.

This is a big part of what hurts us - you end up with lots of loose regexes when parsing logs.

Tim

Quoted 18 lines · Rusty Russell
Quoted 5 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#35 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Hi!

Quoted 2 lines

But there are a number of places that have different strings for the same meaning: "Can't" vs "can't" vs "can not" vs "failed to", etc.

Do you have examples?

That wastes space in bzImage (and hints of duplicated code), so we may want to fix it anyway.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#36 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 9 lines · Pavel Machek

Hi!

Quoted 2 lines

But there are a number of places that have different strings for the same meaning: "Can't" vs "can't" vs "can not" vs "failed to", etc.

Do you have examples?

That wastes space in bzImage (and hints of duplicated code), so we may want to fix it anyway.

I can look for the specific examples. I just saw the regexes we use this week and was taken aback at how they have been loosened for these sorts of cases.

#37 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Tim Hockin
Quoted 5 lines · On Wednesday 13 August 2008 17:04:11 Tim Hockin wrote:

But there are a number of places that have different strings for the same meaning: "Can't" vs "can't" vs "can not" vs "failed to", etc.

This is a big part of what hurts us - you end up with lots of loose regexes when parsing logs.

Well, if they're to be the same messages under the manual-numbering scheme, someone has to verify that they are really the same anyway. Not much more work to simply fix them in that case, is it?

If it improves normal kernel messages, then everyone wins. Rusty.

#38 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 8 lines · Rusty Russell
Quoted 2 lines · On Wednesday 13 August 2008 17:04:11 Tim Hockin wrote:

But there are a number of places that have ...Well, if they're to be the same messages under the manual-numbering scheme,

someone has to verify that they are really the same anyway. Not much more work to simply fix them in that case, is it?

If it improves normal kernel messages, then everyone wins.

Oh, I agree with that. I personally don't care much for the msg ID part of this patch (I mean I don't care either way). It might be nice to have man pages, but I just see it becoming out of sync, duplicate numbers, etc.

What I want to see is the elevation of these call-sites from "it's just a printk()" to "it's a report-worthy event and part of our user<->kernel API". I want people to add them when it's appropriate and then not change the strings later. I don't care if, in the end, they are structured strings. I do care if I have to run dozens of regexes against thousands of log-lines on thousands of systems.

:)

Tim

#39 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 6 lines · Tim Hockin
Quoted 4 lines · Rusty Russell
Quoted 2 lines · On Wednesday 13 August 2008 17:04:11 Tim Hockin wrote:

But there are a number of places that have ...Well, if they're to be the same messages under the manual-numbering scheme,

Quoted 8 lines
Quoted 4 lines

someone has to verify that they are really the same anyway. Not much more work to simply fix them in that case, is it?

If it improves normal kernel messages, then everyone wins.

Oh, I agree with that. I personally don't care much for the msg ID part of this patch (I mean I don't care either way). It might be nice to have man pages, but I just see it becoming out of sync, duplicate numbers, etc.

No, the kmsg-doc script will prevent that the kmsg message will become of of sync and it checks for duplicate numbers. The idea here is that the kmsg man pages are generated with the kernel compile (just try it with "make D=2").

Quoted 8 lines

What I want to see is the elevation of these call-sites from "it's just a printk()" to "it's a report-worthy event and part of our user<->kernel API". I want people to add them when it's appropriate and then not change the strings later. I don't care if, in the end, they are structured strings. I do care if I have to run dozens of regexes against thousands of log-lines on thousands of systems.

:)

Yes, and this has already happened with the s390 device driver messages. With the conversion to kmsg our developers removed a lot of crud from the code, this alone makes it worthwhile.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Rusty Russell
Quoted 10 lines · Rusty Russell
Quoted 5 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

First, how do you do that with the C preprocessor? Second the kmsg-doc script will check that the message format strings match if a kmsg with a specific id is used in multiple locations.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 9 lines · On Friday 15 August 2008 03:07:03 Martin Schwidefsky wrote:
Quoted 8 lines · Rusty Russell
Quoted 6 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Quoted 8 lines
Quoted 4 lines

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

First, how do you do that with the C preprocessor? Second the kmsg-doc script will check that the message format strings match if a kmsg with a specific id is used in multiple locations.

Well, why would you do it with the preprocessor? It's simplest to spit it out at runtime.

The (offline) catalogger will need to generate them, of course. Rusty.

#42 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 15 lines · Rusty Russell
Quoted 14 lines · On Friday 15 August 2008 03:07:03 Martin Schwidefsky wrote:
Quoted 12 lines · Rusty Russell
Quoted 6 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Quoted 6 lines
Quoted 3 lines

First, how do you do that with the C preprocessor? Second the kmsg-doc script will check that the message format strings match if a kmsg with a specific id is used in multiple locations.

Well, why would you do it with the preprocessor? It's simplest to spit it out at runtime.

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

Quoted 2 lines

The (offline) catalogger will need to generate them, of course. Rusty.

Sounds doable to me.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 10 lines · Martin Schwidefsky
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

Tim

#44 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

This is really an easy thing to do.
It can be achieved without a huge retro-fit.
It can happen even without yet another macro.
(Not saying that there should not be a new macro or new function, just that we can enjoy unique message IDs without those mechanisms.)

Quoted 5 lines · Martin Schwidefsky
Quoted 5 lines

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

Point to note: the message tag has to be unique.
The tag is what's relevant, what gets catalogued.

I don't really see the value of a hash per se.
What Martin has suggested (unless I have misunderstood) is the driver name combined with some index number ==> unique msg id. That's not exactly a "hash". (One can generate a hash from it, but why bother? You've got a unique string already.)

Quoted 2 lines · Then Tim Hockin

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

Whether hashed or not, what's needed is premeditated reporting, intentional dividing between variable content (like device ID) and the explanatory text arround it. Prefix each line with a token (or as most are calling it, a "tag") that can be looked up off-line.

I hope no one is thinking gettext in this thread. Don't clutter the kernel with something like gettext.

And don't burden the kernel with run-time text crunching. Message codes go in when the module is written. They get looked up either in user space or off-line. Easy! Almost trivial!

-- R; <><

#45 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Tim Hockin
Quoted 8 lines · On Sunday 17 August 2008 06:40:50 Tim Hockin wrote:

On Sat, Aug 16, 2008 at 10:49 AM, Martin Schwidefsky

Quoted 5 lines · <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Quoted 8 lines
Quoted 5 lines

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

You need to catalogue them all anyway, so you can detect clashes at build time. Yes, you have to change the new string in that case, but that's easy.

And the number changing as the message changes is arguably a feature. You shouldn't (and we generally don't) idly change kernel messages.

Rusty.

#46 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 11 lines · Rusty Russell
Quoted 8 lines
Quoted 5 lines

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

You need to catalogue them all anyway, so you can detect clashes at build time. Yes, you have to change the new string in that case, but that's easy.

Is the suggestion that in case of a clash just change the message string slightly to avoid the clash ?

Quoted 2 lines

And the number changing as the message changes is arguably a feature. You shouldn't (and we generally don't) idly change kernel messages.

This is very true. If a message is touched most likely the message description has to be changed as well. If the message hash then changes the tools can warn about it. The small thing now only is the matter of actually implementing the hash and changing the script to work on them..

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Tim Hockin
Quoted 5 lines · Tim Hockin
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Quoted 8 lines
Quoted 5 lines

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

The only problem here is trivial change like typos. Then the hash changes although the message is semantically still the same. If the message really changes, its id should change as well.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 12 lines · Martin Schwidefsky
Quoted 11 lines · Tim Hockin
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Ok, so a specialized version of printk will do the work to calculate the hash. Only, what will we do if there ever is a conflict? The message tag has to be unique. The shorter the hash is, the more likely a collision gets. Don't know if 6 hash digits is enough to just ignore the problem.

Quoted 6 lines
Quoted 2 lines

And if you ever need to change the text that is in the format string? The hash changes. That seems exactly counter to your goal...

The only problem here is trivial change like typos. Then the hash changes although the message is semantically still the same. If the message really changes, its id should change as well.

That's what I meant. Never underestimate the urge to fix the printk(), because "hey, it's JUST A PRINTK". That's one of my motivations - to make it no longer just a printk.

#49 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Rusty Russell
Quoted 4 lines · Rusty Russell

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

I second this suggestion (or propose something like it). A short hash or even an index into some off-line table lets the user hit the right page when looking for an explanation.

I've been using a similar (and perhaps ugly to some eyes) numeric message catalog for years (with token substitution and all). The catalogs can be translated and then replaced with local language so the users don't have to learn English (or French, or German, or Japanese, or Chinese).

-- R; <><

#50 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 8 lines · Rick Troth
Quoted 3 lines · Rusty Russell

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

I second this suggestion (or propose something like it). A short hash or even an index into some off-line table lets the user hit the right page when looking for an explanation.

The kmsg id is just that, an index into the table of message for a particular component.

Quoted 5 lines

I've been using a similar (and perhaps ugly to some eyes) numeric message catalog for years (with token substitution and all). The catalogs can be translated and then replaced with local language so the users don't have to learn English (or French, or German, or Japanese, or Chinese).

That is what we are trying to achieve as well.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

In reply to Rusty Russell
Quoted 10 lines · Rusty Russell
Quoted 5 lines · On Thursday 31 July 2008 02:56:57 Martin Schwidefsky wrote:

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

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.

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

If we go with hashes there is one more thing: kmsg(0, <string>) The variant where we manually assign the message ids knows about the "special" id 0. There is no documentation required for id 0 and none is wanted. If we replace the manual ids with hashes this will get lost. You could argue that a kmsg with id 0 is a normal printk so why not just use printk? What is lost is the information that this printk has been found to be not important enough to be documented.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 6 lines · On Tuesday 26 August 2008 01:56:30 Martin Schwidefsky wrote:
Quoted 4 lines · Rusty Russell

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Quoted 7 lines

If we go with hashes there is one more thing: kmsg(0, <string>) The variant where we manually assign the message ids knows about the "special" id 0. There is no documentation required for id 0 and none is wanted. If we replace the manual ids with hashes this will get lost. You could argue that a kmsg with id 0 is a normal printk so why not just use printk? What is lost is the information that this printk has been found to be not important enough to be documented.

Hmm, #define KERN_IGNORE KERN_DEBUG?

Rusty.

#53 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 15 lines · Rusty Russell
Quoted 6 lines · On Tuesday 26 August 2008 01:56:30 Martin Schwidefsky wrote:
Quoted 4 lines · Rusty Russell

Can you hash the format string to generate the id? 6 hex digits should be enough, and your tool can check for clashes. As it's bad form to have identical strings for different semantics anyway, this seems to make sense.

Quoted 7 lines

If we go with hashes there is one more thing: kmsg(0, <string>) The variant where we manually assign the message ids knows about the "special" id 0. There is no documentation required for id 0 and none is wanted. If we replace the manual ids with hashes this will get lost. You could argue that a kmsg with id 0 is a normal printk so why not just use printk? What is lost is the information that this printk has been found to be not important enough to be documented.

Quoted 1 line

Hmm, #define KERN_IGNORE KERN_DEBUG?

Hmm, shouldn't KERN_xxx levels be independent of the special id 0?

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 4 lines · On Monday 01 September 2008 22:28:50 Martin Schwidefsky wrote:
Quoted 1 line · Rusty Russell

Hmm, #define KERN_IGNORE KERN_DEBUG?

Hmm, shouldn't KERN_xxx levels be independent of the special id 0?

I don't know. Why should something be untranslatable?

Rusty.

#55 lore raw

Re: [patch 1/3] kmsg: Kernel message catalog macros.

Quoted 7 lines · Rusty Russell
Quoted 4 lines · On Monday 01 September 2008 22:28:50 Martin Schwidefsky wrote:
Quoted 1 line · Rusty Russell

Hmm, #define KERN_IGNORE KERN_DEBUG?

Hmm, shouldn't KERN_xxx levels be independent of the special id 0?

I don't know. Why should something be untranslatable?

Do we really want to require that every message printed with the kmsg macros has to be documented? I don't think this is a good idea. The special id 0 is there to tell the script not to bother with a particular message, e.g. the lovely "module <x> has been loaded" messages. The message still can be translated.

Signature · 4 lines
blue skies,
  Martin.

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

PATCH 2/3 kmsg: Kernel message catalog script.

In reply to Martin Schwidefsky

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

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 three places, the source file where the kmsg call is located, in the architecture dependent file Documentation/kmsg/$ARCH/<component> and in the common file Documentation/kmsg/<component>.

The kmsg check is invoked with "make D=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 D=2" and reads the source files for all built objects, looks up the message description and writes a man page to $(objtree)/man.

---

 Makefile               |   16 ++
 scripts/Makefile.build |   14 +
 scripts/kmsg-doc       |  366 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 396 insertions(+)
Makefile +16 -0
Index: linux-2.6/Makefile
===================================================================
@@ -63,6 +63,20 @@ ifndef KBUILD_CHECKSRC
   KBUILD_CHECKSRC = 0
 endif
 
+# Call message checker as part of the C compilation
+#
+# Use 'make D=1' to enable checking
+# Use 'make D=2' to create the message catalog
+
+ifdef D
+  ifeq ("$(origin D)", "command line")
+    KBUILD_KMSG_CHECK = $(D)
+  endif
+endif
+ifndef KBUILD_KMSG_CHECK
+  KBUILD_KMSG_CHECK = 0
+endif
+
 # Use make M=dir to specify directory of external module to build
 # Old syntax make ... SUBDIRS=$PWD is still supported
 # Setting the environment variable KBUILD_EXTMOD take precedence
@@ -321,6 +335,7 @@ PERL		= perl
 CHECK		= sparse
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
+KMSG_CHECK	= $(srctree)/scripts/kmsg-doc
 MODFLAGS	= -DMODULE
 CFLAGS_MODULE   = $(MODFLAGS)
 AFLAGS_MODULE   = $(MODFLAGS)
@@ -355,6 +370,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODU
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
+export KBUILD_KMSG_CHECK KMSG_CHECK
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
scripts/kmsg-doc new file +366 -0

366 lines not on this page · raw message

scripts/Makefile.build +14 -0
Index: linux-2.6/scripts/Makefile.build
===================================================================
@@ -211,12 +211,14 @@ endef
 # Built-in and composite module parts
 $(obj)/%.o: $(src)/%.c FORCE
 	$(call cmd,force_checksrc)
+	$(call cmd,force_check_kmsg)
 	$(call if_changed_rule,cc_o_c)
 
 # Single-part modules are special since we need to mark them in $(MODVERDIR)
 
 $(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
 	$(call cmd,force_checksrc)
+	$(call cmd,force_check_kmsg)
 	$(call if_changed_rule,cc_o_c)
 	@{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
 
@@ -339,6 +341,18 @@ $(multi-used-m) : %.o: $(multi-objs-m) F
 
 targets += $(multi-used-y) $(multi-used-m)
 
+# kmsg check tool
+ifneq ($(KBUILD_KMSG_CHECK),0)
+  ifeq ($(KBUILD_KMSG_CHECK),2)
+    kmsg_cmd := print
+    quiet_cmd_force_check_kmsg = KMSG_PRINT $<
+    $(shell [ -d $(objtree)/man ] || mkdir -p $(objtree)/man)
+  else
+    kmsg_cmd := check
+    quiet_cmd_force_check_kmsg = KMSG_CHECK $<
+  endif
+  cmd_force_check_kmsg = $(KMSG_CHECK) $(kmsg_cmd) $(CC) $(c_flags) $< ;
+endif
 
 # Descending
 # ---------------------------------------------------------------------------
Signature · 4 lines
blue skies,
   Martin.

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

Re: [patch 2/3] kmsg: Kernel message catalog script.

Quoted 33 lines

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

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 three places, the source file where the kmsg call is located, in the architecture dependent file Documentation/kmsg/$ARCH/<component> and in the common file Documentation/kmsg/<component>.

The kmsg check is invoked with "make D=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.

Quoted 3 lines

The kmsg man page creation is invoked with "make D=2" and reads the source files for all built objects, looks up the message description and writes a man page to $(objtree)/man.

I don't know message id numbering is good or bad.
but I like a check script/Makefile of printk format changing. because many people(include me :) often forget printk/Documentation change.

Thanks

#58 lore raw

RE: [patch 2/3] kmsg: Kernel message catalog script.

In reply to Martin Schwidefsky
Quoted 25 lines

/*?
* 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 three places, the source file where the kmsg call is located, in the architecture dependent file Documentation/kmsg/$ARCH/<component> and in the common file Documentation/kmsg/<component>.

The kmsg check is invoked with "make D=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.

Quoted 3 lines

The kmsg man page creation is invoked with "make D=2" and reads the source files for all built objects, looks up the message description and writes a man page to $(objtree)/man.

I think it is good to number the message. It might be gospel for
providing with the support service for the corporation.
However, there is a problem of the scale in numbering of not only a
specific module but also all modules to the message. (There might be at least 34000 relating messages or more. )

It introduces the following Web sites as a approach that arranges
the message on a Japanese Web site though it apologizes.

OSS Message Pedia
http://ossmpedia.org/
(Attention: This Web site is being written in Japanese. )

Thanks

--
NISHIIE Takashi

#59 lore raw

RE: [patch 2/3] kmsg: Kernel message catalog script.

Quoted 3 lines · Takashi Nishiie

However, there is a problem of the scale in numbering of not only a
specific module but also all modules to the message. (There might be at least 34000 relating messages or more. )

Could you explain this a bit more? I'm not sure I understood it correctly. I'm unsure about the term "relating message". A single ksmg message can be printed from several modules if it is the same message. Do you want to create a list of modules that issue a particular message?

Signature · 4 lines
blue skies,
  Martin.

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

PATCH 3/3 kmsg: convert xpram messages to kmsg api.

In reply to Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>

---

 Documentation/kmsg/s390/xpram |   54 ++++++++++++++++++++++++++++++++++++++++++
 drivers/s390/block/xpram.c    |   41 ++++++++++++++-----------------
 2 files changed, 73 insertions(+), 22 deletions(-)
Documentation/kmsg/s390/xpram new file +54 -0
Index: linux-2.6/Documentation/kmsg/s390/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 compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * 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 compiled as a separate module,
+ * unload the xpram module and load it again with an appropriate value
+ * for the 'sizes' module parameter. If the XPRAM device driver has been
+ * compiled into the kernel, adjust the 'xpram.parts' parameter in the
+ * kernel 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.
+ */
+
drivers/s390/block/xpram.c +19 -22

86 lines not on this page · raw message

Signature · 4 lines
blue skies,
   Martin.

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

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 14 lines · Martin Schwidefsky

From: Martin Schwidefsky <[email protected]>

---

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

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram line 2

Quoted 2 lines
Documentation/kmsg/s390/xpram new file +2 -0
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1

Ick, so you are going to have to define a message number per file? How is that going to work, it looks like you use ids 0-2 below in the .c file, yet in this documentation file they are 1-3. Off by one somewhere? :)

Quoted 6 lines
Documentation/kmsg/s390/xpram new file +6 -0
+ * 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

Documentation/kmsg/s390/xpram line 18

Quoted 10 lines
Documentation/kmsg/s390/xpram new file +10 -0
+ * or with the 'xpram.parts' kernel parameter must be an integer in the
+ * range 1 to 32. The XPRAM device driver created a maximum of 32 partitions
+ * that are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * parameter line and restart Linux.
+ */

Any way to put this stuff in the .c file itself? It's hard enough getting people to update Documentation/ABI/, knowing to go modify something else in the Documentation directory is going to be _very_ difficult.

Documentation/kmsg/s390/xpram line 19

Quoted 2 lines
Documentation/kmsg/s390/xpram new file +1 -0
+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Documentation/kmsg/s390/xpram

Quoted 5 lines
Documentation/kmsg/s390/xpram new file +1 -1
 	/* 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;

Magic number "1" here? See comment above about this.

thanks,

greg k-h

#62 lore raw

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 13 lines · Greg KH

Documentation/kmsg/s390/xpram line 2

Quoted 7 lines · Martin Schwidefsky

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram new file +2 -0
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1

Ick, so you are going to have to define a message number per file? How is that going to work, it looks like you use ids 0-2 below in the .c file, yet in this documentation file they are 1-3. Off by one somewhere? :)

The kmsg number 0 is special, the message tag will not include the message number for id 0. And the script won't complain that the message description is missing.
And yes, we WANT to define the message numbers per kmsg component.

Quoted 17 lines
Quoted 6 lines
Documentation/kmsg/s390/xpram new file +6 -0
+ * 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

Documentation/kmsg/s390/xpram line 18

Quoted 10 lines
Documentation/kmsg/s390/xpram new file +10 -0
+ * or with the 'xpram.parts' kernel parameter must be an integer in the
+ * range 1 to 32. The XPRAM device driver created a maximum of 32 partitions
+ * that are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * parameter line and restart Linux.
+ */
Quoted 4 lines

Any way to put this stuff in the .c file itself? It's hard enough getting people to update Documentation/ABI/, knowing to go modify something else in the Documentation directory is going to be _very_ difficult.

Yes, already implemented. Just put the comment anywhere in the .c file where the message is printed. The Documentation/kmsg directory is just an additional option.

Quoted 7 lines

Documentation/kmsg/s390/xpram line 19

Quoted 3 lines
Documentation/kmsg/s390/xpram new file +1 -0
+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.
2) we want to be able to use the same kmsg component in multiple .c files.

Quoted 7 lines

Documentation/kmsg/s390/xpram

Quoted 5 lines
Documentation/kmsg/s390/xpram new file +1 -1
 	/* 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;

Magic number "1" here? See comment above about this.

This is just the kmsg printk for xpram.1, see comment above about id 0.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 15 lines · Martin Schwidefsky
Quoted 13 lines · Greg KH

Documentation/kmsg/s390/xpram line 2

Quoted 7 lines · Martin Schwidefsky

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram new file +2 -0
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1

Ick, so you are going to have to define a message number per file? How is that going to work, it looks like you use ids 0-2 below in the .c file, yet in this documentation file they are 1-3. Off by one somewhere? :)

Quoted 3 lines

The kmsg number 0 is special, the message tag will not include the message number for id 0. And the script won't complain that the message description is missing.

Was "0 is special" defined anywhere that I missed?

Quoted 1 line

And yes, we WANT to define the message numbers per kmsg component.

But again, you have to manually match up numbers by hand, that's prone to get messy very quickly.

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Documentation/kmsg/s390/xpram new file +16 -0
+ * 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 compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * parameter line and restart Linux.
+ */
Quoted 8 lines
Quoted 4 lines

Any way to put this stuff in the .c file itself? It's hard enough getting people to update Documentation/ABI/, knowing to go modify something else in the Documentation directory is going to be _very_ difficult.

Yes, already implemented. Just put the comment anywhere in the .c file where the message is printed. The Documentation/kmsg directory is just an additional option.

Why not have your example show this?

Quoted 9 lines
Quoted 5 lines

Documentation/kmsg/s390/xpram line 19

Quoted 1 line
Documentation/kmsg/s390/xpram new file +1 -0
+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.

Um, isn't that the point? If the code structure changes, then perhaps the message also should change? If not, it's trival to adjust.

Quoted 2 lines

2) we want to be able to use the same kmsg component in multiple .c files.

Why would this matter? It's just a "tag", who cares about the actual name?

thanks,

greg k-h

#64 lore raw

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 16 lines · Greg KH
Quoted 15 lines · Martin Schwidefsky
Quoted 13 lines · Greg KH

Documentation/kmsg/s390/xpram line 2

Quoted 7 lines · Martin Schwidefsky

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram new file +2 -0
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1

Ick, so you are going to have to define a message number per file? How is that going to work, it looks like you use ids 0-2 below in the .c file, yet in this documentation file they are 1-3. Off by one somewhere? :)

Quoted 5 lines
Quoted 3 lines

The kmsg number 0 is special, the message tag will not include the message number for id 0. And the script won't complain that the message description is missing.

Was "0 is special" defined anywhere that I missed?

From the patch description of the kernel message catalog script:

The kmsg check is invoked with "make D=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.

Quoted 4 lines
Quoted 1 line

And yes, we WANT to define the message numbers per kmsg component.

But again, you have to manually match up numbers by hand, that's prone to get messy very quickly.

The kmsg catalog script if called with "make D=1" will check all the messages in the current build. When a message is introduced you have to pick a free number. The checking is done automatically and errors will be caught without trouble.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 6 lines
Documentation/kmsg/s390/xpram new file +6 -0
+ * 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

Documentation/kmsg/s390/xpram line 18

Quoted 10 lines
Documentation/kmsg/s390/xpram new file +10 -0
+ * or with the 'xpram.parts' kernel parameter must be an integer in the
+ * range 1 to 32. The XPRAM device driver created a maximum of 32 partitions
+ * that are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * parameter line and restart Linux.
+ */

Any way to put this stuff in the .c file itself? It's hard enough getting people to update Documentation/ABI/, knowing to go modify something else in the Documentation directory is going to be _very_ difficult.

Quoted 5 lines
Quoted 3 lines

Yes, already implemented. Just put the comment anywhere in the .c file where the message is printed. The Documentation/kmsg directory is just an additional option.

Why not have your example show this?

Ok, fair enough.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Documentation/kmsg/s390/xpram line 19

Quoted 1 line
Documentation/kmsg/s390/xpram new file +1 -0
+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Quoted 6 lines
Quoted 3 lines

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.

Um, isn't that the point? If the code structure changes, then perhaps the message also should change? If not, it's trival to adjust.

NO! The message nor the message tag should change if the message semantically still reports the same thing. If the meaning of the message changes then change the message AND the message tag.

Quoted 5 lines
Quoted 2 lines

2) we want to be able to use the same kmsg component in multiple .c files.

Why would this matter? It's just a "tag", who cares about the actual name?

The actual name is not really important, but if the name is choosen wisely it does convey information. Guess what "dasd.17" tells you something about the dasd driver, "zfcp.42" about the zfcp driver and so on. The code structure should not dictate how the message tag is created.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 23 lines · Martin Schwidefsky
Quoted 21 lines · Greg KH
Quoted 15 lines · Martin Schwidefsky
Quoted 13 lines · Greg KH

Documentation/kmsg/s390/xpram line 2

Quoted 7 lines · Martin Schwidefsky

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram new file +2 -0
@@ -0,0 +1,54 @@
+/*?
+ * Tag: xpram.1

Ick, so you are going to have to define a message number per file? How is that going to work, it looks like you use ids 0-2 below in the .c file, yet in this documentation file they are 1-3. Off by one somewhere? :)

Quoted 3 lines

The kmsg number 0 is special, the message tag will not include the message number for id 0. And the script won't complain that the message description is missing.

Was "0 is special" defined anywhere that I missed?

Quoted 7 lines
Quoted 1 line

From the patch description of the kernel message catalog script:

The kmsg check is invoked with "make D=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.

Ok, but you don't describe messages with "0" in them :)

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

Documentation/kmsg/s390/xpram line 3

Quoted 1 line
Documentation/kmsg/s390/xpram new file +1 -0
+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.

Quoted 6 lines
Quoted 2 lines

Um, isn't that the point? If the code structure changes, then perhaps the message also should change? If not, it's trival to adjust.

NO! The message nor the message tag should change if the message semantically still reports the same thing. If the meaning of the message changes then change the message AND the message tag.

Why can't the message reporting change? What's the reluctance for change here for something that did happen to move to a different file? It shouldn't matter _at all_ as you are only looking at the tags/messages for a specific kernel version to ensure they match up. Any future kernel version might have different ones.

It's not like once you write a message/tag it will stay that way fixed for all time, that's just not going to fly with the way the Linux kernel is developed.

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

2) we want to be able to use the same kmsg component in multiple .c files.

Why would this matter? It's just a "tag", who cares about the actual name?

The actual name is not really important, but if the name is choosen wisely it does convey information. Guess what "dasd.17" tells you something about the dasd driver, "zfcp.42" about the zfcp driver and so on. The code structure should not dictate how the message tag is created.

The message tag should not dictate anything except how to look it up somehow. So it doesn't matter if the name changes, as long as the ability to get the real information is still there.

So the kernel could change the tags every other release and there would be no problem.

thanks,

greg k-h

#66 lore raw

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 9 lines · Greg KH
Quoted 7 lines
Quoted 1 line

From the patch description of the kernel message catalog script:

The kmsg check is invoked with "make D=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.

Ok, but you don't describe messages with "0" in them :)

I'll add the creation of a howto to my to-do list that describes how to work with kmsg.

Quoted 23 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.

Quoted 6 lines
Quoted 2 lines

Um, isn't that the point? If the code structure changes, then perhaps the message also should change? If not, it's trival to adjust.

NO! The message nor the message tag should change if the message semantically still reports the same thing. If the meaning of the message changes then change the message AND the message tag.

Why can't the message reporting change? What's the reluctance for change here for something that did happen to move to a different file? It shouldn't matter _at all_ as you are only looking at the tags/messages for a specific kernel version to ensure they match up. Any future kernel version might have different ones.

Quoted 3 lines

It's not like once you write a message/tag it will stay that way fixed for all time, that's just not going to fly with the way the Linux kernel is developed.

The message tag should uniquely identify the message so that the translation projects have something to work with. If we keep changing the message tag with each kernel release that will create a huge effort to keep track of the messages.

Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

2) we want to be able to use the same kmsg component in multiple .c files.

Why would this matter? It's just a "tag", who cares about the actual name?

The actual name is not really important, but if the name is choosen wisely it does convey information. Guess what "dasd.17" tells you something about the dasd driver, "zfcp.42" about the zfcp driver and so on. The code structure should not dictate how the message tag is created.

Quoted 6 lines

The message tag should not dictate anything except how to look it up somehow. So it doesn't matter if the name changes, as long as the ability to get the real information is still there.

So the kernel could change the tags every other release and there would be no problem.

I think the unique message ids are very important. If we change them all the time this would severly limit the value of the kernel message catalog.

Signature · 4 lines
blue skies,
  Martin.

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

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 24 lines · Martin Schwidefsky
Quoted 23 lines · Greg KH
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

+#define KMSG_COMPONENT "xpram"

Can't you just use KBUILD_MODULE_NAME instead? That makes it one less thing you have to define in the code (and forget about when moving files around or cut-and-pasting).

Two reason why we don't want to use KBUILD_MODULE_NAME:
1) the message tag (message component + message id) should never change, if you change the code structure the module name might change as well.

Quoted 6 lines
Quoted 2 lines

Um, isn't that the point? If the code structure changes, then perhaps the message also should change? If not, it's trival to adjust.

NO! The message nor the message tag should change if the message semantically still reports the same thing. If the meaning of the message changes then change the message AND the message tag.

Why can't the message reporting change? What's the reluctance for change here for something that did happen to move to a different file? It shouldn't matter _at all_ as you are only looking at the tags/messages for a specific kernel version to ensure they match up. Any future kernel version might have different ones.

Quoted 8 lines
Quoted 3 lines

It's not like once you write a message/tag it will stay that way fixed for all time, that's just not going to fly with the way the Linux kernel is developed.

The message tag should uniquely identify the message so that the translation projects have something to work with. If we keep changing the message tag with each kernel release that will create a huge effort to keep track of the messages.

But that's the point here. The kernel does change a lot with each release (you have seen the numbers, right?) And if a change happens, then the message also needs to change as something changed! Why would you think that these messages could be static till the end of time? That's not how the kernel works.

Quoted 16 lines
Quoted 16 lines
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

2) we want to be able to use the same kmsg component in multiple .c files.

Why would this matter? It's just a "tag", who cares about the actual name?

The actual name is not really important, but if the name is choosen wisely it does convey information. Guess what "dasd.17" tells you something about the dasd driver, "zfcp.42" about the zfcp driver and so on. The code structure should not dictate how the message tag is created.

The message tag should not dictate anything except how to look it up somehow. So it doesn't matter if the name changes, as long as the ability to get the real information is still there.

Quoted 6 lines
Quoted 2 lines

So the kernel could change the tags every other release and there would be no problem.

I think the unique message ids are very important. If we change them all the time this would severly limit the value of the kernel message catalog.

Again, they will be unique, but again, they will change as the kernel changes, they will have to.

thanks,

greg k-h

#68 lore raw

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

In reply to Martin Schwidefsky

Hi!

Quoted 21 lines

From: Martin Schwidefsky <[email protected]>

---

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

Index: linux-2.6/Documentation/kmsg/s390/xpram
===================================================================

Documentation/kmsg/s390/xpram new file +7 -0
@@ -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:

Documentation/kmsg/s390/xpram line 17

Quoted 10 lines
Documentation/kmsg/s390/xpram new file +10 -0
+ * The number of XPRAM partitions specified for the 'devs' module parameter
+ * or with the 'xpram.parts' kernel parameter must be an integer in the
+ * range 1 to 32. The XPRAM device driver created a maximum of 32 partitions
+ * that are probably not configured as intended.
+ * User action:
+ * If the XPRAM device driver has been compiled as a separate module,
+ * unload the module and load it again with a correct value for the
+ * 'devs' module parameter. If the XPRAM device driver has been compiled
+ * into the kernel, correct the 'xpram.parts' parameter in the kernel
+ * parameter line and restart Linux.

It is "Kernel command line". Plus, I do not think I find "User action" section really helpful here.

...user that does not understand what "between 1 and 32 means" is unlikely to know if the driver is built-in or module...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#69 lore raw

Re: [patch 3/3] kmsg: convert xpram messages to kmsg api.

Quoted 2 lines · Pavel Machek

It is "Kernel command line". Plus, I do not think I find "User action" section really helpful here.

Ok, I'll fix that.

Quoted 2 lines

...user that does not understand what "between 1 and 32 means" is unlikely to know if the driver is built-in or module...

Yeah, it is a trivial example for a user action. Perhaps even too trivial. On the other hand it doesn't hurt either. At least it is good english thanks to our ID department.

Signature · 4 lines
blue skies,
  Martin.

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#71 lore raw
Quoted 9 lines · Sam Ravnborg
Quoted 5 lines

The lastest changes:
* kmsg.h has been moved from include/asm-s390 to include/linux
* The s390 specific documentation is now in Documentation/kmsg/s390
* The script checks for messages in the source file, Documentation/kmsg and Documentation/kmsg/$SRCARCH

The tendency is that all ARCH specific files should be part of arch/$ARCH/*
What is the correct approach here I dunno.

Hmm, arch/$ARCH/kmsg. But then Documentation/kmsg doesn't really fit, does it? Don't no either..

Signature · 4 lines
blue skies,
  Martin.

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