printk, vt: sleep from invalid context bug
Subsystems (2)
Hi,
Since commit 1bc9a28f076f ("printk: Use console_flush_one_record for legacy printer kthread"), I see this warning:
BUG: sleeping function called from invalid context at kernel/printk/printk.c:3431
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 14, name: pr/legacypreempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
4 locks held by pr/legacy/14:
#0: ffffffff807dcdf0 (console_lock){+.+.}-{0:0}, at: legacy_kthread_func+0x40/0x114 #1: ffffffff807dce30 (console_srcu){....}-{0:0}, at: console_flush_one_record+0x0/0x3c8 #2: ffffffff8083af88 (printing_lock){+.+.}-{3:3}, at: vt_console_print+0x48/0x330 #3: ffffffff807df2e8 (rcu_read_lock){....}-{1:3}, at: rt_spin_trylock+0x24/0x138
CPU: 0 UID: 0 PID: 14 Comm: pr/legacy Not tainted 6.19.0-rvvm-09292-g7449f86bafcd #79 PREEMPT_RT
Hardware name: RVVM v0.7-git-g8c45ccf (DT)
Call Trace:
walk_stackframe+0x0/0x80
dump_stack_lvl+0x4e/0x74
rt_spin_trylock+0x9e/0x138
__might_resched+0x19e/0x1e0
fbcon_redraw+0x74/0x1a0
fbcon_scroll+0xf2/0x13c
con_scroll+0x122/0x188
lf+0x6a/0x74
vt_console_print+0x2ac/0x330
console_flush_one_record+0x208/0x3c8
console_flush_one_record+0x3c4/0x3c8
kthread+0xc6/0x100
legacy_kthread_func+0x4c/0x114
prio_changed_stop+0xc/0x10
kthread+0xc6/0x100
ret_from_fork_kernel_asm+0x12/0x18
ret_from_fork_kernel+0xe/0x3fc
rt_spin_unlock+0x56/0x128
kthread_affine_node+0x88/0x8c
ret_from_fork_kernel_asm+0x12/0x18If I understand it correctly, vt_console_print() grabs the spin lock "printing_lock", and then calls fbcon_redraw() which does console_conditional_schedule(), triggering the warning.
Nam
Sebastian Andrzej Siewior
maintainerQuoted 1 line · Nam Cao
Hi,
Hi,
Quoted 2 lines
Since commit
1bc9a28f076f("printk: Useconsole_flush_one_recordfor legacy printer kthread"), I see this warning:
https://lore.kernel.org/all/[email protected]/T/#u
Sebastian
Quoted 38 lines · Nam Cao
Hi,
Since commit
1bc9a28f076f("printk: Useconsole_flush_one_recordfor legacy printer kthread"), I see this warning:BUG: sleeping function called from invalid context at kernel/printk/printk.c:3431
in_atomic(): 0,irqs_disabled(): 0,non_block: 0, pid: 14, name: pr/legacypreempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
4 locks held by pr/legacy/14:
#0:ffffffff807dcdf0(console_lock){+.+.}-{0:0}, at:legacy_kthread_func+0x40/0x114#1:ffffffff807dce30(console_srcu){....}-{0:0}, at:console_flush_one_record+0x0/0x3c8#2:ffffffff8083af88(printing_lock){+.+.}-{3:3}, at:vt_console_print+0x48/0x330#3:ffffffff807df2e8(rcu_read_lock){....}-{1:3}, at:rt_spin_trylock+0x24/0x138CPU: 0 UID: 0 PID: 14 Comm: pr/legacy Not tainted 6.19.0-rvvm-09292-g7449f86bafcd #79 PREEMPT_RT Hardware name: RVVM v0.7-git-g8c45ccf (DT) Call Trace: walk_stackframe+0x0/0x80 dump_stack_lvl+0x4e/0x74 rt_spin_trylock+0x9e/0x138 __might_resched+0x19e/0x1e0 fbcon_redraw+0x74/0x1a0 fbcon_scroll+0xf2/0x13c con_scroll+0x122/0x188 lf+0x6a/0x74 vt_console_print+0x2ac/0x330 console_flush_one_record+0x208/0x3c8 console_flush_one_record+0x3c4/0x3c8 kthread+0xc6/0x100 legacy_kthread_func+0x4c/0x114 prio_changed_stop+0xc/0x10 kthread+0xc6/0x100 ret_from_fork_kernel_asm+0x12/0x18 ret_from_fork_kernel+0xe/0x3fc rt_spin_unlock+0x56/0x128 kthread_affine_node+0x88/0x8c ret_from_fork_kernel_asm+0x12/0x18
Quoted 3 lines
If I understand it correctly,
vt_console_print()grabs the spin lock "printing_lock", and then callsfbcon_redraw()which doesconsole_conditional_schedule(), triggering the warning.
Sebastian has recently sent a patch which should remove the cond_resched(), see
https://lore.kernel.org/all/[email protected]
It seems that the patch has made it upstream in this merge window for 7.0, see the commit 8e9bf8b9e8c0 ("printk, vt, fbcon: Remove console_conditional_schedule()").
Best Regards,
Petr
Quoted 7 lines · Petr Mladek
Sebastian has recently sent a patch which should remove the
cond_resched(), see
https://lore.kernel.org/all/[email protected]It seems that the patch has made it upstream in this merge window for 7.0, see the commit
8e9bf8b9e8c0("printk, vt, fbcon: Removeconsole_conditional_schedule()").
Pulled and the problem goes away. Thanks Sebastian.
Nam