]> git.ipfire.org Git - thirdparty/linux.git/commit
printk: console_flush_one_record() code cleanup
authorPetr Mladek <pmladek@suse.com>
Mon, 20 Oct 2025 15:38:06 +0000 (16:38 +0100)
committerPetr Mladek <pmladek@suse.com>
Thu, 23 Oct 2025 15:11:13 +0000 (17:11 +0200)
commitba00f7c4d0051e351ee284490c531a004fca4c7d
tree87100d91e549958f244f2615bb6868ba21c29cab
parent741ea7aa95dd9ac77f861e7d0961d8d231ac8448
printk: console_flush_one_record() code cleanup

console_flush_one_record() and console_flush_all() duplicate several
checks. They both want to tell the caller that consoles are not
longer usable in this context because it has lost the lock or
the lock has to be reserved for the panic CPU.

Remove the duplication by changing the semantic of the function
console_flush_one_record() return value and parameters.

The function will return true when it is able to do the job. It means
that there is at least one usable console. And the flushing was
not interrupted by a takeover or panic_on_other_cpu().

Also replace the @any_usable parameter with @try_again. The @try_again
parameter will be set to true when the function could do the job
and at least one console made a progress.

Motivation:

The callers need to know when

  + they should continue flushing => @try_again
  + when the console is flushed => can_do_the_job(return) && !@try_again
  + when @next_seq is valid => same as flushed
  + when lost console_lock => @takeover

The proposed change makes it clear when the function can do
the job. It simplifies the answer for the other questions.

Also the return value from console_flush_one_record() can
be used as return value from console_flush_all().

Reviewed-by: John Ogness <john.ogness@linutronix.de>
Link: https://patch.msgid.link/20251020-printk_legacy_thread_console_lock-v3-2-00f1f0ac055a@thegoodpenguin.co.uk
[pmladek@suse.com: Fixed type of any_usable variable reported by John]
Signed-off-by: Petr Mladek <pmladek@suse.com>
kernel/printk/printk.c