Skip to contentSkip to conversation

ramoops: use pstore interface

PATCH In review Kees Cook 6 participants 17 messages Jan 18, 2012 – Apr 11, 2012

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v5 1/1 ramoops: use pstore interface

Instead of using /dev/mem directly and forcing userspace to know (or extract) where the platform has defined persistent memory, how many slots it has, the sizes, etc, use the common pstore infrastructure to handle Oops gathering and extraction. This presents a much easier to use filesystem-based view to the memory region. This also means that any other tools that are written to understand pstore will automatically be able to process ramoops too.

---
v5:
- Rebased.
- Updated with changes based on feedback from Andrew Morton:
- Increased changelog verbosity.
- Dropped needless casts from void *.
- Clarified ramoops_pstore_write() comments.
v4:
- Rebased to Linus's tree.
v3:
- Added more documentation about which memory regions it would be used with.
v2:
- General reworking.

---
 Documentation/ramoops.txt |    8 +-
 drivers/char/Kconfig      |    1 +
 drivers/char/ramoops.c    |  203 ++++++++++++++++++++++++++++++++++----------
 3 files changed, 162 insertions(+), 50 deletions(-)
Documentation/ramoops.txt +4 -4
index 8fb1ba7..a0b9d8e 100644
@@ -3,7 +3,7 @@ Ramoops oops/panic logger
 
 Sergiu Iordache <[email protected]>
 
-Updated: 8 August 2011
+Updated: 17 November 2011
 
 0. Introduction
 
@@ -71,6 +71,6 @@ timestamp and a new line. The dump then continues with the actual data.
 
 4. Reading the data
 
-The dump data can be read from memory (through /dev/mem or other means).
-Getting the module parameters, which are needed in order to parse the data, can
-be done through /sys/module/ramoops/parameters/* .
+The dump data can be read from the pstore filesystem. The format for these
+files is "dmesg-ramoops-N", where N is the record number in memory. To delete
+a stored record from RAM, simply unlink the respective pstore file.
drivers/char/Kconfig +1 -0
index 4364303..f166499 100644
@@ -603,6 +603,7 @@ source "drivers/s390/char/Kconfig"
 config RAMOOPS
 	tristate "Log panic/oops to a RAM buffer"
 	depends on HAS_IOMEM
+	depends on PSTORE
 	default n
 	help
 	  This enables panic and oops messages to be logged to a circular
drivers/char/ramoops.c +157 -46

306 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 13 lines · On Tue, 17 Jan 2012 15:58:52 -0800 Kees Cook <[email protected]> wrote:

Instead of using /dev/mem directly and forcing userspace to know (or extract) where the platform has defined persistent memory, how many slots it has, the sizes, etc, use the common pstore infrastructure to handle Oops gathering and extraction. This presents a much easier to use filesystem-based view to the memory region. This also means that any other tools that are written to understand pstore will automatically be able to process ramoops too.

...

drivers/char/Kconfig source "drivers/s390/char/Kconfig" · line 609

Quoted 7 lines
drivers/char/Kconfig +1 -0
@@ -603,6 +603,7 @@ source "drivers/s390/char/Kconfig"
 config RAMOOPS
 	tristate "Log panic/oops to a RAM buffer"
 	depends on HAS_IOMEM
+	depends on PSTORE
 	default n
 	help
 	  This enables panic and oops messages to be logged to a circular

I think this is the right thing to do, but boy I hate it. You sit there wondering "wtf do I need to enable so I can use feature X". I sometimes use menuconfig's search feature, other times go trawl the Kconfig files. There should be a capability in Kconfig to just turn on the terminal feature, enabling any precondition features on the way. Everyone loves Kconfig.

drivers/char/Kconfig

Quoted 9 lines

...

static int __exit ramoops_remove(struct platform_device *pdev) {

drivers/char/Kconfig +4 -0
+#if 0
+	/* TODO(kees): We cannot unload ramoops since pstore doesn't support
+	 * unregistering yet.
+	 */

Well that sucks. Is pstore getting fixed?

Quoted 19 lines
drivers/char/Kconfig +8 -3
 	struct ramoops_context *cxt = &oops_cxt;
 
-	if (kmsg_dump_unregister(&cxt->dump) < 0)
-		pr_warn("could not unregister kmsg_dumper\n");
-
 	iounmap(cxt->virt_addr);
 	release_mem_region(cxt->phys_addr, cxt->size);
+	cxt->max_count = 0;
+
+	/* TODO(kees): When pstore supports unregistering, call it here. */
+	kfree(cxt->pstore.buf);
+	cxt->pstore.bufsize = 0;
+
 	return 0;
