printk: Prevent printk kthreads from blocking direct console handling
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | printk: Block console kthreads when direct printing will be requiredkernel/ | +3 | 2 replies | |
| 2/2 | printk: Wait for the global console lock when the system is going downinclude/ kernel/ kernel/ +3 more | +47 | 0 replies |
Reviews trailers per patch
None of the 2 patches has a Reviewed-by or Acked-by.
| Patch | Paul E. McKenney |
|---|---|
| Series | T-b |
| 1/2 | |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/2] printk: Prevent printk kthreads from blocking direct console handling
There are reports that console kthreads prevented printing messages during panic() or shutdown(), see
In both situations, printk() correctly tries to flush the consoles directly but it fails to get the global console_lock(). Both problems went away with these patches:
1st patch blocks console kthreads so that they do not start handling new messages when the direct printing is preferred by the system state. It is probably enough on its own. It solves the problem when the kthreads actively did the wrong thing.
2nd patch allows to wait for the console kthreads to release the lock in any context. It should make it more reliable. It would have been useful even for the legacy code.
More possible improvements:
+ the waiting might be necessary also in the suspend code paths
+ convert con->mutex to con->spinlock to avoid blocking
the global console_lock() when sleeping with con->lock
+ at least disable preemption around console_emit_next_record() in console kthread to avoid sleeping in the console driver code
+ somehow change the priority of the kthread so that it gets scheduled immediately when the scheduler works
Petr Mladek (2):
printk: Block console kthreads when direct printing will be required
printk: Wait for the global console lock when the system is going down
include/linux/printk.h | 5 +++++ kernel/panic.c | 2 ++ kernel/printk/internal.h | 2 ++ kernel/printk/printk.c | 8 +++++++- kernel/printk/printk_safe.c | 32 ++++++++++++++++++++++++++++++++ kernel/reboot.c | 2 ++ 6 files changed, 50 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.3