9.5 C
New York
Sunday, November 27, 2022

After 30 Years, a Second Language Comes to Linux Kernel – Analytics India Magazine

“So, as is hopefully clear to everybody, the major version number change is more about me running out of fingers and toes than it is about any big fundamental changes,” wrote Linus Torvalds as he introduced Linux 6.0 earlier this month. He also added, “I’ll open the merge window for 6.1, which—unlike 6.0—has a number of fairly core new things lined up.”
All speculations, which heightened after Torvalds teased in the Linux 6.0 release note, were confirmed after he accepted the pull request made by Kees Cook, a Kernel security engineer at Google. This means that v6.1 will have direct support for the Rust code. Linux will not be entirely rewritten in Rust, but the process is already ongoing for adding 12,500 lines of code to the Linux kernel.
https://t.co/QQTz1rofNK

The first bits of Rust code have been merged into the Linux kernel.

This project started at PyCon 2018 with @geofft and I building a prototype, with some of the nastiest Makefile hacks ever seen.

I cannot express how thrilled I am to see this upstream.
This is a major update given Linux kernel from the start (since 1991) has been written in C programming language. It is the same language that was used to write kernels for Unix and similar operating systems since the 1970s.
At the Linux Security Summit 2019, Alex Gaynor and Geoffrey Thomas (both distinguished software developers with substantial work with Rust) presented a talk where they made a case for Rust in the Kernel and even presented their work prototyping Rust kernel modules. They based their presentation on security concerns and how Rust can avoid such error classes through safer APIs.
Similar sentiments were echoed by many developers. According to a few reports, the thought of Rust in the Linux kernel first emerged as early as 2013.
Later, at the 2020 Linux Plumbers Conference that was held virtually, one of the most heavily attended sessions was the one where attendees discussed and debated using Rust upstream in the Linux kernel and also the challenges of doing so.
Torvalds seemed more open to the idea and even requested that Rust compiler availability be enabled by default in the kernel build environment. This would enable any potential submissions to be built and automatically tested like any other kernel code.
In the same year, Torvalds was speaking at the Open Source Summit. During the discussion, he spoke about a lot of topics, including the one concerning the future of Linux overall, considering the current crop of maintainers is in their forties, even fifties. He was also asked if C, the language in which the kernel is written, faces risk from Go, Rust and others. To this, Torvalds said that while C is still one of the top ten languages, the kernel team was looking into using Rust and the likes to write things that are “not very central to the kernel itself”. He further added, “It is going to happen that we will have different models for writing these kinds of things, and C won’t be the only one.”
From the beginning of this year, Torvalds started making bolder statements. In fact, at this year’s Open Source Summit in Texas, he said that Rust could make it to the Linux kernel by the next major release.
There is a good reason why C is one of the most popular languages, even decades later. It is easy to read and write, and is portable between hardware architectures. That said, C has some glaring challenges, specifically due to its nature as a non memory-managed language. A variable, once its purpose is realised, must be explicitly destroyed. Failing to do so may give rise to memory leaks or even cause system crashes due to overaccumulation. 
On the other hand, Rust has emerged as a ‘developer darling’ of late. It has been long favoured as the desirable contender as a second language for kernel, especially due to its automated way of ensuring secure memory management. Rust has good support for interoperability with code written in C, including support for both calling functions using the C ABI and for defining functions with C-compatible ABIs. Further, the bindgen tool can parse C header files to give appropriate Rust declarations so that there is no need to duplicate definitions from C. This in turn provides a scope for cross-language type checking.
Last year, it was reported that the Google Android team was supporting a project led by developer Miguel Ojeda to write a few elements of the Linux kernel. During the development phase, Ojeda said that the team built a Rust Binder kernel module that demonstrated better preliminary performance than the C version. In a blog that details the Rust for Linux project, Ojeda wrote that one of the key properties of Rust that makes it very interesting to consider as the kernel second language is that it makes sure no ‘undefined behaviour’ occurs, especially in terms of memory management. “This includes no use-after-free issues, no double frees, no data races, etc,” he added.
Conference, in-person (Bangalore)
Machine Learning Developers Summit (MLDS) 2023
19-20th Jan, 2023
Conference, in-person (Bangalore)
Rising 2023 | Women in Tech Conference
16-17th Mar, 2023
Conference, in-person (Bangalore)
Data Engineering Summit (DES) 2023
27-28th Apr, 2023
Conference, in-person (Bangalore)
MachineCon 2023
23rd Jun, 2023
Stay Connected with a larger ecosystem of data science and ML Professionals
Discover special offers, top stories, upcoming events, and more.
Stay up to date with our latest news, receive exclusive deals, and more.
© Analytics India Magazine Pvt Ltd 2022
Terms of use
Privacy Policy
Copyright

source

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles