Linux 6.7 Continues Work On printk Threaded Printing
One of the last major blockers before the remaining real-time "PREEMPT_RT" patches can be upstreamed is sorting out threaded / atomic console printing. With the in-development Linux 6.7 kernel, there's been more work upstreamed in that endeavor.
For Linux 6.7 are further preparations for printk kthread handling with a per-console lock now being introduced. Today's printk pull request explains:
Perhaps for the v6.8 kernel cycle we'll see the remaining printk threading work finished and who knows if we'll then see the PREEMPT_RT code wrapped up too at the same time. In any event, the real-time kernel patches didn't make it upstream for 2023 but hopefully it won't be far into 2024 before finally seeing this long sought goal realized. As it stands now there are several dozen RT patches still being maintained out-of-tree.
For Linux 6.7 are further preparations for printk kthread handling with a per-console lock now being introduced. Today's printk pull request explains:
Another preparation step for introducing printk kthreads. The main piece is a per-console lock with several features:
- Support three priorities: normal, emergency, and panic. They will be defined by a context where the lock is taken. A context with a higher priority is allowed to take over the lock from a context with a lower one.
The plan is to use the emergency context for Oops and WARN() messages, and also by watchdogs.
The panic() context will be used on panic CPU.
- The owner might enter/exit regions where it is not safe to take over the lock. It allows the take over the lock a safe way in the middle of a message.
For example, serial drivers emit characters one by one. And the serial port is in a safe state in between.
Only the final console_flush_in_panic() will be allowed to take over the lock even in the unsafe state (last chance, pray, and hope).
- A higher priority context might busy wait with a timeout. The current owner is informed about the waiter and releases the lock on exit from the unsafe state.
- The new lock is safe even in atomic contexts, including NMI.
Another change is a safe manipulation of per-console sequence number counter under the new lock.
Perhaps for the v6.8 kernel cycle we'll see the remaining printk threading work finished and who knows if we'll then see the PREEMPT_RT code wrapped up too at the same time. In any event, the real-time kernel patches didn't make it upstream for 2023 but hopefully it won't be far into 2024 before finally seeing this long sought goal realized. As it stands now there are several dozen RT patches still being maintained out-of-tree.
14 Comments