实时 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 在工业激光控制方面的潜力; 今天,它被纳入主线内核标志着实现这一愿景的重要一步。

Linux 内核实现了实时支持,允许精确计时并最大限度地减少某些应用程序中的延迟。 内核版本 6.11 包括 Thomas Gleixner 和他的团队所做的更改。 改进包括与早期版本相比减少了补丁大小以及增加了配置选项。 用于评估这些改进的影响的值得注意的工具包括循环测试实用程序,用于测量跨 CPU 内核的中断延迟。 以前,最坏情况下的延迟可能会超过十毫秒,而通过实时补丁,延迟会在微秒内降至个位数。 然而,为了实现一致的低延迟,必须禁用省电模式。 实时 Linux 内核允许及时运行复杂的交互进程,提供高系统吞吐量,同时保持速度和精度。 虽然这一发展可能不会对普通用户产生重大影响,但对于机器人、工业控制和其他需要快速响应的嵌入式系统至关重要。 Ubuntu 去年推出了实时发行版,仅适用于专业订阅。 这一最新进展标志着在主流 Linux 发行版中实现实时功能的一个重要里程碑。
相关文章

原文
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