Christoph Hellwig, maintainer of the DMA subsystem, KVM, Slab Allocator, and PowerPC architecture in the Linux kernel, fundamentally refused to accept Rust bindings for the DMA subsystem into the kernel, has joined the discussion on the rules for supporting Rust within the kernel, published by the Rust for Linux project. According to Christoph, such rules are useless until they are agreed upon with the community and included in the kernel documentation.
Christoph also pointed out that the rules contain incorrect information regarding maintainers' ability to make decisions on including Rust-related code in their subsystems. Christoph mentioned that in a private conversation, Linus Torvalds stated he is determined to accept Rust code into the kernel, despite maintainers' objections. Therefore, developers and kernel maintainers will now have to deal with Rust, whether they want to or not.
Christoph also compared the spread of Rust bindings to a cancerous tumor that will spread to all subsystems of the kernel and lead to fragmentation. From a unified whole, the kernel is turning into a project written in several languages, without a clear definition of when each language should be used. Christoph stated that working with such a mixed codebase has become his worst nightmare, as it constantly involves rewriting code from one language to another and then back.
In this regard, Christoph asks to clarify the purpose of introducing Rust into the kernel. If the goal is to solve safety issues arising from low-level memory operations, then the existing code needs modernization first. Given that maintainers react painfully even to trivial things like integer overflow checks, it's unclear how to bridge the gap between one part of the kernel that does not accept even simple safety rules and another part that adheres to strict rules. If the goal is to simplify driver development, then adding support for yet another language will only increase the workload and burden the already overloaded individuals maintaining the kernel infrastructure.
Jeśli chodzi o zwolenników wprowadzenia Rust do jądra, wymieniają oni następujące cele:
- Pisanie nowego kodu w języku Rust zmniejszy ryzyko błędów związanych z pamięcią i stanami wyścigu, a także wyeliminuje niektóre błędy logiczne.
- Utrzymującym będzie łatwiej recenzować zmiany i przeprowadzać refaktoryzację modułów, biorąc pod uwagę gwarancje oferowane przez język Rust.
- Obecność abstrakcji wykorzystujących zaawansowane możliwości języka Rust ułatwi tworzenie nowych sterowników i modułów.
- Wsparcie nowoczesnego języka przyciągnie nowych uczestników do rozwoju jądra.
- Zastosowanie narzędzi Rust uprości spełnianie wymagań dotyczących dokumentacji kodu. Na przykład w projekcie Rust for Linux wprowadzono wymóg obowiązkowego dokumentowania publicznych API, wymagań bezpieczeństwa, bloków unsafe i inwariantów typów.
Źródło: opennet.ru
