Re: [PATCH v3] rust: page: add byte-wise atomic memory copy methods
From: Peter Zijlstra
Date: Wed Feb 18 2026 - 06:28:18 EST
On Tue, Feb 17, 2026 at 09:10:42AM -0800, Boqun Feng wrote:
> To me, having a atomic_bytewise_memcpy() at least clear things out about
> what is actually needed (at the very minimal) to have a concurrent-safe
> memcpy(). Moving forward, since the concept has been already somehow
> proposed to C/C++, it's likely to be standardized (we can push it from
> the kernel end as well) so we don't need to implement a concurrent-safe
> memcpy() for all architectures on our own.
>
> Hope this makes some sense ;-)
So all of this is about compilers being silly, not about there being a
problem with memcpy().
memcpy() as implemented by all architectures is *FINE*.
The proposal you refer to is:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1478r7.html
(as shared by Will on IRC) and right from the start it goes sideways:
"But fences only order atomic accesses,"
This is of course complete and utter bollocks.
No actual hardware works that way, so for the C virtual machine to be
specified that way is complete insanity. This insanity then leads to all
sorts of problems, and then these imaginary problems need solutions and
we're up a creek that smells real bad.
Can we please just 'fix' things by stating that *all* loads and stores
are properly affected by the relevant barriers. Then things like:
https://lkml.kernel.org/r/cbbea9ecb994df975109d97a7756d73e@xxxxxxxxxxx
also instantly resolve themselves, because the compiler just isn't
allowed to be *that* stupid^Wclever.