Rust for Linux
{{Short description|Project for adding Rust language to the Linux kernel}}
{{Infobox software
| title = Rust for Linux
| logo = Rust for Linux logo.svg
| logo caption = The mascot of Linux, Tux, superimposed over Rust's logo
| developer = {{plainlist|
- Community contributors
- Miguel Ojeda
}}
| released = {{Start date and age|2022|10|01}}
| ver layout =
| repo = {{URL|https://github.com/Rust-for-Linux/linux}}
| programming language = Rust
| middleware =
| operating system = Linux
| platform =
| standard =
| language = English
| license = GPL-2.0-only with Linux-syscall-note.
| website = https://rust-for-linux.com/
}}
Rust for Linux is an ongoing project started in 2020 to add Rust as a programming language that can be used within the Linux kernel software, which has been written using C and assembly only. This project aims to leverage Rust's memory safety to reduce bugs when writing kernel drivers.{{cite news |last1=Vaughan-Nichols |first1=Steven |title=Rust in Linux: Where we are and where we're going next |url=https://www.zdnet.com/article/rust-in-linux-where-we-are-and-where-were-going-next/ |access-date=31 August 2024 |publisher=zdnet}}
Progress has been slower than hoped by both Rust advocates and Linus Torvalds, lead of the Linux kernel project.{{cite news |title=Linus Torvalds talks AI, Rust adoption, and why the Linux kernel is 'the only thing that matters' |url=https://www.zdnet.com/article/linus-torvalds-talks-ai-rust-adoption-and-why-the-linux-kernel-is-the-only-thing-that-matters/ |access-date=31 August 2024 |publisher=zdnet |date=23 August 2024}}
In December 2023, the first drivers written in Rust were accepted, and released in version 6.8.{{cite news |last1=Das |first1=Ankush |title=Linux Kernel 6.8 Released! Goes Big On Hardware Support |url=https://news.itsfoss.com/linux-kernel-6-8-release/ |access-date=4 September 2024 |publisher=news.itsfoss.com |date=11 March 2024}}
History
The Linux kernel has been primarily written in C and assembly languages since its first release in 1991. Around 1997, the addition of C++ was considered and experimented upon for two weeks before being scrapped.{{Cite web |last=Claburn |first=Thomas |title=Linus Torvalds says Rust is coming to the Linux kernel |url=https://www.theregister.com/2022/06/23/linus_torvalds_rust_linux_kernel/ |date=2022-06-23 |access-date=2022-07-25 |website=The Register |language=en |archive-date=2022-07-28 |archive-url=https://web.archive.org/web/20220728221531/https://www.theregister.com/2022/06/23/linus_torvalds_rust_linux_kernel/ |url-status=live }} Rust was created in 2006 and combines the performance of low-level programming languages (such as C) with a focus on memory safety and a user-friendly tool set and syntax.{{Cite journal |last=Perkel |first=Jeffrey M. |date=2020-12-01 |title=Why scientists are turning to Rust |url=https://www.nature.com/articles/d41586-020-03382-2 |journal=Nature |language=en |volume=588 |issue=7836 |pages=185–186 |doi=10.1038/d41586-020-03382-2 |pmid=33262490 |bibcode=2020Natur.588..185P |s2cid=227251258 |access-date=2022-08-04 |archive-date=2022-05-06 |archive-url=https://web.archive.org/web/20220506040523/https://www.nature.com/articles/d41586-020-03382-2 |url-status=live }}
An example Linux external loadable kernel module created using the Rust language was published by Taesoo Kim in 2013.{{cite news |last1=Vaughan-Nichols |first1=Steven J. |title=Rust in the Linux Kernel |url=https://thenewstack.io/rust-in-the-linux-kernel/ |access-date=31 August 2024 |work=thenewstack.io |date=5 October 2022}}{{cite web |last1=Ojeda |first1=Miguel |title=Memory Safety for the World's Largest Software Project |url=https://www.memorysafety.org/blog/memory-safety-in-linux-kernel/ |access-date=31 August 2024 |date=23 June 2022 }}
The Rust for Linux project was announced in 2020 in the Linux kernel mailing list with goal of adding Rust as a programming language that could be used within the Linux project.{{Cite web |first=Sergio De |last=Simone |title=Using Rust to Write Safe and Correct Linux Kernel Drivers |url=https://www.infoq.com/news/2021/04/rust-linux-kernel-development/ |date=2021-04-27 |access-date=2022-08-04 |website=InfoQ |language=en |archive-date=2022-09-22 |archive-url=https://web.archive.org/web/20220922094134/https://www.infoq.com/news/2021/04/rust-linux-kernel-development/ |url-status=live }} At the Open Source Summit 2022, Linus Torvalds stated that the incorporation of the project's work could begin as soon as the Linux 5.20 release, later named as Linux 6.0.{{Cite web |first=Steven |last=Vaughan-Nichols |title=Linus Torvalds is cautiously optimistic about bringing Rust into Linux kernel's next release |url=https://www.zdnet.com/article/linus-torvalds-is-cautiously-optimistic-about-bringing-rust-into-the-linux-kernels-next-release/ |date=2022-06-27 |access-date=2022-08-04 |website=ZDNet |language=en |archive-date=2022-08-12 |archive-url=https://web.archive.org/web/20220812183421/https://www.zdnet.com/article/linus-torvalds-is-cautiously-optimistic-about-bringing-rust-into-the-linux-kernels-next-release/ |url-status=live }} The first release candidate for Linux 6.0 was created on 14 August 2022, without Rust support. In the release notes for Linux 6.0-rc1, Torvalds expressed his intention for adding Rust support, "I actually was hoping that we'd get some of the first rust infrastructure, and the multi-gen LRU VM, but neither of them happened this time around."{{Cite web |first=Liam |last=Tung |title=Linux 6.0 arrives with performance improvements and more Rust coming |url=https://www.zdnet.com/article/linux-6-0-arrives-with-performance-improvements-and-more-rust-coming/ |date=2022-08-15 |access-date=2022-09-07 |website=ZDNet |language=en |archive-date=2022-09-07 |archive-url=https://web.archive.org/web/20220907042936/https://www.zdnet.com/article/linux-6-0-arrives-with-performance-improvements-and-more-rust-coming/ |url-status=live }}{{Cite web |first=Linus |last=Torvalds |title=Linux 6.0-rc1 |url=https://lwn.net/Articles/904681/ |date=2022-08-14 |access-date=2022-09-07 |website=LWN.net}} On 19 September 2022, an article from ZDNet revealed an email from Linus Torvalds stating that "Unless something odd happens, it [Rust] will make it into 6.1".{{Cite web |first=Steven |last=Vaughan-Nichols |date=2022-09-19 |title=Linus Torvalds: Rust will go into Linux 6.1 |url=https://www.zdnet.com/article/linus-torvalds-rust-will-go-into-linux-6-1/ |access-date=2022-09-20 |website=ZDNET |language=en |archive-date=2023-01-19 |archive-url=https://web.archive.org/web/20230119081543/https://www.zdnet.com/article/linus-torvalds-rust-will-go-into-linux-6-1/ |url-status=live }}
In October 2022, a pull request for accepting the implementation for Rust for Linux was approved by Torvalds.{{Cite web |last=Proven |first=Liam |title=Linux 6.1: Rust to hit mainline kernel |url=https://www.theregister.com/2022/10/05/rust_kernel_pull_request_pulled/ |date=2022-10-05 |access-date=2022-10-12 |website=The Register |language=en |archive-date=2022-10-12 |archive-url=https://web.archive.org/web/20221012065118/https://www.theregister.com/2022/10/05/rust_kernel_pull_request_pulled/ |url-status=live }} As of Linux 6.1, support was intentionally left minimal in order to allow developers to test the feature.{{cite web |last1=Corbet |first1=Jonathan |title=Next steps for Rust in the kernel |url=https://lwn.net/Articles/908347/ |website=LWN.net |access-date=2023-05-03 |archive-date=2023-06-08 |archive-url=https://web.archive.org/web/20230608001707/https://lwn.net/Articles/908347/ |url-status=live }}
Rust for Linux developers created a new library "pinned-init" to safely and fallibly initialize memory that must not be relocated.{{cite web |last1=Li |first1=Hongyu |last2=Guo |first2=Liwei |last3=Yang |first3=Yexuan |last4=Wang |first4=Shangguang |last5=Xu |first5=Mengwei |title=An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise |url=https://www.usenix.org/publications/loginonline/empirical-study-rust-linux-success-dissatisfaction-and-compromise |website=usenix |publisher=;login: |access-date=4 September 2024 |date=1 July 2024}}
It was first included in Linux 6.4,{{cite web |last1=Larabel |first1=Michael |title=More Rust Code Readied For Linux 6.4 |url=https://www.phoronix.com/news/Linux-6.4-More-Rust |website=phoronix.com |access-date=31 August 2024}} and been improved in later versions.
Linux 6.10 included RISCV processor architecture support for Rust.{{cite news |last1=Knop |first1=Dirk |title=Linux-Kernel 6.10: Verbesserte Dateisysteme und neue Treiber |url=https://www.heise.de/news/Linux-Kernel-6-10-Verbesserte-Dateisysteme-und-neue-Treiber-9815386.html |access-date=31 August 2024 |work=heise.de |date=July 27, 2024}}
In July 2024 a change was accepted into Linux to support multiple Rust versions for the first time, allowing compiling using both 1.78 (Released 2 May, 2024) and 1.79 (Released 13 June, 2024).{{cite news |last1=Leemhuis |first1=Thorsten |title=Linux kernel gets "blue screens" with QR code |url=https://www.heise.de/en/news/Linux-kernel-gets-blue-screens-with-QR-code-9851774.html |access-date=31 August 2024 |work=heise.de |date=Aug 29, 2024}}
{{As of|August 2024}}, Rust for Linux depends on unstable features of the Rust compiler.
Usage
Linux kernel contains the following Rust components:
- rnull, a drop-in replacement for the null device{{cite web |last1=Larabel |first1=Michael |title=Rust Null Block Driver Published To Begin Experimenting With Rust For Linux Storage |url=https://www.phoronix.com/news/Rust-Null-Block-Driver |website=phoronix.com |access-date=31 August 2024}}
- ASIX AX88772A and Realtek Generic FE-GE physical layer network drivers{{cite web |last1=Larabel |first1=Michael |title=The First Rust-Written Network PHY Driver Set To Land In Linux 6.8 |url=https://www.phoronix.com/news/Linux-6.8-Rust-PHY-Driver |website=phoronix.com |access-date=31 August 2024}}{{cite web |title=Rust abstractions for network PHY drivers |url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d6beb085e8ff3d9547df8a5a55f15ccc7552c5d0 |access-date=31 August 2024}}
Drivers scheduled for inclusion in Linux kernel:
Other notable projects using Rust in Linux include:
- tarfs, a tar filesystem
- NVM Express (NVMe) device driver
- Android Binder IPC driver{{cite web |last1=Filho |first1=Wedson Almeida |title=Rust in the Linux kernel |url=https://security.googleblog.com/2021/04/rust-in-linux-kernel.html |website=Google Security Blog |access-date=31 August 2024 |date=April 14, 2021}}
- Asahi Linux's Apple silicon AGX GPU DRM driver{{cite news |last1=Corbet |first1=Jonathan |title=Whither the Apple AGX graphics driver? |url=https://lwn.net/SubscriberLink/988438/4171601a819405c4/ |access-date=5 September 2024 |publisher=LWN.net |date=2 September 2024}}{{cite web |last1=Larabel |first1=Michael |title=Initial Rust DRM Abstractions, AGX Apple DRM Driver Posted For Review |url=https://www.phoronix.com/news/Rust-DRM-AGX-RFC-Preview |website=phoronix.com |access-date=31 August 2024}}
- PuzzleFS, a container filesystem{{cite web |last1=Larabel |first1=Michael |title=PuzzleFS Continues Striving To Be The Best File-System For Containers |url=https://www.phoronix.com/news/PuzzleFS-Development-Continues |website=phoronix.com |access-date=31 August 2024}}
- Read-only ext2 filesystem{{cite web |last1=Larabel |first1=Michael |title=Microsoft Engineer Ports EXT2 File-System Driver To Rust |url=https://www.phoronix.com/news/Rust-VFS-Linux-V2-Now-With-EXT2 |website=phoronix.com |access-date=31 August 2024}}
- Nova, intended to create a Rust nouveau Nvidia GPU driver, is being developed on the freedesktop.org project infrastructure{{cite news |last1=Das |first1=Ankush |title=Red Hat Unveils a Rust-based 'Nova' Driver: A Better Nouveau for Nvidia GPUs |url=https://news.itsfoss.com/red-hat-nova-driver/ |access-date=4 September 2024 |publisher=news.itsfoss.com |date=21 March 2024}}{{cite web |last1=Larabel |first1=Michael |title=Red Hat's Long, Rust'ed Road Ahead For Nova As Nouveau Driver Successor |url=https://www.phoronix.com/news/Red-Hat-Nova-Rust-Abstractions |website=phoronix.com |access-date=31 August 2024}}
See also
References
{{reflist}}
{{Linux kernel|state=collapsed}}
{{Linux|state=collapsed}}