Skip to contentSkip to conversation

pstore: Split pstore fragile flags

PATCH Superseded Namhyung Kim 2 participants 4 messages Jul 20, 2016 Pstore filesystem

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pstore: Split pstore fragile flags

This patch adds new PSTORE_FLAGS for each pstore type so that they can be enabled separately. This is a preparation for ongoing virtio-pstore work to support those types flexibly.

The PSTORE_FLAGS_FRAGILE is mapped to PSTORE_FLAGS_DMESG to preserve the original behavior.

---
 fs/pstore/platform.c   | 9 +++++----
 fs/pstore/ram.c        | 2 ++
 include/linux/pstore.h | 8 +++++++-
 3 files changed, 14 insertions(+), 5 deletions(-)
fs/pstore/platform.c +5 -4
index 588461bb2dd4..1b5cae9b405f 100644
@@ -467,13 +467,14 @@ int pstore_register(struct pstore_info *psi)
 	if (pstore_is_mounted())
 		pstore_get_records(0);
 
-	pstore_register_kmsg();
-
-	if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
+	if (psi->flags & PSTORE_FLAGS_DMESG)
+		pstore_register_kmsg();
+	if (psi->flags & PSTORE_FLAGS_CONSOLE)
 		pstore_register_console();
+	if (psi->flags & PSTORE_FLAGS_FTRACE)
 		pstore_register_ftrace();
+	if (psi->flags & PSTORE_FLAGS_PMSG)
 		pstore_register_pmsg();
-	}
 
 	if (pstore_update_ms >= 0) {
 		pstore_timer.expires = jiffies +
fs/pstore/ram.c +2 -0
index bd9812e83461..d08bfd611b11 100644
@@ -539,6 +539,8 @@ static int ramoops_probe(struct platform_device *pdev)
 		goto fail_clear;
 	}
 
+	cxt->pstore.flags = PSTORE_FLAGS_ALL;
+
 	err = pstore_register(&cxt->pstore);
 	if (err) {
 		pr_err("registering with pstore failed\n");
include/linux/pstore.h +7 -1
index 831479f8df8f..6c291be41e84 100644
@@ -73,7 +73,13 @@ struct pstore_info {
 	void		*data;
 };
 
-#define	PSTORE_FLAGS_FRAGILE	1
+#define PSTORE_FLAGS_DMESG	(1 << 0)
+#define PSTORE_FLAGS_CONSOLE	(1 << 1)
+#define PSTORE_FLAGS_FTRACE	(1 << 2)
+#define PSTORE_FLAGS_PMSG	(1 << 3)
+
+#define	PSTORE_FLAGS_FRAGILE	PSTORE_FLAGS_DMESG
+#define PSTORE_FLAGS_ALL	((1 << 4) - 1)
 
 extern int pstore_register(struct pstore_info *);
 extern void pstore_unregister(struct pstore_info *);
Signature · 1 line
2.8.0
#1 lore raw

PATCH 2/2 pstore/ram: Set pstore flags dynamically

The ramoops can be configured to enable each pstore type by setting their size. In that case, it'd be better not to register disabled types in the first place.

---
 fs/pstore/ram.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/pstore/ram.c +7 -1
index d08bfd611b11..80a4d44464fc 100644
@@ -539,7 +539,13 @@ static int ramoops_probe(struct platform_device *pdev)
 		goto fail_clear;
 	}
 
