Kernel watch
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to.
Linus Torvalds announced the release of Linux 5.14, which came mere days after the 30th birthday of his very first Linux announcement. The new kernel includes features such as “core scheduling” (a defence against speculation attacks that span multiple threads) and a new io priority “rq-qos” Quality of Service policy that allows I/O bandwidth to be prioritised within different Linux cgroups.
With the release of 5.14 came the opening of the “merge window” for what will become Linux 5.15. Among the many patches pulled thus far is the core real time “preemption” locking code, and support for scheduling on “asymmetric” systems such as those with Arm “big.LITTLE” clusters of “big” (high performance) and “little” (high efficiency) cores where each of those cores doesn’t have uniform architectural capabilities. A classic example comes when some Arm cores don’t support 32-bit, but a similar situation could even arise on x86 with some cores not supporting AVX512 vector operations. Other more complex constraints are likely in future.
Real Time Linux now a step closer
As an Operating System, the primary job of the Linux kernel is to juggle various platform resources provided by hardware and make those available to application software programs that need to share them in an efficient manner. A key part of this is scheduling time for each application process that wants to run on the (limited number of) CPU cores available. Traditionally, each running application process (known as a “task” within the kernel) was given a fixed “quanta” of CPU time before the next, and those processes with a higher priority got to have their time quanta before lower priority tasks. Periodically, the kernel would interrupt whatever was running on a given CPU to service a piece of hardware.
This works well enough much of the time, but there are times when whatever the kernel is doing must be preempted right now in order to run a more important task. There are a number of challenges to implement this, not the least of which is that the kernel frequently makes use of “spinlocks” to protect what are called “critical sections” of kernel code that should not be interrupted. To get around this, the “PREEMPT_ RT” patch series converts these into preemptable locks called “rtmutexes”. The fun isn’t over there however because real-time systems classically may suffer from a problem known as “Priority Inversion”.
Priority Inversion famously struck the NASA Mars Pathfinder program. A rover was on the surface of the red planet when a low-priority maintenance task was able to prevent another low-priority task from making progress. Unfortunately, a high-priority (critical) task was waiting for a resource owned by the second lowpriority task that never made progress and thus never released the resource. Linux solves this using an approach originally motivated from academia: Priority Inheritance. Whenever a highpriority task is blocked on a lock that a lowerpriority task is holding, the lower-priority task is temporarily “boosted” up in priority to the same as the high-priority task in order to progress.