* 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
2026-12-06 14:48 ` Garg, Shivank
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* Re: [PATCH v4 1/6] mm/highmem: introduce copy_mc_can_batch() and __copy_mc_pages()
2026-12-04 3:45 ` [PATCH v4 1/6] mm/highmem: introduce copy_mc_can_batch() and __copy_mc_pages() Jiangtian Feng
@ 2026-12-06 14:48 ` Garg, Shivank
0 siblings, 0 replies; 2+ messages in thread
From: Garg, Shivank @ 2026-12-06 14:48 UTC (permalink / raw)
To: jiangtianfeng@linux.alibaba.com
Cc: david.laight.linux@gmail.com, torvalds@linuxfoundation.org,
ying.huang@linux.alibaba.com, Salunke, Hrushikesh,
usama.arif@linux.dev, ryan.roberts@arm.com, david@kernel.org,
mhocko@suse.com, pfalcato@suse.de, tglx@kernel.org,
rientjes@google.com, lance.yang@linux.dev, peterz@infradead.org,
liam@infradead.org, linux-kernel@vger.kernel.org,
catalin.marinas@arm.com, Rao, Bharata Bhasker,
tianruidong@linux.alibaba.com, x86@kernel.org, bp@alien8.de,
rppt@kernel.org, baolin.wang@linux.alibaba.com, dev.jain@arm.com,
surenb@google.com, nhuhuan@google.com, will@kernel.org,
hpa@zytor.com, mingo@redhat.com, nico.pache@linux.dev,
baohua@kernel.org, linux-arm-kernel@lists.infradead.org,
ziy@nvidia.com, vbabka@kernel.org, tejavojjala@google.com,
ankur.a.arora@oracle.com, linux-mm@kvack.org,
akpm@linux-foundation.org, kas@kernel.org,
dave.hansen@linux.intel.com, ljs@kernel.org
On Fri, 2026-12-04 at 11:45 +0800, Jiangtian Feng wrote:
> [Some people who received this message don't often get email from jiangtianfeng@linux.alibaba.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> 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.
>
Hi Jiangtian,
Thanks for catching and alerting me on this.
Instead of inventing new Kconfig symbol ARCH_HAS_COPY_MC_BATCH, how about I
reuse __HAVE_ARCH_COPY_MC{_USER}_HIGHPAGE checks that you're adding[1]?
static inline bool copy_mc_can_batch(void)
{
#if defined(__HAVE_ARCH_COPY_MC_HIGHPAGE) || defined(__HAVE_ARCH_COPY_MC_USER_HIGHPAGE)
return false;
#else
return IS_ENABLED(CONFIG_ARCH_HAS_COPY_MC) &&
IS_ENABLED(CONFIG_PREEMPTION) && !IS_ENABLED(CONFIG_HIGHMEM);
#endif
}
That way batching is only used where it is the generic helper repeated
over the range, and arch-specific COPY_MC cases, falls back to the per-page loop
without having to know about batching. It also needs no x86 or powerpc changes.
If you prefer an explicit ARCH_HAS_COPY_MC_BATCH instead, I'm fine with that
too. Let me know your thoughts.
[1] https://lore.kernel.org/linux-mm/20261205012435.1406255-7-jiangtianfeng@linux.alibaba.com
--
Thanks,
Shivank
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-06 14:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261201-batpagecopy-v4-1-dd82a573e573@amd.com>
2026-12-04 3:45 ` [PATCH v4 1/6] mm/highmem: introduce copy_mc_can_batch() and __copy_mc_pages() Jiangtian Feng
2026-12-06 14:48 ` Garg, Shivank
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox