* Re: [PATCH v4 1/6] mm/highmem: introduce copy_mc_can_batch() and __copy_mc_pages()
[not found] <20261201-batpagecopy-v4-1-dd82a573e573@amd.com>
@ 2026-12-04 3:45 ` Jiangtian Feng
0 siblings, 0 replies; only message in thread
From: Jiangtian Feng @ 2026-12-04 3:45 UTC (permalink / raw)
To: shivankg
Cc: Jiangtian Feng, akpm, david, ljs, liam, vbabka, rppt, surenb,
mhocko, bp, ankur.a.arora, dave.hansen, tglx, bharata, hsalunke,
mingo, hpa, david.laight.linux, rientjes, torvalds, tejavojjala,
nhuhuan, pfalcato, peterz, ziy, baolin.wang, nico.pache,
ryan.roberts, dev.jain, baohua, lance.yang, usama.arif, kas,
ying.huang, linux-mm, linux-kernel, x86, linux-arm-kernel,
catalin.marinas, will, tianruidong
Hi Shivank,
> Add copy_mc_can_batch(), which tells whether a page range can be copied
> with a single copy_mc_to_kernel() call, and __copy_mc_pages(), which
> does that copy.
There is a pending interaction with the arm64 copy_mc work. I am
preparing a respin of Ruidong's v15 series:
https://lore.kernel.org/all/20260618092124.3901230-1-tianruidong@linux.alibaba.com/
The respin selects ARCH_HAS_COPY_MC when ACPI_APEI_SEA is enabled and
provides architecture-specific copy_mc_highpage() and
copy_mc_user_highpage() helpers. Consequently, ARCH_HAS_COPY_MC would
also enable this raw-range fast path on preemptible arm64 kernels.
Your range wrappers handle KMSAN metadata, but the arm64 helpers have
additional semantics. When enabled, they reset the destination KASAN
hardware tag and copy MTE tags and their page/folio state. The user
variant also maintains the dcache-clean state needed for later
icache/dcache synchronization. They queue the actual source page when
either the data or MTE-tag copy fails; the latter failure has no
copy_mc_to_kernel() residual from which to derive a PFN. The raw fast
path would bypass these operations.
Could we separate raw-range batching from ARCH_HAS_COPY_MC with an
explicit opt-in, for example ARCH_HAS_COPY_MC_BATCH? The Kconfig help
should state that selecting it requires the architecture's per-page
helpers to have no additional semantics beyond the raw copy, KMSAN
metadata and residual-based source-page queueing. That description is
only about raw-range equivalence; the ordinary copy_mc_to_kernel()
contract remains unchanged.
copy_mc_can_batch() would then check ARCH_HAS_COPY_MC_BATCH instead of
ARCH_HAS_COPY_MC. x86-64 and ppc64 can select the new symbol alongside
ARCH_HAS_COPY_MC, preserving the fast path covered by this series.
Other architectures retain your range helpers and caller conversions,
but take their existing per-page fallback. No arm64 exclusion is needed
for raw batching. The range-order change and its failure-order effects
remain a separate review item; this opt-in only prevents bypassing the
architecture helpers.
This seems preferable to making arm64 disable PREEMPTION or dropping
the generic range work, and leaves room for a future arm64 range helper
that handles its tag/cache/failure semantics explicitly. x86-64 and
ppc64 would retain responsibility for validating their respective raw
fast paths; arm64 would validate the per-page fallback.
Would that split work for v5? I think the selector and the x86/ppc
selections belong in this series, so that adding a new ARCH_HAS_COPY_MC
architecture cannot silently opt into raw batching. If you prefer a
different ownership or ordering for the prerequisite, please let me
know so we do not post competing versions.
Thanks,
Jiangtian
^ permalink raw reply [flat|nested] only message in thread