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

From: Peter Zijlstra

Date: Tue Feb 17 2026 - 10:51:00 EST


On Tue, Feb 17, 2026 at 02:54:30PM +0100, Danilo Krummrich wrote:
> On Tue Feb 17, 2026 at 2:00 PM CET, Peter Zijlstra wrote:
> > Anyway, I don't think something like the below is an unreasonable patch.
> >
> > It ensures all accesses to the ptr obtained from kmap_local_*() and
> > released by kunmap_local() stays inside those two.
>
> I'd argue that not ensuring this is a feature, as I don't see why we would want
> to ensure this if !CONFIG_HIGHMEM.

Because of the principle of least surprise. For the HIGHMEM case 'ptr'
only lives between kmap and kunmap and any access must necessarily be
confined in between those. Having the code behave differently for
!HIGHMEM is surprising.

> I think this is not about not escaping a critical scope, but about ensuring to
> read exactly once.

It ends up being the same thing.