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

From: Greg KH

Date: Fri Feb 13 2026 - 08:21:48 EST


On Fri, Feb 13, 2026 at 01:58:16PM +0100, Andreas Hindborg wrote:
> "Greg KH" <gregkh@xxxxxxxxxxxxxxxxxxx> writes:
>
> > On Fri, Feb 13, 2026 at 10:55:57AM +0100, Peter Zijlstra wrote:
> >> On Thu, Feb 12, 2026 at 03:51:24PM +0100, Andreas Hindborg wrote:
> >> > When copying data from buffers that are mapped to user space, it is
> >> > impossible to guarantee absence of concurrent memory operations on those
> >> > buffers. Copying data to/from `Page` from/to these buffers would be
> >> > undefined behavior if no special considerations are made.
> >> >
> >> > Add methods on `Page` to read and write the contents using byte-wise atomic
> >> > operations.
> >>
> >> I'm completely failing to understand. What!?
> >>
> >> There is no such thing as an 'atomic' byte load, nor does it help one
> >> whit against concurrent modification of the memory you're copying.
> >
> > I too am totally confused when reading this patch, and the previous
> > ones. Shouldn't the "normal" copy_from_user() stuff be used here
> > correctly? Why is anything new needed?
>
> One use for this is copying data out of a `struct bio_vec`. As far as I
> know, there is no way to know where the pages backing a bio_vec are
> mapped. They could be mapped to user space.

And how does C code do this today? Surely there's a function that is
used there that we should also be using here, right? Why do we need
something different?

thanks,

greg k-h