Re: [RFC PATCH v3 0/3] mm: use non-temporal stores for demotion
From: Huan Nguyen
Date: Thu Nov 12 2026 - 20:55:05 EST
On Fri, Nov 6, 2026 at 12:51 AM Li Zhe <lizhe.67@xxxxxxxxxxxxx> wrote:
>
> On Tue, 3 Nov 2026 14:30:22 -0800, Huan Nguyen wrote:
>
> > Using non-temporal stores and prefetching on x86 bypasses CPU cache
> > allocation, protecting active workload working sets and improving
> > demotion throughput.
>
> Could you show some real workload numbers for this? I am wondering
> whether the reduced cache allocation and improved demotion throughput
> also translate into visible application-level benefits.
I do not have direct benchmark numbers for non-temporal demotion with
this implementation yet. As far as I know, Alirad and Yiannis (cc'd)
are currently evaluating its real-workload impact and may share
results once available.
>
> > - Memory ordering:
> > Add a wmb() barrier at the end of folio_mc_copy_nt() to ensure weakly
> > ordered non-temporal stores are drained before page tables are updated.
>
> I have not looked into all the details here, so I may be missing
> something. But before migration completes, there should eventually be a
> publication step that makes the new folio visible. In theory, that
> publication step should already provide the required ordering before
> userspace can observe the new folio. So I wonder whether the wmb() in
> folio_mc_copy_nt() is really needed here.
On weakly-ordered architectures like arm64, the publication step
indeed provides the required ordering, because smp_wmb() and
smp_store_release() emit real hardware barriers before the new folio
becomes visible.
On x86_64, however, those primitives compile down to a compiler
barrier() with no CPU instructions, since x86 assumes TSO. Because
movnti bypasses TSO, the standard publication barriers do not order
non-temporal writes on x86_64, which is why folio_mc_copy_nt() needs
an explicit wmb() at the end.
Right now __HAVE_ARCH_COPY_PAGE_NT is only defined on x86_64, so that
the wmb() is effectively x86-only today. If another architecture
implements __HAVE_ARCH_COPY_PAGE_NT in the future, we can move the
wmb() into an x86-specific scope in v4 so weakly-ordered architectures
do not pay for an unnecessary barrier.
>
> Thanks,
> Zhe