From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH printk v3 10/19] printk: nbcon: Use thread callback if in task context for legacy
Date: Tue, 30 Jul 2024 17:35:56 +0200 [thread overview]
Message-ID: <ZqkIXP22C7ovP-dn@pathway.suse.cz> (raw)
In-Reply-To: <20240722171939.3349410-11-john.ogness@linutronix.de>
On Mon 2024-07-22 19:25:30, John Ogness wrote:
> When printing via console_lock, the write_atomic() callback is
> used for nbcon consoles. However, if it is known that the
> current context is a task context, the write_thread() callback
> can be used instead.
>
> Using write_thread() instead of write_atomic() helps to reduce
> large disabled preemption regions when the device_lock does not
> disable preemption.
>
> This is mainly a preparatory change to allow avoiding
> write_atomic() completely during normal operation if boot
> consoles are registered.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Well, I would update a comment, see below.
> ---
> kernel/printk/internal.h | 4 +--
> kernel/printk/nbcon.c | 54 +++++++++++++++++++++++++++++-----------
> kernel/printk/printk.c | 5 ++--
> 3 files changed, 45 insertions(+), 18 deletions(-)
>
> diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
> index 12605e0aff11..bb02788acc7c 100644
> --- a/kernel/printk/internal.h
> +++ b/kernel/printk/internal.h
> @@ -91,7 +91,7 @@ void nbcon_free(struct console *con);
> enum nbcon_prio nbcon_get_default_prio(void);
> void nbcon_atomic_flush_pending(void);
> bool nbcon_legacy_emit_next_record(struct console *con, bool *handover,
> - int cookie);
> + int cookie, bool use_atomic);
> bool nbcon_kthread_create(struct console *con);
> void nbcon_kthread_stop(struct console *con);
> void nbcon_wake_kthreads(void);
> @@ -174,7 +174,7 @@ static inline void nbcon_free(struct console *con) { }
> static inline enum nbcon_prio nbcon_get_default_prio(void) { return NBCON_PRIO_NONE; }
> static inline void nbcon_atomic_flush_pending(void) { }
> static inline bool nbcon_legacy_emit_next_record(struct console *con, bool *handover,
> - int cookie) { return false; }
> + int cookie, bool use_atomic) { return false; }
> static inline void nbcon_kthread_wake(struct console *con) { }
>
> static inline bool console_is_usable(struct console *con, short flags,
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> index 69cecf97bf24..233ab8f90fef 100644
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1294,9 +1294,10 @@ enum nbcon_prio nbcon_get_default_prio(void)
> }
>
> /*
> - * nbcon_atomic_emit_one - Print one record for an nbcon console using the
> - * write_atomic() callback
> + * nbcon_emit_one - Print one record for an nbcon console using the
> + * specified callback
> * @wctxt: An initialized write context struct to use for this context
> + * @use_atomic: True if the write_atomic() callback is to be used
> *
> * Return: True, when a record has been printed and there are still
> * pending records. The caller might want to continue flushing.
> @@ -1309,7 +1310,7 @@ enum nbcon_prio nbcon_get_default_prio(void)
> * This is an internal helper to handle the locking of the console before
> * calling nbcon_emit_next_record().
This is not completely true when @use_atomic == false. The function
takes only the nbcon context. But also con->device_lock()
is needed for the non-atomic case.
We should either update the commit message. Or it might make sense
to move "con->device_lock()/unlock() stuff to nbcon_emit_one
so that it actually does all the necessary locking.
BTW: We could use this function in nbcon_kthread_func() then as well.
*/
> -static bool nbcon_atomic_emit_one(struct nbcon_write_context *wctxt)
> +static bool nbcon_emit_one(struct nbcon_write_context *wctxt, bool use_atomic)
> {
> struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
>
Otherwise, it looks good.
Best Regards,
Petr
next prev parent reply other threads:[~2024-07-30 15:36 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
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 01/19] printk: nbcon: Clarify nbcon_get_default_prio() context John Ogness
2024-07-26 8:57 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 02/19] printk: nbcon: Consolidate alloc() and init() John Ogness
2024-07-26 11:58 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 03/19] printk: nbcon: Add function for printers to reacquire ownership John Ogness
2024-07-26 12:25 ` Petr Mladek
2024-07-29 8:36 ` John Ogness
2024-07-30 9:24 ` Petr Mladek
2024-08-27 1:32 ` John Ogness
2024-07-22 17:19 ` [PATCH printk v3 04/19] printk: nbcon: Clarify rules of the owner/waiter matching John Ogness
2024-07-26 12:55 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 05/19] printk: Fail pr_flush() if before SYSTEM_SCHEDULING John Ogness
2024-07-26 13:14 ` Petr Mladek
2024-07-26 14:45 ` John Ogness
2024-07-30 9:50 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 06/19] printk: Flush console on unregister_console() John Ogness
2024-07-26 13:23 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 07/19] printk: Add helpers for flush type logic John Ogness
2024-07-23 2:01 ` kernel test robot
2024-07-23 8:39 ` John Ogness
2024-07-23 3:29 ` kernel test robot
2024-07-26 15:51 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 08/19] printk: nbcon: Add context to usable() and emit() John Ogness
2024-07-30 12:30 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 09/19] printk: nbcon: Introduce printer kthreads John Ogness
2024-07-30 14:44 ` John Ogness
2024-07-31 9:59 ` Petr Mladek
2024-07-30 15:16 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 10/19] printk: nbcon: Use thread callback if in task context for legacy John Ogness
2024-07-30 15:35 ` Petr Mladek [this message]
2024-07-22 17:19 ` [PATCH printk v3 11/19] printk: nbcon: Rely on kthreads for normal operation John Ogness
2024-07-23 3:18 ` kernel test robot
2024-07-23 8:51 ` John Ogness
2024-07-31 13:46 ` preffer_ofload param: was: " Petr Mladek
2024-08-01 14:22 ` John Ogness
2024-08-01 15:40 ` Petr Mladek
2024-08-02 7:29 ` John Ogness
2024-08-02 10:19 ` Petr Mladek
2024-07-31 14:06 ` Petr Mladek
2024-07-31 15:25 ` John Ogness
2024-08-01 9:36 ` Petr Mladek
2024-08-01 9:52 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 12/19] printk: Provide helper for message prepending John Ogness
2024-07-22 17:19 ` [PATCH printk v3 13/19] printk: nbcon: Show replay message on takeover John Ogness
2024-07-31 14:59 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 14/19] proc: consoles: Add notation to c_start/c_stop 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
2024-07-22 17:19 ` [PATCH printk v3 16/19] tty: sysfs: Add nbcon support for 'active' John Ogness
2024-07-31 15:09 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 17/19] printk: Implement legacy printer kthread for PREEMPT_RT John Ogness
2024-08-02 11:45 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 18/19] printk: nbcon: Assign nice -20 for printing threads John Ogness
2024-08-02 11:47 ` Petr Mladek
2024-07-22 17:19 ` [PATCH printk v3 19/19] printk: Avoid false positive lockdep report for legacy printing John Ogness
2024-08-02 12:34 ` 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=ZqkIXP22C7ovP-dn@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.