Re: [PATCH v2 7/7] mm: use memcpy_streaming() in zone-device template copies
From: Li Zhe
Date: Mon May 25 2026 - 01:00:21 EST
On Sat, 23 May 2026 15:10:52 +0300, rppt@xxxxxxxxxx wrote:
> On Thu, 21 May 2026 12:01:24 +0800, Li Zhe <lizhe.67@xxxxxxxxxxxxx> wrote:
> > diff --git a/mm/mm_init.c b/mm/mm_init.c
> > index 17a84d4cda01..08feb24795b8 100644
> > --- a/mm/mm_init.c
> > +++ b/mm/mm_init.c
> > @@ -1075,13 +1075,15 @@ static void __ref zone_device_page_init_slow(struct page *page,
> > [ ... skip 12 lines ... ]
> > */
> > - return !page_ref_tracepoint_active(page_ref_set) &&
> > - IS_ALIGNED(sizeof(struct page), sizeof(u64));
> > + return !IS_ENABLED(CONFIG_KASAN) && !IS_ENABLED(CONFIG_KMSAN) &&
> > + !page_ref_tracepoint_active(page_ref_set) &&
> > + IS_ALIGNED(sizeof(struct page), sizeof(u64));
>
> Oh, can we rewrite it as a sequence of
>
> if (cond)
> return false;
> ...
>
> return true;
>
> I believe the compilers would generate the same code.
Thanks for the review. I will fix this in the next revision.
> > @@ -1104,30 +1106,42 @@ static inline void zone_device_template_tail_page_init(struct page *template,
> > [ ... skip 10 lines ... ]
> > + * copying it into @page.
> > */
> > -static inline void zone_device_page_init_finish(struct page *page,
> > - unsigned long pfn)
> > +static inline void zone_device_page_update_template(struct page *template,
> > + unsigned long pfn)
>
> Two tabs for indentation here from the first patch this function
> appears please.
Thanks for the review. I will fix this in the next revision.
> Why do we need the intermediate step of _init_finish() if we later
> change it to _update_template()?
Instead of introducing an intermediate _init_finish() and renaming it
later, I will simply use zone_device_page_update_template() directly
from the beginning in the patch series.
> > [ ... skip 30 lines ... ]
> > + memcpy(page, template, sizeof(*page));
> > + else
> > + memcpy_streaming(page, template, sizeof(*page));
> >
> > - for (i = 0; i < sizeof(struct page) / sizeof(u64); i++)
> > - dst[i] = src[i];
>
> If you replace this with memcpy, what's the point for doing the loop in
> intermediate patches?
Thanks for the review. I will fix this in the next revision.
Thanks,
Zhe