Re: [PATCH RFC v2] mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy()
From: David Hildenbrand (Arm)
Date: Mon Oct 19 2026 - 08:24:43 EST
>> +}
>> +#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?
>
>> +
>> +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.
--
Cheers,
David