+#endif
+	return -EBUSY;
 }
 
 static struct platform_driver ramoops_driver = {
author
#2 lore raw
Quoted 12 lines · Andrew Morton
Quoted 9 lines · On Tue, 17 Jan 2012 15:58:52 -0800 Kees Cook <[email protected]> wrote:
drivers/char/Kconfig +0 -0
@@ -603,6 +603,7 @@ source "drivers/s390/char/Kconfig"

 config RAMOOPS
      tristate "Log panic/oops to a RAM buffer"
      depends on HAS_IOMEM
+     depends on PSTORE
      default n
      help

Quoted 8 lines
Quoted 1 line

        This enables panic and oops messages to be logged to a circular

I think this is the right thing to do, but boy I hate it.  You sit there wondering "wtf do I need to enable so I can use feature X".  I sometimes use menuconfig's search feature, other times go trawl the Kconfig files.  There should be a capability in Kconfig to just turn on the terminal feature, enabling any precondition features on the way. Everyone loves Kconfig.

Heh. Yeah, makes a lot of thing undiscoverable in menuconfig. Maybe stuff should be greyed out instead of just disappearing.

Quoted 8 lines
Quoted 6 lines

 static int __exit ramoops_remove(struct platform_device *pdev) {
+#if 0
+     /* TODO(kees): We cannot unload ramoops since pstore doesn't support
+      * unregistering yet.
+      */

Well that sucks.  Is pstore getting fixed?

Tony, any plans for changing this? I'm ready when it does! :)

Thanks,

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#16 lore raw
In reply to Andrew Morton
Quoted 5 lines

drivers/char/ramoops.c static int __init ramoops_probe(struct platform_device *pdev) · line 296

Quoted 3 lines
drivers/char/ramoops.c +3 -0
+	/* TODO(kees): We cannot unload ramoops since pstore doesn't support
+	 * unregistering yet.
+	 */

Well that sucks. Is pstore getting fixed?

While it might be useful for developers who have machines that support multiple back-ends to load & unload - there really isn't any credible end-user case for it - so it has a very low priority. Perhaps zero (it would complicate the code for no useful purpose).

Even for development there's a lot of re-booting (after all, pstore is really about saving the kernel log when the system crashes :-).

-Tony

#3 lore raw
In reply to Kees Cook
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

 static int __exit ramoops_remove(struct platform_device *pdev) {
+#if 0
+     /* TODO(kees): We cannot unload ramoops since pstore doesn't support
+      * unregistering yet.
+      */

Quoted 5 lines
Quoted 1 line

Well that sucks.  Is pstore getting fixed?

Tony, any plans for changing this? I'm ready when it does! :)

I have an question about this.

Are there any specific usecases you need to unload ramoops?

If users really would like to get kernel messages, unregistering ramoops is not needed.

Seiji

author
#4 lore raw
Quoted 7 lines · Seiji Aguchi
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

 static int __exit ramoops_remove(struct platform_device *pdev) {
+#if 0
+     /* TODO(kees): We cannot unload ramoops since pstore doesn't support
+      * unregistering yet.
+      */

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Well that sucks.  Is pstore getting fixed?

Tony, any plans for changing this? I'm ready when it does! :)

I have an question about this.

Are there any specific usecases you need to unload ramoops?

For me, it would be useful during development. Beyond that, not that I can see.

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#5 lore raw
Quoted 3 lines
Quoted 1 line

Are there any specific usecases you need to unload ramoops?

For me, it would be useful during development. Beyond that, not that I can see.

Thank you for your quick relay. I understood this is useful for you.

But, as Tony said, I think this is a low priority because there is a side effect for end users.
If they unload ramoops by mistake, messages will be lost.

In my opinion, we have to consider whether each feature is truly needed for end users (not for developers).

Seiji

#6 lore raw

Il 19/01/2012 00:20, Seiji Aguchi ha scritto:

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Are there any specific usecases you need to unload ramoops?

For me, it would be useful during development. Beyond that, not that I can see.

Thank you for your quick relay. I understood this is useful for you.

Quoted 10 lines

But, as Tony said, I think this is a low priority because there is a side effect for end users.
If they unload ramoops by mistake, messages will be lost.

In my opinion, we have to consider whether each feature is truly needed for end users (not for developers).

Seiji

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Marco

#7 lore raw
Quoted 9 lines

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Marco

What is the status of this patch? Don't see it in 3.3 and haven't checked 3.4-rc1 yet.

-- Shuah

author
#8 lore raw
Quoted 11 lines · Shuah Khan
Quoted 8 lines

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Marco

What is the status of this patch? Don't see it in 3.3 and haven't checked 3.4-rc1 yet.

Hi,

I've been hoping it would get into 3.4. It's in the -mm tree, and has been living in linux-next for a while. I'm not sure why it hasn't been merged into Linus's tree yet. Andrew, is there a reason it hasn't been merged?

http://marc.info/?l=linux-mm-commits&m=132692455101733&w=4

http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=commitdiff;h=07eff225ead22b21fe5aba32cd2695248a9e4d1f

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#9 lore raw
Quoted 13 lines · On Mon, 2 Apr 2012 13:51:29 -0700 Kees Cook <[email protected]> wrote:
Quoted 11 lines · Shuah Khan
Quoted 8 lines

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Marco

What is the status of this patch? Don't see it in 3.3 and haven't checked 3.4-rc1 yet.

Quoted 7 lines

Hi,

I've been hoping it would get into 3.4. It's in the -mm tree, and has been living in linux-next for a while. I'm not sure why it hasn't been merged into Linus's tree yet. Andrew, is there a reason it hasn't been merged?

It's not forgotten about - sometimes I'll hold a few things over until rc2 to give myself time to go back and review the discussion. The ramoops and c/r patches fell into that bucket this time.

#10 lore raw
In reply to Kees Cook
Quoted 13 lines · On Mon, 2 Apr 2012 13:51:29 -0700 Kees Cook <[email protected]> wrote:
Quoted 11 lines · Shuah Khan
Quoted 8 lines

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Marco

What is the status of this patch? Don't see it in 3.3 and haven't checked 3.4-rc1 yet.

Quoted 6 lines

Hi,

I've been hoping it would get into 3.4. It's in the -mm tree, and has been living in linux-next for a while. I'm not sure why it hasn't been merged into Linus's tree yet. Andrew, is there a reason it hasn't been merged?

The patch breaks ramoops module unloading. Tony says there's "no credible end-user case" for this and Marco promptly provided one, which was ignored.

#11 lore raw
Quoted 3 lines

The patch breaks ramoops module unloading. Tony says there's "no credible end-user case" for this and Marco promptly provided one, which was ignored.

Quoted 6 lines · I'm not sure that I understood Marco's use case. He

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

In the non-crashed oops case ... aren't all the logs you need in /var/log/messages?

-Tony

#12 lore raw

Il 09/04/2012 23:42, Luck, Tony ha scritto:

Quoted 13 lines
Quoted 3 lines

The patch breaks ramoops module unloading. Tony says there's "no credible end-user case" for this and Marco promptly provided one, which was ignored.

Quoted 6 lines · I'm not sure that I understood Marco's use case. He

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Quoted 4 lines

In the non-crashed oops case ... aren't all the logs you need in /var/log/messages?

-Tony

Maybe you right, but it could be useful to have a "single log point" especially for automatic/semi-automatic log gathering. I'm not sure we can *always* read from messages in case of non-crashed oops. Sure, it will be possible after a reboot, but if /var was mounted with tmpfs (on embedded systems it's possible :)) we have no log.

PS: It's only a brainstorming on all the possible situation :)

Marco

author
#13 lore raw
Quoted 23 lines · Marco Stornelli

Il 09/04/2012 23:42, Luck, Tony ha scritto:

Quoted 15 lines
Quoted 3 lines

The patch breaks ramoops module unloading.  Tony says there's "no credible end-user case" for this and Marco promptly provided one, which was ignored.

Quoted 6 lines · I'm not sure that I understood Marco's use case. He

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Quoted 4 lines

In the non-crashed oops case ... aren't all the logs you need in /var/log/messages?

-Tony

Quoted 7 lines

Maybe you right, but it could be useful to have a "single log point" especially for automatic/semi-automatic log gathering. I'm not sure we can *always* read from messages in case of non-crashed oops. Sure, it will be possible after a reboot, but if /var was mounted with tmpfs (on embedded systems it's possible :)) we have no log.

