lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cd3a600c-a4ee-4034-f605-ad9bac5c7655@gentwo.org>
Date: Wed, 25 Jun 2025 10:21:17 -0700 (PDT)
From: "Christoph Lameter (Ampere)" <cl@...two.org>
To: Mitchell Levy <levymitchell0@...il.com>
cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, 
    Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
    Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
    Andreas Hindborg <a.hindborg@...nel.org>, 
    Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, 
    Andrew Morton <akpm@...ux-foundation.org>, Dennis Zhou <dennis@...nel.org>, 
    Tejun Heo <tj@...nel.org>, Danilo Krummrich <dakr@...nel.org>, 
    Benno Lossin <lossin@...nel.org>, linux-kernel@...r.kernel.org, 
    rust-for-linux@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 4/5] rust: percpu: Add pin-hole optimizations for
 numerics

On Tue, 24 Jun 2025, Mitchell Levy wrote:

> The C implementations of `this_cpu_add`, `this_cpu_sub`, etc., are
> optimized to save an instruction by avoiding having to compute
> `this_cpu_ptr(&x)` for some per-CPU variable `x`. For example, rather
> than

Cool. Great progress for Rust support. Maybe we can switch the SLUB
allocator over or come up with SLRB for the Slab Rust allocator ;-)


> +        impl PerCpuNumeric<'_, $ty> {
> +            /// Adds `rhs` to the per-CPU variable.
> +            pub fn add(&mut self, rhs: $ty) {
> +                // SAFETY: `self.ptr.0` is a valid offset into the per-CPU area (i.e., valid as a
> +                // pointer relative to the `gs` segment register) by the invariants of PerCpu.
> +                unsafe {
> +                    asm!(
> +                        concat!("add gs:[{off}], {val}"),
> +                        off = in(reg) self.ptr.0 as *mut $ty,
> +                        val = in(reg_byte) rhs,

That looks arch specific to x86? What about ARM and other platforms?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