From: "Garg, Shivank" <shivankg@amd.com>
To: "david@kernel.org" <david@kernel.org>,
"pfalcato@suse.de" <pfalcato@suse.de>
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>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"vbabka@kernel.org" <vbabka@kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"surenb@google.com" <surenb@google.com>,
"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>,
"mhocko@suse.com" <mhocko@suse.com>,
"bp@alien8.de" <bp@alien8.de>, "ljs@kernel.org" <ljs@kernel.org>,
"rientjes@google.com" <rientjes@google.com>,
"torvalds@linuxfoundation.org" <torvalds@linuxfoundation.org>,
"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH RFC v2] mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy()
Date: Mon, 19 Oct 2026 13:10:12 +0000 [thread overview]
Message-ID: <0346e29faa551efb6a4e21a920d344f5f9b918e5.camel@amd.com> (raw)
In-Reply-To: <ad34dd6d-f106-42b1-b8b6-a4487822285f@kernel.org>
On Mon, 2026-10-19 at 14:23 +0200, David Hildenbrand (Arm) wrote:
> > > +}
> > > +#else
> > > +
> > > +#define COPY_MC_PAGES_NON_PREEMPT_BATCH 1
> >
> > I would suggest that perhaps this should be the fallback for non-preemptible
> > models. But it gets a little weird with PREEMPT_DYNAMIC I think?
>
> Why can't we just use PROCESS_PAGES_NON_PREEMPT_BATCH where we have similar
> handling already?
>
> >
I did not reuse PROCESS_PAGES_NON_PREEMPT_BATCH because it depends on
whether clear_pages is defined. While COPY_MC_PAGES_NON_PREEMPT_BATCH
depends on copy_mc_to_kernel and other constraints. So, using a single
param for both would make it more messy.
However as Pedro pointed, most architectures are full preempt/preempt lazy,
and with this commit 7dadeaa6e851 ("sched: Further restrict the
preemption modes"), for PREEMPT_DYNAMIC, preempt=none and preempt=voluntary
are rejected at boot. preempt_model_preemptible() is therefore always
true for this case.
So, this can be simplfied to drop the COPY_MC_PAGES_NON_PREEMPT_BATCH.
> > > +
> > > +static inline int copy_mc_highpages(struct page *to, struct page *from,
> > > + unsigned long nr_pages)
> > > +{
> > > + unsigned long i;
> > > +
> > > + for (i = 0; i < nr_pages; i++)
> > > + if (copy_mc_highpage(to + i, from + i))
> > > + return -EHWPOISON;
> > > + return 0;
> > > +}
> > > +#endif
> > > +
> > > static inline void memcpy_page(struct page *dst_page, size_t dst_off,
> > > struct page *src_page, size_t src_off,
> > > size_t len)
> > > diff --git a/mm/util.c b/mm/util.c
> > > index 7f374bb8bf36..5015cfdfeaa5 100644
> > > --- a/mm/util.c
> > > +++ b/mm/util.c
> > > @@ -763,13 +763,23 @@ EXPORT_SYMBOL(folio_copy);
> > >
> > >
> > > int folio_mc_copy(struct folio *dst, struct folio *src)
> > > {
> > > - long nr = folio_nr_pages(src);
> > > - long i = 0;
> > > + const unsigned long nr_pages = folio_nr_pages(src);
> > > + /*
> > > + * Copy the largest extent possible to allow for architecture specific
> > > + * extent based optimizations. copy_mc_highpages() does not call
> > > + * cond_resched(), so limit the unit size when running under
> > > + * non-preemptible scheduling models.
> > > + */
> > > + const unsigned long unit = preempt_model_preemptible() ?
> > > + nr_pages : COPY_MC_PAGES_NON_PREEMPT_BATCH;
> >
> > See? now mm is aware of preemption models! eww!
>
> Yeah, we have that in clear_contig_highpages() already, which is getting
> replicated here for copying instead of zeroing.
next prev parent reply other threads:[~2026-10-19 13:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 10:06 Shivank Garg
2026-10-19 11:09 ` Pedro Falcato
2026-10-19 12:23 ` David Hildenbrand (Arm)
2026-10-19 13:10 ` Garg, Shivank [this message]
2026-10-19 14:21 ` David Hildenbrand (Arm)
2026-10-19 13:16 ` Garg, Shivank
2026-10-19 12:19 ` David Laight
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=0346e29faa551efb6a4e21a920d344f5f9b918e5.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=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®