* [PATCH printk v3 00/19] add threaded printing + the rest
@ 2024-07-22 17:19 John Ogness
2024-07-22 17:19 ` [PATCH printk v3 15/19] proc: Add nbcon support for /proc/consoles John Ogness
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2024-07-22 17:19 UTC (permalink / raw)
To: Petr Mladek
Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner, linux-kernel,
Greg Kroah-Hartman, linux-fsdevel, Jiri Slaby, linux-serial
Hi,
This is v3 of a series to implement threaded console printing as
well as some other minor pieces (such as proc and sysfs support). v2
is here [0].
For information about the motivation of the nbcon consoles, please
read the cover letter of the original v1 [1].
This series provides the remaining pieces of the printk rework. All
other components are either already mainline or are currently in
linux-next. In particular this series does:
- Implement dedicated printing threads per nbcon console.
- Implement forced threading of legacy consoles for PREEMPT_RT.
- Implement nbcon support for proc and sysfs console-related files.
- Provide a new helper function nbcon_reacquire_nobuf() to allow
nbcon console drivers to reacquire ownership.
Note that this series does *not* provide an nbcon console driver.
That will come in a follow-up series.
Here are the main changes since v2:
- Drop the patch for "threadprintk" boot arg for !PREEMPT_RT.
- Rename variables and functions:
force_printkthreads() -> force_legacy_kthread()
nbcon_reacquire() -> nbcon_reacquire_nobuf()
nbcon_wake_threads() -> nbcon_wake_kthreads()
nbcon_legacy_kthread_func() -> legacy_kthread_func()
wake_up_legacy_kthread() -> legacy_kthread_wake()
@printk_threads_enabled -> @printk_kthreads_running
@nbcon_legacy_kthread -> @printk_legacy_kthread
- Introduce @printk_kthreads_ready to flag when it is allowed to
create kthreads.
- Rename lockdep map functions with updated comments to hopefully
better clarify their purpose.
- The write_thread() callback is now mandatory. write_atomic()
remains optional. (This also simplifies the changes to
drivers/tty/tty_io.c and fs/proc/consoles.c.)
- Merge nbcon_init() into nbcon_alloc(). This simplifies the rules
and more closely resembles the legacy registration.
- Introduce struct console_flush_type to inform which flushing type
to use.
- Introduce flushing type macro printk_get_console_flush_type() for
non-emergency CPU states.
- Introduce flushing type macro
printk_get_emergency_console_flush_type() for emergency CPU
states.
- Remove @printing_via_unlock macro since there is now the flushing
type macros.
- Replace _all_ flushing decisions with calls to new flushing type
macros.
- Introduce helper function nbcon_write_context_set_buf() for
setting up the write context for nbcon printers.
- In nbcon and legacy kthread functions, do not check for spurious
signals.
- In nbcon_kthread_func(), check for kthread_should_stop() inside
the printing loop.
- In nbcon_kthread_func(), add cond_resched() inside the printing
loop.
- In rcuwait_has_sleeper(), avoid unnecessary RCU dereference.
- In nbcon_wake_kthreads(), do not try to wake if kthreads are not
fully available.
- In nbcon_legacy_emit_next_record(), split the atomic/thread cases
before and after printing.
- Use suggested alternative implementation for
console_prepend_message().
- Move all functions to start/stop kthreads into printk.c.
- Introduce printk_kthreads_check_locked() to start/stop kthreads if
needed when the console list has changed.
- Unregister nbcon console if the related kthread printer cannot be
created.
- On failure to start the legacy kthread, unregister all legacy
consoles.
- If all legacy consoles unregister, stop legacy kthread.
- If all nbcon consoles unregister, clear @nbcon_kthreads_running.
- On shutdown, clear @nbcon_kthreads_running.
- In unregister_console_locked(), flush the console before
unregistering.
- Let pr_flush() fail if called _very_ early.
- Do not wake nbcon kthreads in printk_trigger_flush().
- In console_try_replay_all(), add support for the legacy kthread.
- Refactor the series to hopefully provide a cleaner transition to
the final desired stand.
- Split -20 nice for kthreads into a separate patch.
- Rewrite many comments and commit messages as requested.
John Ogness
[0] https://lore.kernel.org/lkml/20240603232453.33992-1-john.ogness@linutronix.de
[1] https://lore.kernel.org/lkml/20230302195618.156940-1-john.ogness@linutronix.de
John Ogness (18):
printk: nbcon: Clarify nbcon_get_default_prio() context
printk: nbcon: Consolidate alloc() and init()
printk: nbcon: Add function for printers to reacquire ownership
printk: nbcon: Clarify rules of the owner/waiter matching
printk: Fail pr_flush() if before SYSTEM_SCHEDULING
printk: Flush console on unregister_console()
printk: Add helpers for flush type logic
printk: nbcon: Add context to usable() and emit()
printk: nbcon: Use thread callback if in task context for legacy
printk: nbcon: Rely on kthreads for normal operation
printk: Provide helper for message prepending
printk: nbcon: Show replay message on takeover
proc: consoles: Add notation to c_start/c_stop
proc: Add nbcon support for /proc/consoles
tty: sysfs: Add nbcon support for 'active'
printk: Implement legacy printer kthread for PREEMPT_RT
printk: nbcon: Assign nice -20 for printing threads
printk: Avoid false positive lockdep report for legacy printing
Thomas Gleixner (1):
printk: nbcon: Introduce printer kthreads
drivers/tty/tty_io.c | 2 +-
fs/proc/consoles.c | 7 +-
include/linux/console.h | 50 +++-
kernel/printk/internal.h | 159 ++++++++++-
kernel/printk/nbcon.c | 530 ++++++++++++++++++++++++++++++-----
kernel/printk/printk.c | 588 +++++++++++++++++++++++++++++++--------
6 files changed, 1137 insertions(+), 199 deletions(-)
base-commit: b18703ea7157f62f02eb0ceb11f6fa0138e90adc
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH printk v3 15/19] proc: Add nbcon support for /proc/consoles
2024-07-22 17:19 [PATCH printk v3 00/19] add threaded printing + the rest John Ogness
@ 2024-07-22 17:19 ` John Ogness
2024-07-31 15:07 ` Petr Mladek
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2024-07-22 17:19 UTC (permalink / raw)
To: Petr Mladek
Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner, linux-kernel,
linux-fsdevel
Update /proc/consoles output to show 'W' if an nbcon console is
registered. Since the write_thread() callback is mandatory, it
enough just to check if it is an nbcon console.
Also update /proc/consoles output to show 'N' if it is an
nbcon console.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
fs/proc/consoles.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index 7036fdfa0bec..b7cab1ad990d 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -21,6 +21,7 @@ static int show_console_dev(struct seq_file *m, void *v)
{ CON_ENABLED, 'E' },
{ CON_CONSDEV, 'C' },
{ CON_BOOT, 'B' },
+ { CON_NBCON, 'N' },
{ CON_PRINTBUFFER, 'p' },
{ CON_BRL, 'b' },
{ CON_ANYTIME, 'a' },
@@ -58,8 +59,8 @@ static int show_console_dev(struct seq_file *m, void *v)
seq_printf(m, "%s%d", con->name, con->index);
seq_pad(m, ' ');
seq_printf(m, "%c%c%c (%s)", con->read ? 'R' : '-',
- con->write ? 'W' : '-', con->unblank ? 'U' : '-',
- flags);
+ ((con->flags & CON_NBCON) || con->write) ? 'W' : '-',
+ con->unblank ? 'U' : '-', flags);
if (dev)
seq_printf(m, " %4d:%d", MAJOR(dev), MINOR(dev));
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH printk v3 15/19] proc: Add nbcon support for /proc/consoles
2024-07-22 17:19 ` [PATCH printk v3 15/19] proc: Add nbcon support for /proc/consoles John Ogness
@ 2024-07-31 15:07 ` Petr Mladek
0 siblings, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2024-07-31 15:07 UTC (permalink / raw)
To: John Ogness
Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner, linux-kernel,
linux-fsdevel
On Mon 2024-07-22 19:25:35, John Ogness wrote:
> Update /proc/consoles output to show 'W' if an nbcon console is
> registered. Since the write_thread() callback is mandatory, it
> enough just to check if it is an nbcon console.
>
> Also update /proc/consoles output to show 'N' if it is an
> nbcon console.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-31 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-22 17:19 [PATCH printk v3 00/19] add threaded printing + the rest John Ogness
2024-07-22 17:19 ` [PATCH printk v3 15/19] proc: Add nbcon support for /proc/consoles John Ogness
2024-07-31 15:07 ` Petr Mladek
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).