linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sreenath Vijayan <sreenath.vijayan@sony.com>
To: Petr Mladek <pmladek@suse.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: Thu, 23 May 2024 11:22:58 +0530	[thread overview]
Message-ID: <Zk7ZuhHGW2R6N1E4@sreenath.vijayan@sony.com> (raw)
In-Reply-To: <Zk4MtXxbzGrQhSFA@pathway.suse.cz>

On Wed, May 22, 2024 at 05:18:13PM +0200, Petr Mladek wrote:
> 
> 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.
>

Ok, noted.
 
> > + *
> > + * 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.
> 

Understood.

> > + */
> > +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

Thank you for the review comments. As the patch has been merged to
mainline, I will soon send a followup patch with "Fixes:" tag.

Regards,
Sreenath

  reply	other threads:[~2024-05-23  5:53 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
2024-05-23  5:52     ` Sreenath Vijayan [this message]
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=Zk7ZuhHGW2R6N1E4@sreenath.vijayan@sony.com \
    --to=sreenath.vijayan@sony.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=pmladek@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --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;
as well as URLs for NNTP newsgroup(s).