All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Dongdong Yang <check.kernel@gmail.com>
Cc: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>,
	Kees Cook <keescook@chromium.org>,
	Tony Luck <tony.luck@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alex Elder <elder@linaro.org>,
	"Luis R. Rodriguez" <mcgrof@suse.com>,
	Peter Hurley <peter@hurleysoftware.com>,
	Joe Perches <joe@perches.com>, Tejun Heo <tj@kernel.org>,
	Ethan du <duhui@xiaomi.com>, Linghua Gu <gulinghua@xiaomi.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	yangdongdong <yangdongdong@xiaomi.com>
Subject: Re: [PATCH] ramoops: provide panic data even in suspend
Date: Tue, 11 Aug 2015 18:10:29 +0200	[thread overview]
Message-ID: <20150811161029.GF18217@pathway.suse.cz> (raw)
In-Reply-To: <CAEG8FrHTbsJ8vwLAi_dcQ8q3axGtko=hkZ5p7X=TK7=HTro5Ag@mail.gmail.com>

On Thu 2015-08-06 22:37:15, Dongdong Yang wrote:
> >From 6b28004d7b3144d4d26d60fe0bf6a750bbab39f6 Mon Sep 17 00:00:00 2001
> From: yangdongdong <yangdongdong@xiaomi.com>
> Date: Wed, 5 Aug 2015 18:51:17 +0800
> Subject: [PATCH] fs/pstore: provide panic data even in suspend
> 
> 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..cfa22f5 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)
> +               resume_console();

Could you please explain the meaning of this test? I do not get it.

If you want to resume a potentially suspended console, you need to check if the
console is really suspended.

> +}
> +EXPORT_SYMBOL(emergency_unlock_console);
> +
>  /**
>   * console_cpu_notify - print deferred console messages after CPU hotplug
>   * @self: notifier struct
> -- 
> 2.5.0
> 
> 
> The above PATCH-v2 with following update:
>         - Change subject "[PATCH] ramoops" to "[PATCH-v2] fs/pstore"
>         - Add panic_timeout as emergency_unlock condition
>         - Add Ethan Du to signed-off list
> 
> For Petr's concern on panic break, here adds panic_timeout check as
> emergency_unlock_console condition. Because our original intention is
> collecting suspend panic debugging information before system reboot.

I am afraid that you are too focused on your scenario and do not see
other possibilities. Suspend is only one state of the system.
The panic might happen at any time. Or did I miss anything?

Best Regards,
Petr

      parent reply	other threads:[~2015-08-11 16:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05 13:56 [PATCH] ramoops: provide panic data even in suspend check.kernel
2015-08-05 14:53 ` Petr Mladek
     [not found]   ` <CAEG8FrHTbsJ8vwLAi_dcQ8q3axGtko=hkZ5p7X=TK7=HTro5Ag@mail.gmail.com>
2015-08-11 16:10     ` Petr Mladek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150811161029.GF18217@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=check.kernel@gmail.com \
    --cc=duhui@xiaomi.com \
    --cc=elder@linaro.org \
    --cc=gulinghua@xiaomi.com \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@suse.com \
    --cc=peter@hurleysoftware.com \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=yangdongdong@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.