From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318AbdFBJFP (ORCPT ); Fri, 2 Jun 2017 05:05:15 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:35617 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbdFBJFM (ORCPT ); Fri, 2 Jun 2017 05:05:12 -0400 From: Sergey Senozhatsky To: Petr Mladek , Steven Rostedt Cc: Jan Kara , Andrew Morton , Peter Zijlstra , "Rafael J . Wysocki" , Eric Biederman , Greg Kroah-Hartman , Jiri Slaby , Pavel Machek , Andreas Mohr , Tetsuo Handa , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: [RFC][PATCHv4 6/7] printk: register syscore notifier Date: Fri, 2 Jun 2017 18:03:44 +0900 Message-Id: <20170602090345.624-7-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170602090345.624-1-sergey.senozhatsky@gmail.com> References: <20170602090345.624-1-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to switch to emergency printk mode in kernel_kexec(). One kernel_kexec() branch calls kernel_restart_prepare(), which updates `system_state', however, the other one, when user requested to ->preserve_context, does not and we are lacking the information in printk about kexec being executed. Register a syscore notifier so printk will be notified by syscore_suspend(). Signed-off-by: Sergey Senozhatsky --- kernel/printk/printk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 5b2b97ee3440..4e5233a265cb 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -2970,6 +2971,22 @@ static struct notifier_block printk_pm_nb = { .notifier_call = printk_pm_notify, }; +static int printk_pm_syscore_suspend(void) +{ + printk_emergency_begin(); + return 0; +} + +static void printk_pm_syscore_resume(void) +{ + printk_emergency_end(); +} + +static struct syscore_ops printk_pm_syscore_ops = { + .suspend = printk_pm_syscore_suspend, + .resume = printk_pm_syscore_resume, +}; + static void printk_kthread_func(unsigned int cpu) { while (1) { @@ -3027,6 +3044,7 @@ static int __init init_printk_kthreads(void) return -EINVAL; } + register_syscore_ops(&printk_pm_syscore_ops); return 0; } late_initcall(init_printk_kthreads); -- 2.13.0