The helper will be used on KDB code in the next commits.
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
include/linux/console.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
kernel/printk/internal.h | 44 --------------------------------------------
2 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/include/linux/console.h b/include/linux/console.h
index 8f10d0a85bb4536e4b0dda4e8ccbdf87978bbb4a..67af483574727c00eea1d5a1eacc994755c92607 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -605,6 +605,48 @@ extern bool nbcon_can_proceed(struct nbcon_write_context *wctxt);
extern bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt);
extern bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt);
extern void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt);
+
+/*
+ * Check if the given console is currently capable and allowed to print
+ * records. Note that this function does not consider the current context,
+ * which can also play a role in deciding if @con can be used to print
+ * records.
+ */
+static inline bool console_is_usable(struct console *con, short flags, bool use_atomic)
+{
+ if (!(flags & CON_ENABLED))
+ return false;
+
+ if ((flags & CON_SUSPENDED))
+ return false;
+
+ if (flags & CON_NBCON) {
+ /* The write_atomic() callback is optional. */
+ if (use_atomic && !con->write_atomic)
+ return false;
+
+ /*
+ * For the !use_atomic case, @printk_kthreads_running is not
+ * checked because the write_thread() callback is also used
+ * via the legacy loop when the printer threads are not
+ * available.
+ */
+ } else {
+ if (!con->write)
+ return false;
+ }
+
+ /*
+ * Console drivers may assume that per-cpu resources have been
+ * allocated. So unless they're explicitly marked as being able to
+ * cope (CON_ANYTIME) don't call them until this CPU is officially up.
+ */
+ if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
+ return false;
+
+ return true;
+}
+
#else
static inline void nbcon_cpu_emergency_enter(void) { }
static inline void nbcon_cpu_emergency_exit(void) { }
@@ -612,6 +654,8 @@ static inline bool nbcon_can_proceed(struct nbcon_write_context *wctxt) { return
static inline bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt) { return false; }
static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return false; }
static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
+static inline bool console_is_usable(struct console *con, short flags,
+ bool use_atomic) { return false; }
#endif
extern int console_set_on_cmdline;
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index ef282001f200fdbbacae3171932bf9f049037a85..bef97f2d11793191280bfb46f7f8b13bf2560351 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -112,47 +112,6 @@ bool nbcon_kthread_create(struct console *con);
void nbcon_kthread_stop(struct console *con);
void nbcon_kthreads_wake(void);
-/*
- * Check if the given console is currently capable and allowed to print
- * records. Note that this function does not consider the current context,
- * which can also play a role in deciding if @con can be used to print
- * records.
- */
-static inline bool console_is_usable(struct console *con, short flags, bool use_atomic)
-{
- if (!(flags & CON_ENABLED))
- return false;
-
- if ((flags & CON_SUSPENDED))
- return false;
-
- if (flags & CON_NBCON) {
- /* The write_atomic() callback is optional. */
- if (use_atomic && !con->write_atomic)
- return false;
-
- /*
- * For the !use_atomic case, @printk_kthreads_running is not
- * checked because the write_thread() callback is also used
- * via the legacy loop when the printer threads are not
- * available.
- */
- } else {
- if (!con->write)
- return false;
- }
-
- /*
- * Console drivers may assume that per-cpu resources have been
- * allocated. So unless they're explicitly marked as being able to
- * cope (CON_ANYTIME) don't call them until this CPU is officially up.
- */
- if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
- return false;
-
- return true;
-}
-
/**
* nbcon_kthread_wake - Wake up a console printing thread
* @con: Console to operate on
@@ -204,9 +163,6 @@ static inline bool nbcon_legacy_emit_next_record(struct console *con, bool *hand
static inline void nbcon_kthread_wake(struct console *con) { }
static inline void nbcon_kthreads_wake(void) { }
-static inline bool console_is_usable(struct console *con, short flags,
- bool use_atomic) { return false; }
-
#endif /* CONFIG_PRINTK */
extern bool have_boot_console;
--
2.51.0
On Mon 2025-09-15 08:20:30, Marcos Paulo de Souza wrote: > The helper will be used on KDB code in the next commits. > > Reviewed-by: Petr Mladek <pmladek@suse.com> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Nit :-) The ordering of the tags is important. It defines the timeline of the related actions. The above ordering might be understood as that Petr reviewed an older version of patch. But it was later modified by Marcos. The expected ordering is: Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: Petr Mladek <pmladek@suse.com> It means that Macros developed a patch and Petr reviewed it. The patch was not longer modified. Note the Reviewed-by tag might be preserved even when Marcos later did some cosmetic changes, e.g. fixed a typo, formatting, or rebased. Best Regards, Petr PS: There is no need to send v5 just because of this. I could fix it when committing the patch...
On Wed, 2025-09-17 at 10:57 +0200, Petr Mladek wrote: > On Mon 2025-09-15 08:20:30, Marcos Paulo de Souza wrote: > > The helper will be used on KDB code in the next commits. > > > > Reviewed-by: Petr Mladek <pmladek@suse.com> > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> > > Nit :-) > > The ordering of the tags is important. It defines the timeline of > the related actions. > > The above ordering might be understood as that Petr reviewed > an older version of patch. But it was later modified by Marcos. > > The expected ordering is: > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> > Reviewed-by: Petr Mladek <pmladek@suse.com> > > It means that Macros developed a patch and Petr reviewed it. > The patch was not longer modified. > > Note the Reviewed-by tag might be preserved even when Marcos > later did some cosmetic changes, e.g. fixed a typo, formatting, > or rebased. Got it. I used b4 prep --update-trailers, and it added the Reviewed-by before my Sign-off. But still, this patch didn't change since the last submission, so I thought that it would be ok. But I'll double check next time. > > Best Regards, > Petr > > PS: There is no need to send v5 just because of this. I could fix > it when committing the patch...
On Wed, Sep 17, 2025 at 09:21:48AM -0300, Marcos Paulo de Souza wrote: > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> > > Reviewed-by: Petr Mladek <pmladek@suse.com> > > > > It means that Macros developed a patch and Petr reviewed it. > > The patch was not longer modified. That's not entirely correct. The signed-off trailer is used as the boundary indicating who was the person responsible for collecting the trailers. When the trailers are collected by the original author as part of their iteration cycles, their signed-off-by trailer goes below any trailers they have received. When the trailers are collected by the maintainer, any trailers they retrieve will go below the original author's S-o-b, but above their own. > > > > Note the Reviewed-by tag might be preserved even when Marcos > > later did some cosmetic changes, e.g. fixed a typo, formatting, > > or rebased. > > Got it. I used b4 prep --update-trailers, and it added the Reviewed-by > before my Sign-off. But still, this patch didn't change since the last > submission, so I thought that it would be ok. That is the correct behaviour. -K
On Wed 2025-09-17 10:07:47, Konstantin Ryabitsev wrote: > On Wed, Sep 17, 2025 at 09:21:48AM -0300, Marcos Paulo de Souza wrote: > > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> > > > Reviewed-by: Petr Mladek <pmladek@suse.com> > > > > > > It means that Macros developed a patch and Petr reviewed it. > > > The patch was not longer modified. > > That's not entirely correct. The signed-off trailer is used as the boundary > indicating who was the person responsible for collecting the trailers. When > the trailers are collected by the original author as part of their iteration > cycles, their signed-off-by trailer goes below any trailers they have > received. This is an interesting interpretation. I am just curious. Has this already been discussed anywhere, please? It seems that the ordering of the trailers is not much described in the process documentation, see https://docs.kernel.org/process/submitting-patches.html Best Regards, Petr
© 2016 - 2025 Red Hat, Inc.