lkml.org 
[lkml]   [2022]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: replay log: Re: [PATCH printk v4 38/39] printk: relieve console_lock of list synchronization duties
On Wed 2022-11-16 10:14:35, John Ogness wrote:
> Hi Petr,
>
> Sorry, console_flush_all() only loses the console_lock if there was a
> handover. Here is a new complete suggestion from me.
>
> if (newcon->flags & (CON_PRINTBUFFER | CON_BOOT)) {
> /* Get a consistent copy of @syslog_seq. */
> mutex_lock(&syslog_lock);
> newcon->seq = syslog_seq;
> mutex_unlock(&syslog_lock);
> } else {
> /* Begin with next message added to ringbuffer. */
> newcon->seq = prb_next_seq(prb);
>
> /*
> * If any enabled boot consoles are due to be unregistered
> * shortly, some may not be caught up and may be the same
> * device as @newcon. Since it is not known which boot console
> * is the same device, flush all consoles and, if necessary,
> * start with the message of the enabled boot console that is
> * the furthest behind.
> */
> if (bootcon_registered && !keep_bootcon) {
> bool handover;
>
> /*
> * Hold the console_lock to guarantee safe access to
> * console->seq.
> */
> console_lock();
>
> /*
> * Flush all consoles and set the console to start at
> * the next unprinted sequence number.
> */
> if (!console_flush_all(true, &newcon->seq, &handover)) {
> /*
> * Flushing failed. Just choose the lowest
> * sequence of the enabled boot consoles.
> */
>
> /*
> * If there was a handover, this context no
> * longer holds the console_lock.
> */
> if (handover)
> console_lock();
>
> newcon->seq = prb_next_seq(prb);
> for_each_console(con) {
> if ((con->flags & CON_BOOT) &&
> (con->flags & CON_ENABLED) &&
> con->seq < newcon->seq) {
> newcon->seq = con->seq;
> }
> }
> }
>
> console_unlock();
> }

It looks good to me.

Now, we just need to agree how to add this into the patchset.
My proposal is to:

1. patch: hide the original code into a function, .e.g. console_init_seq()
2. patch: move console_init_seq() and add the above trickery

Do both before the 3rd patch in this patchset. It moved the code
outside console_lock() guarded section.

Best Regards,
Petr

\
 
 \ /
  Last update: 2022-11-16 10:51    [W:0.144 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site