Rust Code Updates in the Linux Kernel Introduce More Features
Miguel Ojeda has released the latest patch series that implements the foundational infrastructure for the Rust programming language in the Linux kernel, along with initial sample code.
The v8 version with Rust support has been released today, adding support for using the Rust programming language within the Linux kernel to the original 43.6k lines of code.
Back in June at the open-source summit, Linus Torvalds commented that Rust for the kernel could be merged into Linux 5.20—now referred to as Linux 6.0. Whether it will ultimately be merged remains to be seen, especially since the v8 patch series released today contains many new additions that require more time for review… Therefore, unless there is a last-minute merge for Linux 6.0 next week, Rust kernel code may still need more time to prepare. In any case, it seems to be inching closer to the merging goal.
With the release of the Rust v8 series patches for the Linux kernel, there is a lot of code being continuously updated, and more kernel functionalities can now be implemented using Rust code. Some highlights from the latest patches include:
Upgraded the Rust toolchain to 1.62
Moved Rust’s Linux kernel bindings to their own
crate
(named “bindings”) to improve build times when only thekernel
crate changes.Improved the speed of rust-analyzer.
Added filesystem support through the “fs” module, including various new types, filesystem parameters support, filesystem flags, and example code for filesystems in Rust.
Workqueues
support is also a new feature in the Rust v8 Linux patches.Extended asynchronous support in the Rust v8 patches, now with executor support, workqueue-based executors, yielding the execution of the current task with
yield_now()
, and added an example of an asynchronous TCP echo server.Rust support for handling interrupts.
Initial RCU support.
Preliminary support for delays/sleeps.
As for the current status, the v8 patch series still carries the message: “Rust support is still considered experimental. However, the support is good enough that kernel developers can start exploring Rust abstractions for subsystems and writing drivers and other modules.”
For those interested in Rust in the Linux kernel, more details can be found in the kernel mailing list for the v8 patches.
News: https://www.phoronix.com/news/Rust-v8-For-Linux-Kernel
Email: https://lore.kernel.org/lkml/[email protected]/
Asynchronous Rust Practice: Performance, Pitfalls, Analysis
An article detailing the performance tuning of asynchronous Rust, including background on code optimization.
Blog: https://www.p99conf.io/2022/08/02/async-rust-in-practice-performance-pitfalls-profiling/
<span>cargo-pgo</span>
:<span>Cargo</span>
subcommand to simplify PGO and BOLT optimization binary flow
Hi! Over the past few months, I have been optimizing the Rust compiler using PGO and BOLT, during which I realized that using these tools to optimize general Rust code could be a bit cumbersome.
That’s why I decided to create a Cargo subcommand to make it easier to use PGO and BOLT (BOLT support is still slightly experimental, mainly because you have to build LLVM with BOLT yourself, and it doesn’t always work flawlessly).
As a quick overview, PGO (Profile-Guided Optimization) and BOLT are techniques to improve binary performance. You compile your binary in a special way (using instrumentation), then run this modified binary on some workloads to generate a profile, which you then use to recompile your binary with those collected profiles. This aims to produce a faster, more optimized binary (typically resulting in an improvement of 1-20%).
The
cargo-pgo
subcommand will handle enabling PGO for your build with the correct compile flags and settings, guiding you through the workflow of using these so-called “feedback-guided optimizations.” Here’s a simple example:cargo pgo build # build with instrumentation./target/.../<binary> # run your binary on some workloadcargo pgo optimize # build an optimized binary
This command allows you to use PGO, BOLT, and the combination of BOLT+PGO. You can install this tool in the typical way:
cargo install cargo-pgo
You can find this tool here. I would appreciate any feedback.
Github: https://github.com/Kobzol/cargo-pgo
Hot Reloading Rust—For Fun and Faster Feedback Cycles
hot-lib-reloader allows changing Rust code at runtime without restarting. It works on Linux, macOS (Intel), and Windows. For more on why, how it works, and how to use it (as well as the limitations of this approach), please read the post below.
Hot Reloading Rust: https://robert.kra.hn/posts/hot-reloading-rust/
Zero-Copy Series of Blogs
This is the first part of an interesting trilogy about zero-copy deserialization that I have been researching over the past year. This part is about making zero-copy deserialization work more pleasantly. The second part is about making it applicable to more types; and the third part is about completely eliminating the deserialization step. These articles can be read in any order, with the first article containing an explanation of what zero-copy deserialization is.
#1: https://manishearth.github.io/blog/2022/08/03/zero-copy-1-not-a-yoking-matter/
#2: https://manishearth.github.io/blog/2022/08/03/zero-copy-2-zero-copy-all-the-things/
#3: https://manishearth.github.io/blog/2022/08/03/zero-copy-3-so-zero-its-dot-dot-dot-negative/
This Week in Rust 454
The latest issue of the Rust Weekly Update is out, come see what content you may have been interested in 🙂
This Week in Rust 454: https://this-week-in-rust.org/blog/2022/08/03/this-week-in-rust-454/
From the Daily Report team Cupnfish, wishing everyone a happy Qixi Festival 🎉
Community Learning Exchange Platform Subscription:
-
Rust.cc Forum: Supports RSS
-
WeChat Official Account: Rust Language Chinese Community