Skip to contentSkip to conversation

pstore: add pmsg

PATCH In review Mark Salyzyn 1 participant 1 message Jan 6, 2015 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 pstore: add pmsg

A secured user-space accessible pstore object. Writes to /dev/pmsg0 are appended to the buffer, on reboot the persistent contents are available in /sys/fs/pstore/pmsg-ramoops-[ID].

One possible use is syslogd, or other daemon, can write messages, then on reboot provides a means to triage user-space activities leading up to a panic as a companion to the pstore dmesg or console logs.

---
 fs/pstore/Kconfig          |  10 +++++
 fs/pstore/Makefile         |   2 +
 fs/pstore/inode.c          |   3 ++
 fs/pstore/internal.h       |   6 +++
 fs/pstore/platform.c       |   1 +
 fs/pstore/pmsg.c           | 101 +++++++++++++++++++++++++++++++++++++++++++++
 fs/pstore/ram.c            |  46 ++++++++++++++++++---
 include/linux/pstore.h     |   1 +
 include/linux/pstore_ram.h |   1 +
 9 files changed, 166 insertions(+), 5 deletions(-)
 create mode 100644 fs/pstore/pmsg.c
fs/pstore/Kconfig +10 -0
index 983d951..916b8e2 100644
@@ -21,6 +21,16 @@ config PSTORE_CONSOLE
 	  When the option is enabled, pstore will log all kernel
 	  messages, even if no oops or panic happened.
 
+config PSTORE_PMSG
+	bool "Log user space messages"
+	depends on PSTORE
+	help
+	  When the option is enabled, pstore will export a character
+	  interface /dev/pmsg0 to log user space messages. On reboot
+	  data can be retrieved from /sys/fs/pstore/pmsg-ramoops-[ID].
+
+	  If unsure, say N.
+
 config PSTORE_FTRACE
 	bool "Persistent function tracer"
 	depends on PSTORE
fs/pstore/Makefile +2 -0
index 4c9095c..e647d8e 100644
@@ -7,5 +7,7 @@ obj-y += pstore.o
 pstore-objs += inode.o platform.o
 obj-$(CONFIG_PSTORE_FTRACE)	+= ftrace.o
 
+obj-$(CONFIG_PSTORE_PMSG)	+= pmsg.o
+
 ramoops-objs += ram.o ram_core.o
 obj-$(CONFIG_PSTORE_RAM)	+= ramoops.o
fs/pstore/inode.c +3 -0
index a381e6c..1b64c85 100644
@@ -360,6 +360,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
 		snprintf(name, sizeof(name), "powerpc-common-%s-%lld",
 			psname, id);
 		break;
+	case PSTORE_TYPE_PMSG:
+		snprintf(name, sizeof(name), "pmsg-%s-%lld", psname, id);
+		break;
 	case PSTORE_TYPE_UNKNOWN:
 		snprintf(name, sizeof(name), "unknown-%s-%lld", psname, id);
 		break;
fs/pstore/internal.h +6 -0
index 3b3d305..c36ba2c 100644
@@ -45,6 +45,12 @@ extern void pstore_register_ftrace(void);
 static inline void pstore_register_ftrace(void) {}
 #endif
 
+#ifdef CONFIG_PSTORE_PMSG
+extern void pstore_register_pmsg(void);
+#else
+static inline void pstore_register_pmsg(void) {}
+#endif
+
 extern struct pstore_info *psinfo;
 
 extern void	pstore_set_kmsg_bytes(int);
fs/pstore/platform.c +1 -0
index 0a9b72c..15ee78c 100644
@@ -447,6 +447,7 @@ int pstore_register(struct pstore_info *psi)
 	if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
 		pstore_register_console();
 		pstore_register_ftrace();
+		pstore_register_pmsg();
 	}
 
 	if (pstore_update_ms >= 0) {
fs/pstore/pmsg.c new file +101 -0

101 lines not on this page · raw message

fs/pstore/ram.c +41 -5

145 lines not on this page · raw message

include/linux/pstore.h +1 -0
index ece0c6b..8884f6e 100644
@@ -39,6 +39,7 @@ enum pstore_type_id {
 	PSTORE_TYPE_PPC_RTAS	= 4,
 	PSTORE_TYPE_PPC_OF	= 5,
 	PSTORE_TYPE_PPC_COMMON	= 6,
+	PSTORE_TYPE_PMSG	= 7,
 	PSTORE_TYPE_UNKNOWN	= 255
 };
 
include/linux/pstore_ram.h +1 -0
index 4af3fdc..9c9d6c1 100644
@@ -81,6 +81,7 @@ struct ramoops_platform_data {
 	unsigned long	record_size;
 	unsigned long	console_size;
 	unsigned long	ftrace_size;
+	unsigned long	pmsg_size;
 	int		dump_oops;
 	struct persistent_ram_ecc_info ecc_info;
 };
Signature · 1 line
2.2.0.rc0.207.ga3a616c