PS: It's only a brainstorming on all the possible situation :)

Do you feel that this lack of unloading is still a sufficient reason to NAK the ramoops patch?

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#14 lore raw

2012/4/10 Kees Cook <[email protected]>:

Quoted 33 lines
Quoted 23 lines · Marco Stornelli

Il 09/04/2012 23:42, Luck, Tony ha scritto:

Quoted 15 lines
Quoted 3 lines

The patch breaks ramoops module unloading.  Tony says there's "no credible end-user case" for this and Marco promptly provided one, which was ignored.

Quoted 6 lines · I'm not sure that I understood Marco's use case. He

First of all ramoops was born mainly for debug purpose and to help the maintainability of a product. I used it in systems where the uptime (so no reboot) was important. So it can be very useful for me load the module, gather logs and unload it for example. A kernel panic is not recoverable so the reboot is needed but it's not always true for a kernel oops.

Quoted 4 lines

In the non-crashed oops case ... aren't all the logs you need in /var/log/messages?

-Tony

Quoted 7 lines

Maybe you right, but it could be useful to have a "single log point" especially for automatic/semi-automatic log gathering. I'm not sure we can *always* read from messages in case of non-crashed oops. Sure, it will be possible after a reboot, but if /var was mounted with tmpfs (on embedded systems it's possible :)) we have no log.

PS: It's only a brainstorming on all the possible situation :)

Quoted 8 lines

Do you feel that this lack of unloading is still a sufficient reason to NAK the ramoops patch?

-Kees

--
Kees Cook
ChromeOS Security

I don't want to use a "veto" about this patch. If nobody see problem to apply it, then even ok for me. As I said I'm guessing possible situations where an unload features is useful.

Andrew what do you think?

Marco

#15 lore raw
Quoted 5 lines · On Wed, 11 Apr 2012 08:33:15 +0200 Marco Stornelli <[email protected]>…

I don't want to use a "veto" about this patch. If nobody see problem to apply it, then even ok for me. As I said I'm guessing possible situations where an unload features is useful.

Andrew what do you think?

Yes, I plan to send it to Linus.

breaking unloading is a regression, albeit a small one. It's a bit sad that nobody appears to intend to fix it.