Re: [PATCH v4 4/9] rust: percpu: introduce a rust API for static per-CPU variables

From: Andreas Hindborg

Date: Fri Nov 14 2025 - 09:48:34 EST


Hi Mitchell,

"Mitchell Levy" <levymitchell0@xxxxxxxxx> writes:

> Per-CPU variables are an important tool for reducing lock contention,
> especially in systems with many processors. They also provide a
> convenient way to handle data that are logically associated with a
> particular CPU (e.g., the currently running task).
>
> Therefore, add a Rust API to make use of statically-allocated per-CPU
> variables. Add a RAII `CpuGuard` type for disabling CPU preemption.
> Introduce unifying abstractions that can be reused for a Rust API for
> dynamically-allocated per-CPU variables.
>
> Co-developed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: Mitchell Levy <levymitchell0@xxxxxxxxx>

I had to do the following change to make the doctests build when
applying to v6.18-rc5:

commit 47fc7e30ab0fbcc7262b846286b4bae5124d858e
Author: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Date: Fri Nov 14 15:43:47 2025 +0100

fixup! LIST: [PATCH v4 4/9] rust: percpu: introduce a rust API for static per-CPU variables

diff --git a/rust/kernel/percpu/static_.rs b/rust/kernel/percpu/static_.rs
index 418fc2fa06f20..bf053e260f0c5 100644
--- a/rust/kernel/percpu/static_.rs
+++ b/rust/kernel/percpu/static_.rs
@@ -162,7 +162,7 @@ pub unsafe trait PerCpuSyncMarkerType {
/// # Example
/// ```
/// use kernel::define_per_cpu;
-/// use kernel::percpu::StaticPerCpuSymbol;
+/// use kernel::percpu::{PerCpuSyncMarkerType, StaticPerCpuSymbol};
///
/// define_per_cpu!(pub MY_PERCPU: u64 = 0);
/// ```



Best regards,
Andreas Hindborg