All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH printk v3 0/2] nbcon irq_work fixes
@ 2026-09-01  9:31 John Ogness
  2026-09-01  9:31 ` [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: John Ogness @ 2026-09-01  9:31 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

Hi,

This is v3 of a series to address some irq_work issues with nbcon.
Initially motivated as a workaround for hardware-related regressions
reported [0], it turns out that the workaround is actually a nice
improvement for nbcon deferred printing in general.

v2 is here [1].

The changes since v2:

- On nbcon_free(), perform the irq_work flush before stopping the
  kthread printer.

- Rework the commit message of patch 2/2 so that reducing interrupts
  is the primary motivation and the Tegra workaround is a secondary
  "benefit". I really want the Tegra workaround information to stay
  in the commit message because it is historically significant.

John Ogness

[0] https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
[1] https://lore.kernel.org/lkml/20260828140218.232439-1-john.ogness@linutronix.de

John Ogness (2):
  printk/nbcon: Flush nbcon_irq_work in nbcon_free()
  printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY

 kernel/printk/nbcon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


base-commit: ffe0486b139e45cd9c9ca2584f04a1910fe4f8a6
-- 
2.47.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free()
  2026-09-01  9:31 [PATCH printk v3 0/2] nbcon irq_work fixes John Ogness
@ 2026-09-01  9:31 ` John Ogness
  2026-09-02  9:06   ` Petr Mladek
  2026-09-01  9:31 ` [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
  2026-09-02 10:02 ` [PATCH printk v3 0/2] nbcon irq_work fixes Petr Mladek
  2 siblings, 1 reply; 6+ messages in thread
From: John Ogness @ 2026-09-01  9:31 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel

Ensure any pending nbcon_irq_work is flushed before allowing the
console to be recycled.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/nbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index a5921a84a80ed..68f77afee9106 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1837,6 +1837,8 @@ void nbcon_free(struct console *con)
 	/* Synchronize the kthread stop. */
 	lockdep_assert_console_list_lock_held();
 
+	irq_work_sync(&con->irq_work);
+
 	if (printk_kthreads_running) {
 		nbcon_kthread_stop(con);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
  2026-09-01  9:31 [PATCH printk v3 0/2] nbcon irq_work fixes John Ogness
  2026-09-01  9:31 ` [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
@ 2026-09-01  9:31 ` John Ogness
  2026-09-01  9:53   ` John Ogness
  2026-09-02 10:02 ` [PATCH printk v3 0/2] nbcon irq_work fixes Petr Mladek
  2 siblings, 1 reply; 6+ messages in thread
From: John Ogness @ 2026-09-01  9:31 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

Change the nbcon_irq_work to be IRQ_WORK_LAZY, thus not raising
an IRQ upon irq_work queuing. The irq_work is then handled on the
next kernel tick. This additional delay is acceptable because
nbcon_irq_work is only responsible for non-emergency deferred
printing, which is delayed anyway. This has the benefit of not
needing to raise an IRQ for each printk() call.

On a side note, the Tegra20 and Tegra30 platforms can hang if an
irq_work IRQ is raised while entering cpuidle states. This problem
was reproducible by calling printk() while entering cpuidle. So
this change also provides a workaround for these platforms (as long
as they are not running tickless).

Link: https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/nbcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 68f77afee9106..d17704fe93ae1 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1782,7 +1782,7 @@ bool nbcon_alloc(struct console *con)
 	}
 
 	rcuwait_init(&con->rcuwait);
-	init_irq_work(&con->irq_work, nbcon_irq_work);
+	con->irq_work = IRQ_WORK_INIT_LAZY(nbcon_irq_work);
 	atomic_long_set(&ACCESS_PRIVATE(con, nbcon_prev_seq), -1UL);
 	nbcon_state_set(con, &state);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
  2026-09-01  9:31 ` [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
@ 2026-09-01  9:53   ` John Ogness
  0 siblings, 0 replies; 6+ messages in thread
From: John Ogness @ 2026-09-01  9:53 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

On 2026-09-01, John Ogness <john.ogness@linutronix.de> wrote:
> Change the nbcon_irq_work to be IRQ_WORK_LAZY, thus not raising
> an IRQ upon irq_work queuing. The irq_work is then handled on the
> next kernel tick. This additional delay is acceptable because
> nbcon_irq_work is only responsible for non-emergency deferred
> printing, which is delayed anyway. This has the benefit of not
> needing to raise an IRQ for each printk() call.
>
> On a side note, the Tegra20 and Tegra30 platforms can hang if an
> irq_work IRQ is raised while entering cpuidle states. This problem
> was reproducible by calling printk() while entering cpuidle. So
> this change also provides a workaround for these platforms (as long
> as they are not running tickless).
>
> Link: https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
> Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Sorry, I failed to gather the previous tags:

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free()
  2026-09-01  9:31 ` [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
@ 2026-09-02  9:06   ` Petr Mladek
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2026-09-02  9:06 UTC (permalink / raw)
  To: John Ogness
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel

On Tue 2026-09-01 11:37:42, John Ogness wrote:
> Ensure any pending nbcon_irq_work is flushed before allowing the
> console to be recycled.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Thanks for moving the call. It looks good to me:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH printk v3 0/2] nbcon irq_work fixes
  2026-09-01  9:31 [PATCH printk v3 0/2] nbcon irq_work fixes John Ogness
  2026-09-01  9:31 ` [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
  2026-09-01  9:31 ` [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
@ 2026-09-02 10:02 ` Petr Mladek
  2 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2026-09-02 10:02 UTC (permalink / raw)
  To: John Ogness
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

On Tue 2026-09-01 11:37:41, John Ogness wrote:
> Hi,
> 
> This is v3 of a series to address some irq_work issues with nbcon.
> Initially motivated as a workaround for hardware-related regressions
> reported [0], it turns out that the workaround is actually a nice
> improvement for nbcon deferred printing in general.
> 
> v2 is here [1].
> 
> The changes since v2:
> 
> - On nbcon_free(), perform the irq_work flush before stopping the
>   kthread printer.
> 
> - Rework the commit message of patch 2/2 so that reducing interrupts
>   is the primary motivation and the Tegra workaround is a secondary
>   "benefit". I really want the Tegra workaround information to stay
>   in the commit message because it is historically significant.
> 
> John Ogness
> 
> [0] https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
> [1] https://lore.kernel.org/lkml/20260828140218.232439-1-john.ogness@linutronix.de
> 
> John Ogness (2):
>   printk/nbcon: Flush nbcon_irq_work in nbcon_free()
>   printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
> 
>  kernel/printk/nbcon.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

JFYI, the patchset has been comitted into printk/linux.git,
branch for-7.3-irq-work-fixes.

I am going to give it few days in linux-next. Then I will create
a pull request for 7.3 unless any problems got reported.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-02 10:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01  9:31 [PATCH printk v3 0/2] nbcon irq_work fixes John Ogness
2026-09-01  9:31 ` [PATCH printk v3 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
2026-09-02  9:06   ` Petr Mladek
2026-09-01  9:31 ` [PATCH printk v3 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
2026-09-01  9:53   ` John Ogness
2026-09-02 10:02 ` [PATCH printk v3 0/2] nbcon irq_work fixes Petr Mladek

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.