We have a huge repository of atomic operations backed by inline assembly code which resides in the vanilla C side. It is constructed with an elaborate macro infrastructure that has evolved over several years into various flavours of API or code expansion.
Today, the kernel
crate invokes the atomic operations by materialising the macros and static inline
s in rust/helpers
, so that the kernel
crate can link into.
Unfortunately this also comes with a foreseeable and observable comparative disadvantage in performance. One possible solution that has been floating around is to translate the inline assembly blocks, through compiler infrastructure, into Rust inline assembly, so that kernel
crate can "inline" the atomics for a performance boost. This document is a proposal to realise the pre-requisites of this experiment and performance benchmarking on the Rust kernel modules.
I would propose the following guidelines in search of solutions.
At this point, we should still view assembly snippets as the golden reference. We aim for minimal editing of these snippets.
On the side of Rust ecosystem, we should strive for least amount of maintenance in tools.
There is a repository of possible inline assembly features supported by Clang located at clang/test/CodeGen/AArch64/inline-asm.c
.
However, we have done our survey on exact features that kernel rely on. We can assume we will only support those features.
As discovered in the survey, most inline assembly blocks have been enclosed in static inline
s or statement like macros, aka. do-while
style macros.
libclang
and clang-sys