linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] fs/pstore: provide panic data even in suspend
@ 2015-08-12  3:45 check.kernel
  2015-08-13 17:53 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: check.kernel @ 2015-08-12  3:45 UTC (permalink / raw)
  To: Petr Mladek, Alex Elder, Anton Vorontsov, Colin Cross, Kees Cook,
	Tony Luck, Andrew Morton, Luis R. Rodriguez, Peter Hurley,
	Joe Perches, Tejun Heo, Ethan du, Linghua Gu
  Cc: linux-kernel, yangdongdong

From: yangdongdong <yangdongdong@xiaomi.com>

If system restart after panic, this patch also enables
panic and oops messages which in suspend context to be
logged into ramoops console buffer where it can be read
back at some later point.

Signed-off-by: yangdongdong <yangdongdong@xiaomi.com>
Signed-off-by: gulinghua <gulinghua@xiaomi.com>
Signed-off-by: duhui <duhui@xiaomi.com>
---
 fs/pstore/ram.c            | 16 ++++++++++++++++
 include/linux/pstore_ram.h |  1 +
 kernel/printk/printk.c     |  7 +++++++
 3 files changed, 24 insertions(+)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 6c26c4d..3d981a1 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -642,8 +642,23 @@ static void ramoops_register_dummy(void)
 	}
 }
 
+static int ramoops_console_notify(struct notifier_block *this,
+		unsigned long event, void *ptr)
+{
+	pr_emerg("ramoops unlock console ...\n");
+	emergency_unlock_console();
+
+	return 0;
+}
+
+static struct notifier_block ramoop_nb = {
+	.notifier_call = ramoops_console_notify,
+	.priority = INT_MAX,
+};
+
 static int __init ramoops_init(void)
 {
+	atomic_notifier_chain_register(&panic_notifier_list, &ramoop_nb);
 	ramoops_register_dummy();
 	return platform_driver_register(&ramoops_driver);
 }
@@ -654,6 +669,7 @@ static void __exit ramoops_exit(void)
 	platform_driver_unregister(&ramoops_driver);
 	platform_device_unregister(dummy);
 	kfree(dummy_data);
+	atomic_notifier_chain_unregister(&panic_notifier_list, &ramoop_nb);
 }
 module_exit(ramoops_exit);
 
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 9c9d6c1..826a35b 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -52,6 +52,7 @@ struct persistent_ram_zone {
 	size_t old_log_size;
 };
 
+extern void emergency_unlock_console(void);
 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
 			u32 sig, struct persistent_ram_ecc_info *ecc_info,
 			unsigned int memtype);
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index cf8c242..ca02094 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2107,6 +2107,13 @@ void resume_console(void)
 	console_unlock();
 }
 
+void emergency_unlock_console(void)
+{
+	if (panic_timeout != 0 && console_suspended)
+		resume_console();
+}
+EXPORT_SYMBOL(emergency_unlock_console);
+
 /**
  * console_cpu_notify - print deferred console messages after CPU hotplug
  * @self: notifier struct
-- 
2.5.0

Following is the difference between v2 and v3:
 void emergency_unlock_console(void)
 {
-       if (panic_timeout != 0)
+       if ((panic_timeout != 0) && console_suspended)
                resume_console();
 }
 EXPORT_SYMBOL(emergency_unlock_console);

Once system kernel panic with nonzero panic_timeout value, we hope the debugging
information could be dumped and system could be recovered by reboot.

Since it is emergency case before system reboot, no whether it is triggered by
watchdog or emergency_restart, the debugging data is important for us to
be read back at some later point and system would have no possible enter suspend and resume.
And usually dump panic data process would be hoped to handle in atomic process.
That is why no console_suspended check for emergency_unlock_console at the PATCH-V2.
Here is updating it to [PATCH v3], also add console_suspended check for
emergency_unlock_console, which specific invoked conosole_suspended previously.

Due to no panic information, if we use current ram console approach once panic occurs
on system enter suspend, we would not know who is the trouble maker. We have such
experience at receiving big noise in MO call under system suspend. That is the intention to add the patch.


Thanks,
Andy


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

* Re: [PATCH v3] fs/pstore: provide panic data even in suspend
  2015-08-12  3:45 [PATCH v3] fs/pstore: provide panic data even in suspend check.kernel
@ 2015-08-13 17:53 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2015-08-13 17:53 UTC (permalink / raw)
  To: check.kernel
  Cc: Petr Mladek, Alex Elder, Anton Vorontsov, Colin Cross, Kees Cook,
	Tony Luck, Andrew Morton, Luis R. Rodriguez, Peter Hurley,
	Tejun Heo, Ethan du, Linghua Gu, linux-kernel, yangdongdong

On Wed, 2015-08-12 at 11:45 +0800, check.kernel@gmail.com wrote:
> From: yangdongdong <yangdongdong@xiaomi.com>
> 
> If system restart after panic, this patch also enables
> panic and oops messages which in suspend context to be
> logged into ramoops console buffer where it can be read
> back at some later point.

trivia:

> diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
[]
> @@ -52,6 +52,7 @@ struct persistent_ram_zone {
>  	size_t old_log_size;
>  };
>  
> +extern void emergency_unlock_console(void);

None of the other function prototypes in this file use extern.
This one shouldn't either.

>  struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
>  			u32 sig, struct persistent_ram_ecc_info *ecc_info,
>  			unsigned int memtype);



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

end of thread, other threads:[~2015-08-13 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12  3:45 [PATCH v3] fs/pstore: provide panic data even in suspend check.kernel
2015-08-13 17:53 ` Joe Perches

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