From: Petr Mladek <pmladek@suse.com>
To: Sreenath Vijayan <sreenath.vijayan@sony.com>
Cc: john.ogness@linutronix.de, corbet@lwn.net,
gregkh@linuxfoundation.org, jirislaby@kernel.org,
rdunlap@infradead.org, rostedt@goodmis.org,
senozhatsky@chromium.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
taichi.shimoyashiki@sony.com, daniel.palmer@sony.com,
anandakumar.balasubramaniam@sony.com
Subject: Re: [PATCH v6 1/2] printk: Add function to replay kernel log on consoles
Date: Wed, 22 May 2024 17:18:13 +0200 [thread overview]
Message-ID: <Zk4MtXxbzGrQhSFA@pathway.suse.cz> (raw)
In-Reply-To: <90ee131c643a5033d117b556c0792de65129d4c3.1710220326.git.sreenath.vijayan@sony.com>
On Wed 2024-03-13 15:50:52, Sreenath Vijayan wrote:
> Add a generic function console_replay_all() for replaying
> the kernel log on consoles, in any context. It would allow
> viewing the logs on an unresponsive terminal via sysrq.
>
> Reuse the existing code from console_flush_on_panic() for
> resetting the sequence numbers, by introducing a new helper
> function __console_rewind_all(). It is safe to be called
> under console_lock().
>
> Try to acquire lock on the console subsystem without waiting.
> If successful, reset the sequence number to oldest available
> record on all consoles and call console_unlock() which will
> automatically flush the messages to the consoles.
>
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -4259,6 +4271,23 @@ void kmsg_dump_rewind(struct kmsg_dump_iter *iter)
> }
> EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
>
> +/**
> + * console_replay_all - replay kernel log on consoles
It should rather be called "console_try_replay_all()" to make it clear
that it is just the best effort.
> + *
> + * Try to obtain lock on console subsystem and replay all
> + * available records in printk buffer on the consoles.
> + * Does nothing if lock is not obtained.
> + *
> + * Context: Any context.
This should be:
* Context: Any, except for NMI
Basically only lockless code is safe in NMI which is not the case here.
> + */
> +void console_replay_all(void)
> +{
> + if (console_trylock()) {
> + __console_rewind_all();
> + /* Consoles are flushed as part of console_unlock(). */
> + console_unlock();
> + }
> +}
> #endif
Otherwise, it looks good. With the two changes:
Reviewed-by: Petr Mladek <pmladek@suse.com>
I am sorry for the late review. I have been snowed under tasks.
Also I had healthy problems.
I have seen a mail that Greg has queued the patch in tty-next.
I am not sure if it still can be fixed. It will be perfectly fine
to change this by a followup patch.
Best Regards,
Petr
next prev parent reply other threads:[~2024-05-22 15:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 10:17 [PATCH v6 0/2] Add support to replay kernel log on consoles via sysrq Sreenath Vijayan
2024-03-13 10:20 ` [PATCH v6 1/2] printk: Add function to replay kernel log on consoles Sreenath Vijayan
2024-05-22 15:18 ` Petr Mladek [this message]
2024-05-23 5:52 ` Sreenath Vijayan
2024-03-13 10:22 ` [PATCH v6 2/2] tty/sysrq: Replay kernel log messages on consoles via sysrq Sreenath Vijayan
2024-04-08 5:53 ` Sreenath Vijayan
2024-05-22 15:31 ` Petr Mladek
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=Zk4MtXxbzGrQhSFA@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=anandakumar.balasubramaniam@sony.com \
--cc=corbet@lwn.net \
--cc=daniel.palmer@sony.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=sreenath.vijayan@sony.com \
--cc=taichi.shimoyashiki@sony.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
all inboxes | Powered by JetHome®