Re: [PATCH v2] rust: page: add byte-wise atomic memory copy methods

From: Boqun Feng

Date: Tue Feb 17 2026 - 10:53:10 EST


On Tue, Feb 17, 2026 at 10:13:48AM +0100, Peter Zijlstra wrote:
> On Fri, Feb 13, 2026 at 08:19:17AM -0800, Boqun Feng wrote:
> > Well, in standard C, technically memcpy() has the same problem as Rust's
> > `core::ptr::copy()` and `core::ptr::copy_nonoverlapping()`, i.e. they
> > are vulnerable to data races. Our in-kernel memcpy() on the other hand
> > doesn't have this problem. Why? Because it's volatile byte-wise atomic
> > per the implementation.
>
> Look at arch/x86/lib/memcpy_64.S, plenty of movq variants there. Not
> byte-wise. Also, not a single atomic operation in sight.
>

Sigh, byte-wise means you at least need to byte-wise atomic, if movq is
atomic at 32bit or 64 bit level in x86, then it's fine implementation
for byte wise. Or you are saying on x86 it can tear at byte level?

Regards,
Boqun