printk: Wait for all reserved records with pr_flush()
authorJohn Ogness <john.ogness@linutronix.de>
Wed, 7 Feb 2024 13:40:58 +0000 (14:46 +0106)
committerPetr Mladek <pmladek@suse.com>
Wed, 7 Feb 2024 16:23:18 +0000 (17:23 +0100)
commitac7d7844c64d15603daa3e905a311ddcfbb4bc91
tree69deb41aa5b9ea502ebc37a8dffbf9a441d99923
parent584528d621459d1a5c31da7a591218ad3bb96d6c
printk: Wait for all reserved records with pr_flush()

Currently pr_flush() will only wait for records that were
available to readers at the time of the call (using
prb_next_seq()). But there may be more records (non-finalized)
that have following finalized records. pr_flush() should wait
for these to print as well. Particularly because any trailing
finalized records may be the messages that the calling context
wants to ensure are printed.

Add a new ringbuffer function prb_next_reserve_seq() to return
the sequence number following the most recently reserved record.
This guarantees that pr_flush() will wait until all current
printk() messages (completed or in progress) have been printed.

Fixes: 3b604ca81202 ("printk: add pr_flush()")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20240207134103.1357162-10-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>
kernel/printk/printk.c
kernel/printk/printk_ringbuffer.c
kernel/printk/printk_ringbuffer.h