-	cxt->pstore.flags = PSTORE_FLAGS_ALL;
+	cxt->pstore.flags = PSTORE_FLAGS_DMESG;
+	if (ctx->console_size)
+		cxt->pstore.flags |= PSTORE_FLAGS_CONOLE;
+	if (ctx->ftrace_size)
+		cxt->pstore.flags |= PSTORE_FLAGS_FTRACE;
+	if (ctx->pmsg_size)
+		cxt->pstore.flags |= PSTORE_FLAGS_PMSG;
 
 	err = pstore_register(&cxt->pstore);
 	if (err) {
Signature · 1 line
2.8.0
#2 lore raw

PATCH v2 1/2 pstore: Split pstore fragile flags

In reply to Namhyung Kim

This patch adds new PSTORE_FLAGS for each pstore type so that they can be enabled separately. This is a preparation for ongoing virtio-pstore work to support those types flexibly.

The PSTORE_FLAGS_FRAGILE is mapped to PSTORE_FLAGS_DMESG to preserve the original behavior.

---
v2: check flags on the unregister path also

 fs/pstore/platform.c   | 21 +++++++++++++--------
 fs/pstore/ram.c        |  2 ++
 include/linux/pstore.h |  8 +++++++-
 3 files changed, 22 insertions(+), 9 deletions(-)
fs/pstore/platform.c +13 -8
index 588461bb2dd4..6e86b7ea095d 100644
@@ -467,13 +467,14 @@ int pstore_register(struct pstore_info *psi)
 	if (pstore_is_mounted())
 		pstore_get_records(0);
 
-	pstore_register_kmsg();
-
-	if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
+	if (psi->flags & PSTORE_FLAGS_DMESG)
+		pstore_register_kmsg();
+	if (psi->flags & PSTORE_FLAGS_CONSOLE)
 		pstore_register_console();
+	if (psi->flags & PSTORE_FLAGS_FTRACE)
 		pstore_register_ftrace();
+	if (psi->flags & PSTORE_FLAGS_PMSG)
 		pstore_register_pmsg();
-	}
 
 	if (pstore_update_ms >= 0) {
 		pstore_timer.expires = jiffies +
@@ -497,10 +498,14 @@ EXPORT_SYMBOL_GPL(pstore_register);
 
 void pstore_unregister(struct pstore_info *psi)
 {
-	pstore_unregister_pmsg();
-	pstore_unregister_ftrace();
-	pstore_unregister_console();
-	pstore_unregister_kmsg();
+	if (psi->flags & PSTORE_FLAGS_PMSG)
+		pstore_unregister_pmsg();
+	if (psi->flags & PSTORE_FLAGS_FTRACE)
+		pstore_unregister_ftrace();
+	if (psi->flags & PSTORE_FLAGS_CONSOLE)
+		pstore_unregister_console();
+	if (psi->flags & PSTORE_FLAGS_DMESG)
+		pstore_unregister_kmsg();
 
 	free_buf_for_compression();
 
fs/pstore/ram.c +2 -0
index bd9812e83461..d08bfd611b11 100644
@@ -539,6 +539,8 @@ static int ramoops_probe(struct platform_device *pdev)
 		goto fail_clear;
 	}
 
+	cxt->pstore.flags = PSTORE_FLAGS_ALL;
+
 	err = pstore_register(&cxt->pstore);
 	if (err) {
 		pr_err("registering with pstore failed\n");
include/linux/pstore.h +7 -1
index 831479f8df8f..6c291be41e84 100644
@@ -73,7 +73,13 @@ struct pstore_info {
 	void		*data;
 };
 
-#define	PSTORE_FLAGS_FRAGILE	1
+#define PSTORE_FLAGS_DMESG	(1 << 0)
+#define PSTORE_FLAGS_CONSOLE	(1 << 1)
+#define PSTORE_FLAGS_FTRACE	(1 << 2)
+#define PSTORE_FLAGS_PMSG	(1 << 3)
+
+#define	PSTORE_FLAGS_FRAGILE	PSTORE_FLAGS_DMESG
+#define PSTORE_FLAGS_ALL	((1 << 4) - 1)
 
 extern int pstore_register(struct pstore_info *);
 extern void pstore_unregister(struct pstore_info *);
Signature · 1 line
2.8.0
#3 lore raw
Quoted 3 lines · Namhyung Kim

This patch adds new PSTORE_FLAGS for each pstore type so that they can be enabled separately. This is a preparation for ongoing virtio-pstore work to support those types flexibly.

Thanks! I was thinking about doing this too, but there wasn't a strong motivation yet. Now we have one! :)

Quoted 2 lines

The PSTORE_FLAGS_FRAGILE is mapped to PSTORE_FLAGS_DMESG to preserve the original behavior.

There are very few users, so I'd rather just remove PSTORE_FLAGS_FRAGILE entirely and replace it with _DMESG in the backends that were using _FRAGILE.

-Kees

Quoted 87 lines

---
v2: check flags on the unregister path also

 fs/pstore/platform.c   | 21 +++++++++++++--------
 fs/pstore/ram.c        |  2 ++
 include/linux/pstore.h |  8 +++++++-
 3 files changed, 22 insertions(+), 9 deletions(-)
fs/pstore/platform.c +13 -8
index 588461bb2dd4..6e86b7ea095d 100644
@@ -467,13 +467,14 @@ int pstore_register(struct pstore_info *psi)
        if (pstore_is_mounted())
                pstore_get_records(0);
 
-       pstore_register_kmsg();
-
-       if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
+       if (psi->flags & PSTORE_FLAGS_DMESG)
+               pstore_register_kmsg();
+       if (psi->flags & PSTORE_FLAGS_CONSOLE)
                pstore_register_console();
+       if (psi->flags & PSTORE_FLAGS_FTRACE)
                pstore_register_ftrace();
+       if (psi->flags & PSTORE_FLAGS_PMSG)
                pstore_register_pmsg();
-       }
 
        if (pstore_update_ms >= 0) {
                pstore_timer.expires = jiffies +
@@ -497,10 +498,14 @@ EXPORT_SYMBOL_GPL(pstore_register);
 
 void pstore_unregister(struct pstore_info *psi)
 {
-       pstore_unregister_pmsg();
-       pstore_unregister_ftrace();
-       pstore_unregister_console();
-       pstore_unregister_kmsg();
+       if (psi->flags & PSTORE_FLAGS_PMSG)
+               pstore_unregister_pmsg();
+       if (psi->flags & PSTORE_FLAGS_FTRACE)
+               pstore_unregister_ftrace();
+       if (psi->flags & PSTORE_FLAGS_CONSOLE)
+               pstore_unregister_console();
+       if (psi->flags & PSTORE_FLAGS_DMESG)
+               pstore_unregister_kmsg();
 
        free_buf_for_compression();
 
fs/pstore/ram.c +2 -0
index bd9812e83461..d08bfd611b11 100644
@@ -539,6 +539,8 @@ static int ramoops_probe(struct platform_device *pdev)
                goto fail_clear;
        }
 
+       cxt->pstore.flags = PSTORE_FLAGS_ALL;
+
        err = pstore_register(&cxt->pstore);
        if (err) {
                pr_err("registering with pstore failed\n");
include/linux/pstore.h +7 -2
index 831479f8df8f..6c291be41e84 100644
@@ -73,7 +73,13 @@ struct pstore_info {
        void            *data;
 };
 
-#define        PSTORE_FLAGS_FRAGILE    1
+#define PSTORE_FLAGS_DMESG     (1 << 0)
+#define PSTORE_FLAGS_CONSOLE   (1 << 1)
+#define PSTORE_FLAGS_FTRACE    (1 << 2)
+#define PSTORE_FLAGS_PMSG      (1 << 3)
+
+#define        PSTORE_FLAGS_FRAGILE    PSTORE_FLAGS_DMESG
+#define PSTORE_FLAGS_ALL       ((1 << 4) - 1)
 
 extern int pstore_register(struct pstore_info *);
 extern void pstore_unregister(struct pstore_info *);
--

2.8.0

Signature · 2 lines
Kees Cook
Chrome OS & Brillo Security