mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Garg, Shivank" <shivankg@amd.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "tejavojjala@google.com" <tejavojjala@google.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"david.laight.linux@gmail.com" <david.laight.linux@gmail.com>,
	"ankur.a.arora@oracle.com" <ankur.a.arora@oracle.com>,
	"vbabka@kernel.org" <vbabka@kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"david@kernel.org" <david@kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"surenb@google.com" <surenb@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"nhuhuan@google.com" <nhuhuan@google.com>,
	"Salunke, Hrushikesh" <Hrushikesh.Salunke@amd.com>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"liam@infradead.org" <liam@infradead.org>,
	"hpa@zytor.com" <hpa@zytor.com>, "bp@alien8.de" <bp@alien8.de>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"ljs@kernel.org" <ljs@kernel.org>,
	"rientjes@google.com" <rientjes@google.com>,
	"pfalcato@suse.de" <pfalcato@suse.de>,
	"torvalds@linuxfoundation.org" <torvalds@linuxfoundation.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v3] mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy()
Date: Sun, 22 Nov 2026 17:13:30 +0000	[thread overview]
Message-ID: <6eb8b1f35116a0cfff7f27c0afbd2002f62943a0.camel@amd.com> (raw)
In-Reply-To: <20261121233006.bc03ca9b7889c93a482791aa@linux-foundation.org>

On Sat, 2026-11-21 at 23:30 -0800, Andrew Morton wrote:
> On Fri, 13 Nov 2026 17:09:21 +0000 Shivank Garg <shivankg@amd.com> wrote:
> 
> > folio_mc_copy() copies a folio one page at a time with copy_mc_highpage(),
> > so a 2MB folio makes 512 separate copy_mc_to_kernel() calls. Each page
> > pays the startup cost of the string instruction ("REP; MOVSB" on x86
> > CPUs with ERMS) plus a cond_resched().
> > 
> > Introduce copy_mc_highpages(), the page range variant of
> > copy_mc_highpage(). When copy_mc_to_kernel() is available and the pages
> > are in the linear map, copy the whole range with a single
> > copy_mc_to_kernel() call, so the CPU can optimize for the larger extent.
> > Otherwise, fall back to copy_mc_highpage() one page at a time.
> > 
> > On a machine check, queue the poisoned source page for memory_failure(),
> > as copy_mc_highpage() does, and return -EHWPOISON, as folio_mc_copy()
> > does today.
> > 
> > copy_mc_to_kernel() cannot reschedule, so only take the single-call path
> > when CONFIG_PREEMPTION is set and the copy can be preempted. Since commit
> > 7dadeaa6e851 ("sched: Further restrict the preemption modes"), x86 and
> > powerpc, the only architectures that select ARCH_HAS_COPY_MC, only offer
> > the full, lazy and RT preemption models, also with PREEMPT_DYNAMIC, so
> > they always take this path. The per-page fallback calls cond_resched()
> > before each page, as clear_contig_highpages() does. Other architectures
> > keep copying one page at a time.
> > 
> > Switch folio_mc_copy() to copy the whole folio with copy_mc_highpages().
> 
> OK.
> 
> > ---
> > On a Zen 6 system with CXL memory, move_pages() gets ~1.4x faster for
> > 2MB THPs and up to ~2.8x faster for 1GB hugetlb pages (numbers below).
> > When demoting to CXL, kswapd uses ~31% less CPU per GB demoted.
> 
> But that's the most important part!  It's the whole point of the patch!
> Yet here it is below the ---, which means "throw this away".  It
> should be the first paragraph, in all caps.
> 
> <edit edit fixed>

Sure, thanks. I'll keep this in mind.

> 
> OK, thanks, queued,
> 
> nit: does it really need cond_resched()?  That's not appropriate for
> current mainline kernels.  I guess "yes", because this patch looks like
> something which downstream people will eagerly backport into older
> kernels, even though we didn't cc:stable.
> 
> And we care about downstream people.  Globally: "Roughly 60% are on 6.x
> and 30% are on 5.x (with the remaining ~10% split between 7.x and 4.x
> or older)".
> 
> I'll take a look at that Sashiko thing.


Agreed.

For older kernels, where the non-preemptible modes are still
available, the backport should look like v2 in my opinion (calling
cond_resched() every 32MB). Otherwise a 1GB hugetlb copy can run for
a long time without rescheduling. I'll leave this discussion for
backport time :)

      reply	other threads:[~2026-11-22 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 17:09 Shivank Garg
2026-11-22  7:30 ` Andrew Morton
2026-11-22 17:13   ` 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=6eb8b1f35116a0cfff7f27c0afbd2002f62943a0.camel@amd.com \
    --to=shivankg@amd.com \
    --cc=Hrushikesh.Salunke@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=bharata@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.laight.linux@gmail.com \
    --cc=david@kernel.org \
    --cc=hpa@zytor.com \
    --cc=liam@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=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=tejavojjala@google.com \
    --cc=tglx@kernel.org \
    --cc=torvalds@linuxfoundation.org \
    --cc=vbabka@kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®