Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Garg, Shivank" <shivankg@amd.com>
To: "nhuhuan@google.com" <nhuhuan@google.com>,
	"yiannis.nikolakop@gmail.com" <yiannis.nikolakop@gmail.com>
Cc: "ying.huang@linux.alibaba.com" <ying.huang@linux.alibaba.com>,
	"xuezhengchu@huawei.com" <xuezhengchu@huawei.com>,
	"sj@kernel.org" <sj@kernel.org>,
	"lorenzo.stoakes@oracle.com" <lorenzo.stoakes@oracle.com>,
	"joshua.hahnjy@gmail.com" <joshua.hahnjy@gmail.com>,
	"david@kernel.org" <david@kernel.org>,
	"anna@kernel.org" <anna@kernel.org>,
	"ryan.roberts@arm.com" <ryan.roberts@arm.com>,
	"rientjes@google.com" <rientjes@google.com>,
	"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"weixugc@google.com" <weixugc@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"gourry@gourry.net" <gourry@gourry.net>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"byungchul@sk.com" <byungchul@sk.com>,
	"x86@kernel.org" <x86@kernel.org>, "bp@alien8.de" <bp@alien8.de>,
	"linux-trace-kernel@vger.kernel.org"
	<linux-trace-kernel@vger.kernel.org>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"alirad.malek@zptcorp.com" <alirad.malek@zptcorp.com>,
	"Liam.Howlett@oracle.com" <Liam.Howlett@oracle.com>,
	"mhiramat@kernel.org" <mhiramat@kernel.org>,
	"jackmanb@google.com" <jackmanb@google.com>,
	"dimitrios@palyvos.net" <dimitrios@palyvos.net>,
	"surenb@google.com" <surenb@google.com>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"matthew.brost@intel.com" <matthew.brost@intel.com>,
	"fvdl@google.com" <fvdl@google.com>,
	"trondmy@kernel.org" <trondmy@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"yiannis@zptcorp.com" <yiannis@zptcorp.com>,
	"rakie.kim@sk.com" <rakie.kim@sk.com>,
	RaghavendraKT <Raghavendra.KodsaraThimmappa@amd.com>,
	"dave@stgolabs.net" <dave@stgolabs.net>,
	"apopple@nvidia.com" <apopple@nvidia.com>,
	"ziy@nvidia.com" <ziy@nvidia.com>,
	"vbabka@kernel.org" <vbabka@kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"nifan.cxl@gmail.com" <nifan.cxl@gmail.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH RFC v2 1/3] mm, x86: support copying a folio using non-temporal stores
Date: Mon, 17 Aug 2026 16:34:38 +0000	[thread overview]
Message-ID: <8af161b862695557c40ba9c2ddca0ba0fe004b86.camel@amd.com> (raw)
In-Reply-To: <CALwWd5usu+e=MgX95zGPUeqRjEu_SARLoiMPQpyMYBoUVQkk_g@mail.gmail.com>

On Fri, 2026-07-31 at 14:53 -0700, Huan Nguyen wrote:
> Hi Yiannis,
> 
> Although copy_mc_to_kernel_nt() asserts both "mc" (machine check exception)
> and "nt" (non-temporal store), the implementation fails to deliver both:
> 1. copy_mc_fragile() is MCE-safe, but it does not use movnti.
> 2. memcpy_flushcache() uses movnti, but it is not MCE-safe.
> 
> Additionally, according to the Intel manual, since movnti uses the WC protocol
> (a weakly-ordered memory model), a fencing operation is required. Because
> memcpy_flushcache() lacks an sfence, it can result in reading stale or corrupted
> data after folio_unlock().
> 
> Furthermore, copy_mc_highpage() is unoptimized for page migration operations
> because it reuses copy_mc_to_kernel(), built to handle
> variable-length, unaligned
> memory. As copy_mc_highpage_nt() follows copy_mc_highpage(), it inherits this
> flaw. In contrast, copy_highpage() is optimized for page migration by leveraging
> copy_page(), dedicated to 4KiB-aligned memory.
> 

I don't think copy_mc_highpage() is unoptimized for page migration copies.

On ERMS systems, copy_mc_to_kernel() uses copy_mc_enhanced_fast_string(),
which is rep movsb. copy_page() uses rep movsq on REP_GOOD systems.

(The copy_mc_fragile_enabled path looks like a special case and
enable_copy_mc_fragile() is reachable either when mce=recovery or through
one of 4 intel CPUs in x86/kernel/quirks.c)

In my testing on AMD EPYC 9655 (ZEN 5), both folio_mc_copy() and
folio_copy() showed similar performance.

https://lore.kernel.org/all/20260427142036.111940-2-shivankg@amd.com

And there is actually scope of upto ~2X speedup for
folio_copy/folio_mc_copy for large pages if we batch 4KiB copies. 

Thanks,
Shivank

  reply	other threads:[~2026-08-17 16:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 15:02 [PATCH RFC v2 0/3] Demote to lower tier using non-temporal stores Yiannis Nikolakopoulos
2026-07-30 15:02 ` [PATCH RFC v2 1/3] mm, x86: support copying a folio " Yiannis Nikolakopoulos
2026-07-31 21:53   ` Huan Nguyen
2026-08-17 16:34     ` Garg, Shivank [this message]
2026-07-30 15:02 ` [PATCH RFC v2 2/3] mm: new migrate_mode flag for async " Yiannis Nikolakopoulos
2026-08-05 14:14   ` Huang, Ying
2026-07-30 15:02 ` [PATCH RFC v2 3/3] mm: use non-temporal stores for demotion Yiannis Nikolakopoulos
2026-07-30 17:30 ` [PATCH RFC v2 0/3] Demote to lower tier using non-temporal stores Gregory Price
2026-07-30 17:40   ` Frank van der Linden
2026-07-30 18:08     ` Johannes Weiner
2026-07-30 20:49       ` Gregory Price

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=8af161b862695557c40ba9c2ddca0ba0fe004b86.camel@amd.com \
    --to=shivankg@amd.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=Raghavendra.KodsaraThimmappa@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alirad.malek@zptcorp.com \
    --cc=anna@kernel.org \
    --cc=apopple@nvidia.com \
    --cc=bharata@amd.com \
    --cc=bp@alien8.de \
    --cc=byungchul@sk.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave@stgolabs.net \
    --cc=david@kernel.org \
    --cc=dimitrios@palyvos.net \
    --cc=fvdl@google.com \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=jackmanb@google.com \
    --cc=jic23@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=matthew.brost@intel.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=nhuhuan@google.com \
    --cc=nifan.cxl@gmail.com \
    --cc=rakie.kim@sk.com \
    --cc=rientjes@google.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sj@kernel.org \
    --cc=surenb@google.com \
    --cc=tglx@kernel.org \
    --cc=trondmy@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=x86@kernel.org \
    --cc=xuezhengchu@huawei.com \
    --cc=yiannis.nikolakop@gmail.com \
    --cc=yiannis@zptcorp.com \
    --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