Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Garg, Shivank" <shivankg@amd.com>
To: "jiangtianfeng@linux.alibaba.com" <jiangtianfeng@linux.alibaba.com>
Cc: "david.laight.linux@gmail.com" <david.laight.linux@gmail.com>,
	"torvalds@linuxfoundation.org" <torvalds@linuxfoundation.org>,
	"ying.huang@linux.alibaba.com" <ying.huang@linux.alibaba.com>,
	"Salunke, Hrushikesh" <Hrushikesh.Salunke@amd.com>,
	"usama.arif@linux.dev" <usama.arif@linux.dev>,
	"ryan.roberts@arm.com" <ryan.roberts@arm.com>,
	"david@kernel.org" <david@kernel.org>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"pfalcato@suse.de" <pfalcato@suse.de>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"rientjes@google.com" <rientjes@google.com>,
	"lance.yang@linux.dev" <lance.yang@linux.dev>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"liam@infradead.org" <liam@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"tianruidong@linux.alibaba.com" <tianruidong@linux.alibaba.com>,
	"x86@kernel.org" <x86@kernel.org>, "bp@alien8.de" <bp@alien8.de>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"baolin.wang@linux.alibaba.com" <baolin.wang@linux.alibaba.com>,
	"dev.jain@arm.com" <dev.jain@arm.com>,
	"surenb@google.com" <surenb@google.com>,
	"nhuhuan@google.com" <nhuhuan@google.com>,
	"will@kernel.org" <will@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"nico.pache@linux.dev" <nico.pache@linux.dev>,
	"baohua@kernel.org" <baohua@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"ziy@nvidia.com" <ziy@nvidia.com>,
	"vbabka@kernel.org" <vbabka@kernel.org>,
	"tejavojjala@google.com" <tejavojjala@google.com>,
	"ankur.a.arora@oracle.com" <ankur.a.arora@oracle.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"kas@kernel.org" <kas@kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"ljs@kernel.org" <ljs@kernel.org>
Subject: Re: [PATCH v4 1/6] mm/highmem: introduce copy_mc_can_batch() and __copy_mc_pages()
Date: Sun, 6 Dec 2026 14:48:10 +0000	[thread overview]
Message-ID: <d070009c356f7c7093555f1950efff19197285bb.camel@amd.com> (raw)
In-Reply-To: <20261204034522.302814-1-jiangtianfeng@linux.alibaba.com>

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


      reply	other threads:[~2026-12-06 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d070009c356f7c7093555f1950efff19197285bb.camel@amd.com \
    --to=shivankg@amd.com \
    --cc=Hrushikesh.Salunke@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bharata@amd.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.laight.linux@gmail.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=hpa@zytor.com \
    --cc=jiangtianfeng@linux.alibaba.com \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=nhuhuan@google.com \
    --cc=nico.pache@linux.dev \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=tejavojjala@google.com \
    --cc=tglx@kernel.org \
    --cc=tianruidong@linux.alibaba.com \
    --cc=torvalds@linuxfoundation.org \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox