实时 Linux 正式成为内核的一部分 Real-time Linux is officially part of the kernel

原始链接: https://arstechnica.com/gadgets/2024/09/real-time-linux-is-officially-part-of-the-kernel-after-decades-of-debate/

使用激光放大或切割金属的能力需要精确的计时,尤其是在编码方面。 实时 Linux 允许如此精确的计时,已成为音频设备、工业焊接激光器和航天器等专用设备的一个选项。 然而,由于主流 Linux 内核缺乏官方认可以及依赖 QNX 等第三方工具等因素,它的采用历来受到限制。 从 6.12 版本开始,随着 PREEMPT_RT 补丁集即将合并到主线内核中,这种情况有望改变。 Linux 的创建者 Linus Torvalds 最近在欧洲开源峰会上支持了这一开发。 PREEMPT_RT 包括对传统 Linux“printk”调试工具的修改,通过减少延迟和启用线程/原子控制台支持来实现更高效的实时操作。 虽然这一进步可能不会对典型的桌面 Linux 使用产生重大影响,但它为需要绝对执行时间的关键系统带来了巨大的好处,例如控制车辆制动系统、引导计算机数控 (CNC) 机器以及管理复杂的多核处理任务的系统。 通过将 PREEMPT_RT 直接合并到主线内核中,创建和维护实时应用程序变得更加简单,而无需求助于外部补丁。 未来,这一变化可能会改变面向利基行业的实时操作系统服务的格局,从而有可能带来更广泛的可用性并降低成本。 例如,流行的 Linux 发行版 Ubuntu 计划从 2023 年开始提供一个实时变体及其标准版本,只能通过付费订阅来访问。 这一举措使 Ubuntu 能够满足机器人、自动化、嵌入式系统和其他实时应用程序中的特定需求。 Linus Torvalds 本人在十多年前就强调了 PREEMPT_RT 在工业激光控制方面的潜力; 今天,它被纳入主线内核标志着实现这一愿景的重要一步。

The ability to enlarge or cut metals with lasers requires precision timing, especially in the context of coding. Real-Time Linux, which allows for such precise timing, has been available as an option for specialized equipment like audio gear, industrial welding lasers, and spacecraft. However, its adoption has historically been limited due to factors such as lack of official acceptance into the mainstream Linux kernel and reliance on third-party tools like QNX. This situation is poised to change with the impending merger of the PREEMPT_RT patchset into the mainline kernel, starting with the 6.12 release. Linus Torvalds, creator of Linux, recently endorsed this development during the Open Source Summit Europe. PREEMPT_RT includes modifications to the traditional Linux 'printk' debugging tool, allowing for more efficient real-time operations by reducing latency and enabling threaded/atomic console support. While this advancement may not significantly impact typical desktop Linux usage, it offers substantial benefits to critical systems requiring absolute execution times, such as those controlling vehicle brake systems, guiding computer numerical control (CNC) machines, and managing intricate multicore processing tasks. By incorporating PREEMPT_RT directly into the mainline kernel, it becomes simpler to create and maintain real-time applications without resorting to outside patches. In the future, this change could alter the landscape of real-time operating system services catering to niche industries, potentially leading to broader availability and reduced cost. For instance, Ubuntu, a popular Linux distribution, plans to offer a real-time variant alongside its standard offering from 2023, accessible only through paid subscriptions. This move positions Ubuntu to address specific needs within robotics, automation, embedded systems, and other real-time applications. Linus Torvalds himself emphasized the potential of PREEMPT_RT for industrial laser control over a decade ago; today, its inclusion in the mainline kernel marks a significant step forward in realizing that vision.


CNC laser skipping across a metal surface, leaving light trails in long exposure.
Enlarge / Cutting metal with lasers is hard, but even harder when you don't know the worst-case timings of your code.

Getty Images

As is so often the case, a notable change in an upcoming Linux kernel is both historic and no big deal.

If you wanted to use "Real-Time Linux" for your audio gear, your industrial welding laser, or your Mars rover, you have had that option for a long time (presuming you didn't want to use QNX or other alternatives). Universities started making their own real-time kernels in the late 1990s. A patch set, PREEMPT_RT, has existed since at least 2005. And some aspects of the real-time work, like NO_HZ, were long ago moved into the mainline kernel, enabling its use in data centers, cloud computing, or anything with a lot of CPUs.

But officialness still matters, and in the 6.12 kernel, PREEMPT_RT will likely be merged into the mainline. As noted by Steven Vaughan-Nichols at ZDNet, the final sign-off by Linus Torvalds occurred while he was attending Open Source Summit Europe. Torvalds wrote the original code for printk, a debugging tool that can pinpoint exact moments where a process crashes, but also introduces latency that runs counter to real-time computing. The Phoronix blog has tracked the progress of PREEMPT_RT into the kernel, along with the printk changes that allowed for threaded/atomic console support crucial to real-time mainlining.

What does this mean for desktop Linux? Not much. Beyond high-end audio production or replication (and even that is debatable), a real-time kernel won't likely make windows snappier or programs zippier. But the guaranteed execution and worst-case latency timings a real-time Linux provides are quite useful to, say, the systems that monitor car brakes, guide CNC machines, and regulate fiendishly complex multi-CPU systems. Having PREEMPT-RT in the mainline kernel makes it easier to maintain a real-time system, rather than tend to out-of-tree patches.

It will likely change things for what had been, until now, specialty providers of real-time OS solutions for mission-critical systems. Ubuntu, for example, started offering a real-time version of its distribution in 2023 but required an Ubuntu Pro subscription for access. Ubuntu pitched its release at robotics, automation, embedded Linux, and other real-time needs, with the fixes, patches, module integration, and testing provided by Ubuntu.

"Controlling a laster with Linux is crazy," Torvalds said at the Kernel Summit of 2006, "but everyone in this room is crazy in his own way. So if you want to use Linux to control an industrial welding laser, I have no problem with your using PREEMPT_RT." Roughly 18 years later, Torvalds and the kernel team, including longtime maintainer and champion-of-real-time Steven Rostedt, have made it even easier to do that kind of thing.

相关文章
联系我们 contact @ memedata.com