Skip to contentSkip to conversation

printk: Avoid irq_work for printk_deferred() on suspend

PATCH In review John Ogness 2 participants 3 messages Nov 21, 2025 Printk

lore
Share & tools
lore

John Ogness

author maintainer
#0 lore raw

PATCH 1/1 printk: Avoid irq_work for printk_deferred() on suspend

With commit ("printk: Avoid scheduling irq_work on suspend") the implementation of printk_get_console_flush_type() was modified to avoid offloading when irq_work should be blocked during suspend. Since printk uses the returned flush type to determine what flushing methods are used, this was thought to be sufficient for avoiding irq_work usage during the suspend phase.

However, vprintk_emit() implements a hack to support printk_deferred(). In this hack, the returned flush type is adjusted to make sure no legacy direct printing occurs when printk_deferred() was used.

Because of this hack, the legacy offloading flushing method can still be used, causing irq_work to be queued when it should not be.

Adjust the vprintk_emit() hack to also consider @console_irqwork_blocked so that legacy offloading will not be chosen when irq_work should be blocked.

---
 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
index b1c0d35cf3caa..c27fc7fc64eb5 100644
@@ -2393,7 +2393,7 @@ asmlinkage int vprintk_emit(int facility, int level,
 	/* If called from the scheduler, we can not call up(). */
 	if (level == LOGLEVEL_SCHED) {
 		level = LOGLEVEL_DEFAULT;
-		ft.legacy_offload |= ft.legacy_direct;
+		ft.legacy_offload |= ft.legacy_direct && !console_irqwork_blocked;
 		ft.legacy_direct = false;
 	}
 

base-commit: 26873e3e7f0cb26c45e6ad63656f9fe36b2aa31b

Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · John Ogness

With commit ("printk: Avoid scheduling irq_work on suspend") the implementation of printk_get_console_flush_type() was modified to avoid offloading when irq_work should be blocked during suspend. Since printk uses the returned flush type to determine what flushing methods are used, this was thought to be sufficient for avoiding irq_work usage during the suspend phase.

However, vprintk_emit() implements a hack to support printk_deferred(). In this hack, the returned flush type is adjusted to make sure no legacy direct printing occurs when printk_deferred() was used.

Because of this hack, the legacy offloading flushing method can still be used, causing irq_work to be queued when it should not be.

Quoted 6 lines

Adjust the vprintk_emit() hack to also consider @console_irqwork_blocked so that legacy offloading will not be chosen when irq_work should be blocked.

Thanks for catching and fixing the problem:

Best Regards,
Petr

maintainer
#2 lore raw
In reply to John Ogness
Quoted 16 lines · John Ogness

With commit ("printk: Avoid scheduling irq_work on suspend") the implementation of printk_get_console_flush_type() was modified to avoid offloading when irq_work should be blocked during suspend. Since printk uses the returned flush type to determine what flushing methods are used, this was thought to be sufficient for avoiding irq_work usage during the suspend phase.

However, vprintk_emit() implements a hack to support printk_deferred(). In this hack, the returned flush type is adjusted to make sure no legacy direct printing occurs when printk_deferred() was used.

Because of this hack, the legacy offloading flushing method can still be used, causing irq_work to be queued when it should not be.

Quoted 6 lines

Adjust the vprintk_emit() hack to also consider @console_irqwork_blocked so that legacy offloading will not be chosen when irq_work should be blocked.

JFYI, the patch has been committed into printk/linux.git, branch rework/suspend-fixes.

Best Regards,
Petr