From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: "Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
linux-serial@vger.kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Tony Lindgren" <tony@atomide.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Justin Chen" <justin.chen@broadcom.com>,
"Jiaqing Zhao" <jiaqing.zhao@linux.intel.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
"Uros Bizjak" <ubizjak@gmail.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
"Lukas Wunner" <lukas@wunner.de>, "Arnd Bergmann" <arnd@arndb.de>,
"Kefeng Wang" <wangkefeng.wang@huawei.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Neeraj Upadhyay" <quic_neeraju@quicinc.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Josh Triplett" <josh@joshtriplett.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>,
rcu@vger.kernel.org, "Ingo Molnar" <mingo@redhat.com>,
"Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>
Subject: [PATCH printk v2 00/26] wire up write_atomic() printing
Date: Sun, 18 Feb 2024 20:03:00 +0106 [thread overview]
Message-ID: <20240218185726.1994771-1-john.ogness@linutronix.de> (raw)
Hi,
This is v3 of a series to wire up the nbcon consoles so that
they actually perform printing using their write_atomic()
callback. v2 is here [0]. For information about the motivation
of the atomic consoles, please read the cover letter of v1 [1].
The main focus of this series:
- For nbcon consoles, always call write_atomic() directly from
printk() caller context for the panic CPU.
- For nbcon consoles, call write_atomic() when unlocking the
console lock.
- Only perform the console_lock()/_unlock() dance if legacy or
boot consoles are registered.
- For legacy consoles, if nbcon consoles are registered, do not
attempt to print from printk() caller context for the panic
CPU until nbcon consoles have had a chance to print the most
significant messages.
- Mark emergency sections. In these sections printk() calls
will only store the messages. Upon exiting the emergency
section, console flushing is triggered via irq_work.
This series does _not_ include threaded printing or nbcon
drivers. Those features will be added in separate follow-up
series.
Note1: With this series, a system with _only_ nbcon consoles
registered will not have any console printing except
on panic. This is on purpose. When nbcon kthreads are
introduced, they will fill this gap.
Note2: Patches 1-3 are already mainline, but not yet in the
printk/for-next tree. They are included for
completeness, but are not actually part of this series.
The changes since v2:
- Eliminate CPU states (normal, emergency, panic) and instead
just track per-cpu emergency nesting.
- Instead of talking about "atomic mode", talk about "using the
write_atomic() callback". This avoids confusion about what
"atomic mode" means (i.e. "atomic" always means the
write_atomic() callback is used).
- Rename atomic_enter()/_exit() to
cpu_emergency_enter()/_exit().
- When entering emergency mode for a CPU, disable preemption
rather than just migration to allow the warning to be
completely handled before permitting rescheduling.
- Implement nbcon locking within the uart port lock wrappers.
This provides synchronization between write_atomic() and
non-printing driver activities (such as changing the baud
rate.)
- Implement a one-way trigger printk_legacy_allow_panic_sync()
to allow legacy consoles to print from the printk() caller
context for the panic CPU. This allows the safe nbcon
consoles to print before falling back to legacy consoles.
Note that if no nbcon consoles are registered, legacy
consoles are always allowed to print from the printk() caller
context.
- Perform unsafe nbcon flushing at the very end of panic before
going into the infinite loop.
- Add nbcon_get_default_prio() helper to return the appropriate
prio for the current CPU.
- Do not assume that if write_atomic() returns false that the
console has been released.
- For nbcon_atomic_emit_one(), rely on @ctxt->backlog rather
than trying to read the next record.
- Rename nbcon_console_emit_next_record() to
nbcon_legacy_emit_next_record() and have it use the same
procedure as console_emit_next_record() (enter printk_safe,
enable console_lock spinning, stop critical timings).
- Add nbcon_atomic_flush_unsafe() to allow flushing nbcon
consoles in an unsafe manner.
- For nbcon flushing, add @stop_seq argument limit how much to
print. This avoids a CPU getting stuck printing endlessly.
- For nbcon flushing, disable irqs to avoid an interrupt
possibly calling into console code and deadlocking on nbcon
ownership.
- The rules for allowing printing from the printk() caller
context are getting quite complex. Move all this logic into
vprintk_emit().
- For console_init_seq(), also consider nbcon consoles.
- For __pr_flush(), only take the console_lock if legacy or
boot consoles are registered.
- For printk_trigger_flush(), do not flush nbcon consoles
directly.
- For defer_console_output(), only trigger
console_lock()/unlock() if legacy or boot consoles are
registered.
- Add detailed kerneldoc for the write_atomic() callback.
- Fix kerneldoc for enum types (cons_flags, nbcon_prio).
- Add extra check to printk_deferred_enter()/_exit() to ensure
it is called with migration disabled.
[0] https://lore.kernel.org/lkml/20230919230856.661435-1-john.ogness@linutronix.de
[1] https://lore.kernel.org/lkml/20230302195618.156940-1-john.ogness@linutronix.de
John Ogness (19):
printk: Consider nbcon boot consoles on seq init
printk: Add notation to console_srcu locking
printk: nbcon: Ensure ownership release on failed emit
printk: nbcon: Implement processing in port->lock wrapper
printk: nbcon: Add detailed doc for write_atomic()
printk: nbcon: Fix kerneldoc for enums
printk: Make console_is_usable() available to nbcon
printk: Let console_is_usable() handle nbcon
printk: Add @flags argument for console_is_usable()
printk: Track registered boot consoles
printk: nbcon: Use nbcon consoles in console_flush_all()
printk: nbcon: Assign priority based on CPU state
printk: nbcon: Add unsafe flushing on panic
printk: Avoid console_lock dance if no legacy or boot consoles
printk: Track nbcon consoles
printk: Coordinate direct printing in panic
panic: Mark emergency section in oops
rcu: Mark emergency section in rcu stalls
lockdep: Mark emergency section in lockdep splats
Randy Dunlap (1):
serial: core: fix kernel-doc for uart_port_unlock_irqrestore()
Sebastian Andrzej Siewior (1):
printk: Check printk_deferred_enter()/_exit() usage
Thomas Gleixner (5):
serial: core: Provide port lock wrappers
serial: core: Use lock wrappers
printk: nbcon: Provide function to flush using write_atomic()
printk: nbcon: Implement emergency sections
panic: Mark emergency section in warn
drivers/tty/serial/8250/8250_port.c | 1 +
include/linux/console.h | 42 +++-
include/linux/printk.h | 30 ++-
include/linux/serial_core.h | 106 +++++++-
kernel/locking/lockdep.c | 5 +
kernel/panic.c | 9 +
kernel/printk/internal.h | 57 +++++
kernel/printk/nbcon.c | 362 +++++++++++++++++++++++++++-
kernel/printk/printk.c | 248 +++++++++++++------
kernel/printk/printk_safe.c | 12 +
kernel/rcu/tree_stall.h | 5 +
11 files changed, 784 insertions(+), 93 deletions(-)
base-commit: e7081d5a9d976b84f61f497316d7c940a4a2e67a
--
2.39.2
next reply other threads:[~2024-02-18 19:04 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-18 18:57 John Ogness [this message]
2024-02-18 18:57 ` [PATCH printk v2 01/26] serial: core: Provide port lock wrappers John Ogness
2024-02-18 18:57 ` [PATCH printk v2 02/26] serial: core: Use " John Ogness
2024-02-18 18:57 ` [PATCH printk v2 03/26] serial: core: fix kernel-doc for uart_port_unlock_irqrestore() John Ogness
2024-02-18 18:57 ` [PATCH printk v2 04/26] printk: Consider nbcon boot consoles on seq init John Ogness
2024-02-20 10:26 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 05/26] printk: Add notation to console_srcu locking John Ogness
2024-02-20 10:29 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 06/26] printk: nbcon: Ensure ownership release on failed emit John Ogness
2024-02-20 15:16 ` Petr Mladek
2024-02-20 16:29 ` John Ogness
2024-02-21 13:23 ` John Ogness
2024-02-18 18:57 ` [PATCH printk v2 07/26] printk: Check printk_deferred_enter()/_exit() usage John Ogness
2024-02-21 9:55 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 08/26] printk: nbcon: Implement processing in port->lock wrapper John Ogness
2024-02-19 12:16 ` Andy Shevchenko
2024-02-19 14:18 ` John Ogness
2024-02-19 14:35 ` Andy Shevchenko
2024-02-19 16:52 ` John Ogness
2024-02-19 17:14 ` Andy Shevchenko
2024-02-23 10:51 ` Petr Mladek
2024-03-11 17:08 ` John Ogness
2024-03-13 9:49 ` John Ogness
2024-03-22 6:23 ` Tony Lindgren
2024-03-27 9:32 ` John Ogness
2024-03-27 13:12 ` Andy Shevchenko
2024-03-14 11:37 ` John Ogness
2024-03-14 14:26 ` Petr Mladek
2024-03-15 15:04 ` John Ogness
2024-03-18 15:42 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 09/26] printk: nbcon: Add detailed doc for write_atomic() John Ogness
2024-02-23 13:11 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 10/26] printk: nbcon: Fix kerneldoc for enums John Ogness
2024-02-18 19:10 ` Randy Dunlap
2024-02-23 13:13 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 11/26] printk: Make console_is_usable() available to nbcon John Ogness
2024-02-18 18:57 ` [PATCH printk v2 12/26] printk: Let console_is_usable() handle nbcon John Ogness
2024-02-18 18:57 ` [PATCH printk v2 13/26] printk: Add @flags argument for console_is_usable() John Ogness
2024-02-18 18:57 ` [PATCH printk v2 14/26] printk: nbcon: Provide function to flush using write_atomic() John Ogness
2024-02-23 15:47 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 15/26] printk: Track registered boot consoles John Ogness
2024-02-23 15:57 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 16/26] printk: nbcon: Use nbcon consoles in console_flush_all() John Ogness
2024-02-23 17:15 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 17/26] printk: nbcon: Assign priority based on CPU state John Ogness
2024-02-29 13:50 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 18/26] printk: nbcon: Add unsafe flushing on panic John Ogness
2024-02-29 13:53 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 19/26] printk: Avoid console_lock dance if no legacy or boot consoles John Ogness
2024-02-29 15:19 ` Petr Mladek
2024-02-29 16:19 ` READ_ONCE: was: " Petr Mladek
2024-02-29 22:51 ` Paul E. McKenney
2024-02-18 18:57 ` [PATCH printk v2 20/26] printk: Track nbcon consoles John Ogness
2024-03-01 9:39 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 21/26] printk: Coordinate direct printing in panic John Ogness
2024-03-01 13:05 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 22/26] printk: nbcon: Implement emergency sections John Ogness
2024-03-01 13:28 ` Petr Mladek
2024-03-01 15:49 ` flush was: " Petr Mladek
2024-03-01 16:12 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 23/26] panic: Mark emergency section in warn John Ogness
2024-03-01 13:57 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 24/26] panic: Mark emergency section in oops John Ogness
2024-03-01 14:55 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 25/26] rcu: Mark emergency section in rcu stalls John Ogness
2024-03-01 15:13 ` Petr Mladek
2024-02-18 18:57 ` [PATCH printk v2 26/26] lockdep: Mark emergency section in lockdep splats John Ogness
2024-02-19 4:14 ` Waiman Long
2024-02-19 11:11 ` John Ogness
2024-02-19 15:07 ` Waiman Long
2024-03-01 15:18 ` 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=20240218185726.1994771-1-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=geert+renesas@glider.be \
--cc=gpiccoli@igalia.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jiangshanlai@gmail.com \
--cc=jiaqing.zhao@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=jpoimboe@kernel.org \
--cc=justin.chen@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=longman@redhat.com \
--cc=lukas@wunner.de \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=qiang.zhang1211@gmail.com \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
--cc=ubizjak@gmail.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
/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).