lkml.org 
[lkml]   [2022]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH printk v5 16/40] printk: __pr_flush: use srcu console list iterator
    Date
    Use srcu console list iteration for console list traversal.

    Document why the console_lock is still necessary. Note that this
    is a preparatory change for when console_lock no longer provides
    synchronization for the console list.

    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Petr Mladek <pmladek@suse.com>
    ---
    kernel/printk/printk.c | 10 +++++++++-
    1 file changed, 9 insertions(+), 1 deletion(-)

    diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
    index 3a7b1931b7c9..6666cc27a014 100644
    --- a/kernel/printk/printk.c
    +++ b/kernel/printk/printk.c
    @@ -3560,6 +3560,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
    struct console *c;
    u64 last_diff = 0;
    u64 printk_seq;
    + int cookie;
    u64 diff;
    u64 seq;

    @@ -3570,9 +3571,15 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
    for (;;) {
    diff = 0;

    + /*
    + * Hold the console_lock to guarantee safe access to
    + * console->seq and to prevent changes to @console_suspended
    + * until all consoles have been processed.
    + */
    console_lock();

    - for_each_console(c) {
    + cookie = console_srcu_read_lock();
    + for_each_console_srcu(c) {
    if (con && con != c)
    continue;
    if (!console_is_usable(c))
    @@ -3581,6 +3588,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
    if (printk_seq < seq)
    diff += seq - printk_seq;
    }
    + console_srcu_read_unlock(cookie);

    /*
    * If consoles are suspended, it cannot be expected that they
    --
    2.30.2
    \
     
     \ /
      Last update: 2022-11-16 17:24    [W:2.067 / U:0.748 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site