fs/pstore: provide panic data even in suspend
Subsystems (2)
PATCH 1/1 fs/pstore: provide panic data even in suspend
From: yangdongdong <[email protected]>
This 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 <[email protected]>
Signed-off-by gulinghua <[email protected]>
--- fs/pstore/ram.c | 21 +++++++++++++++++++++ include/linux/pstore_ram.h | 1 + kernel/printk/printk.c | 6 ++++++ 3 files changed, 28 insertions(+)
fs/pstore/ram.c +21 -0
@@ -642,8 +642,28 @@ 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 void ramoops_prepare (void ) +{ +atomic_notifier_chain_register (&panic_notifier_list, &ramoop_nb); +} +static int __init ramoops_init (void ) { +ramoops_prepare ();ramoops_register_dummy ();return platform_driver_register (&ramoops_driver); }
@@ -654,6 +674,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);
include/linux/pstore_ram.h +1 -0
@@ -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);
kernel/printk/printk.c +6 -0
@@ -2107,6 +2107,12 @@ void resume_console(void)console_unlock (); } +void emergency_unlock_console (void ) +{ +resume_console (); +} +EXPORT_SYMBOL (emergency_unlock_console); +/** * console_cpu_notify - print deferred console messages after CPU hotplug * @self: notifier struct
Signature · 1 line
2.5.0
Quoted 8 lines · On 08/05/2015 08:11 AM, [email protected] wrote:
From: yangdongdong <[email protected]>
This 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 <[email protected]>Signed-off-by gulinghua <[email protected]>
I have a small comment on the code below.
-Alex
Quoted 40 lines
--- fs/pstore/ram.c | 21 +++++++++++++++++++++ include/linux/pstore_ram.h | 1 + kernel/printk/printk.c | 6 ++++++ 3 files changed, 28 insertions(+)fs/pstore/ram.c +20
-0@@ -642,8 +642,28 @@ 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 void ramoops_prepare (void ) +{ +atomic_notifier_chain_register (&panic_notifier_list, &ramoop_nb); +} +static int __init ramoops_init (void ) { +ramoops_prepare ();ramoops_register_dummy ();return platform_driver_register (&ramoops_driver); }
fs/pstore/ram.c static void __exit ramoops_exit(void) · line 677
Quoted 4 lines
fs/pstore/ram.c +1
-0@@ -654,6 +674,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);
I would say either wrap this atomic_notificer_chain_unregister() call in a trivial function ramoops_unprepare(), or (preferably) get rid of ramoops_prepare().
Quoted 33 lines
fs/pstore/ram.c +0
-0}module_exit (ramoops_exit);include/linux/pstore_ram.h +1
-0@@ -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);kernel/printk/printk.c +6
-0@@ -2107,6 +2107,12 @@ void resume_console(void)console_unlock (); } +void emergency_unlock_console (void ) +{ +resume_console (); +} +EXPORT_SYMBOL (emergency_unlock_console); +/** * console_cpu_notify - print deferred console messages after CPU hotplug * @self: notifier struct