public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: Feng Tang <feng.tang@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>, Borislav Petkov <bp@suse.de>
Subject: Re: [PATCH 1/2] printk: Add an option to flush all messages on panic
Date: Mon, 1 Apr 2019 17:20:33 +0530	[thread overview]
Message-ID: <0020b526-ad88-309a-8dce-1c852f0ebb31@codeaurora.org> (raw)
In-Reply-To: <1554115684-26846-1-git-send-email-feng.tang@intel.com>


On 4/1/2019 4:18 PM, Feng Tang wrote:
> Current console_flush_on_panic() will only dump the new messages
> in buffer, and users may need an opportunity to check all the
> messages on panic which could help debugging, as user may haven't
> seen the log before panic due to loglevel settings.
>
> Add a flag for console_flush_on_panic() to chose whether to
> dump all messages.
>
> Signed-off-by: Feng Tang <feng.tang@intel.com>


Looks good to me.


But, Will it not be good if put it under a config and not change the 
prototype, as it is a debug feature?

Thanks,
Mukesh

> ---
>   arch/powerpc/kernel/traps.c | 2 +-
>   include/linux/console.h     | 2 +-
>   kernel/panic.c              | 2 +-
>   kernel/printk/printk.c      | 9 ++++++++-
>   4 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index 1fd45a8..58d9580 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -179,7 +179,7 @@ extern void panic_flush_kmsg_end(void)
>   	kmsg_dump(KMSG_DUMP_PANIC);
>   	bust_spinlocks(0);
>   	debug_locks_off();
> -	console_flush_on_panic();
> +	console_flush_on_panic(false);
>   }
>   
>   static unsigned long oops_begin(struct pt_regs *regs)
> diff --git a/include/linux/console.h b/include/linux/console.h
> index ec9bdb3..825ecf5 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -175,7 +175,7 @@ extern int console_trylock(void);
>   extern void console_unlock(void);
>   extern void console_conditional_schedule(void);
>   extern void console_unblank(void);
> -extern void console_flush_on_panic(void);
> +extern void console_flush_on_panic(bool flush_all);
>   extern struct tty_driver *console_device(int *);
>   extern void console_stop(struct console *);
>   extern void console_start(struct console *);
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 0ae0d73..fb77e01 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -277,7 +277,7 @@ void panic(const char *fmt, ...)
>   	 * panic() is not being callled from OOPS.
>   	 */
>   	debug_locks_off();
> -	console_flush_on_panic();
> +	console_flush_on_panic(false);
>   
>   	panic_print_sys_info();
>   
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 02ca827..8ff099b 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2525,10 +2525,11 @@ void console_unblank(void)
>   
>   /**
>    * console_flush_on_panic - flush console content on panic
> + * @flush_all:	whether to print all messages in buffer
>    *
>    * Immediately output all pending messages no matter what.
>    */
> -void console_flush_on_panic(void)
> +void console_flush_on_panic(bool flush_all)
>   {
>   	/*
>   	 * If someone else is holding the console lock, trylock will fail
> @@ -2539,6 +2540,12 @@ void console_flush_on_panic(void)
>   	 */
>   	console_trylock();
>   	console_may_schedule = 0;
> +
> +	/* User may want to see all the printk messages on panic */
> +	if (flush_all) {
> +		console_seq = log_first_seq;
> +		console_idx = log_first_idx;
> +	}
>   	console_unlock();
>   }
>   

  parent reply	other threads:[~2019-04-01 11:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 10:48 [PATCH 1/2] printk: Add an option to flush all messages on panic Feng Tang
2019-04-01 10:48 ` [PATCH 2/2] panic: Enable to print out all printk msg in buffer Feng Tang
2019-04-09 14:14   ` Petr Mladek
2019-04-10  1:59     ` Sergey Senozhatsky
2019-04-10  8:02       ` Petr Mladek
2019-04-10  8:16         ` Sergey Senozhatsky
2019-04-10 10:12     ` Feng Tang
2019-04-01 11:50 ` Mukesh Ojha [this message]
2019-04-02  2:47   ` [PATCH 1/2] printk: Add an option to flush all messages on panic Feng Tang
2019-04-02  2:14 ` Sergey Senozhatsky
2019-04-02  2:28   ` Feng Tang
2019-04-02  2:29     ` Sergey Senozhatsky
2019-04-09 13:41       ` Petr Mladek
2019-04-10  1:47         ` Sergey Senozhatsky
2019-04-10  2:21           ` Feng Tang

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=0020b526-ad88-309a-8dce-1c852f0ebb31@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=feng.tang@intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox