Re: [PATCHv2] mm: Fix warning in move_normal_pmd()

From: Kirill A. Shutemov
Date: Thu Jul 16 2020 - 09:16:11 EST


On Wed, Jul 15, 2020 at 04:18:44PM -0700, Linus Torvalds wrote:
> On Wed, Jul 15, 2020 at 4:04 PM Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > It *might* be as simple as this incremental thing on top
>
> No, it needs to be
>
> + if (*old_addr + *len < old->vm_end)
> + return;
>
> in try_to_align_end(), of course.

Okay, this should work, but I'm not convinced that it gives much: number
of cases covered by the optimization not going to be high.

It can also lead to performance regression: for small mremap() if only one
side of the range got aligned and there's no PMD_SIZE range to move,
kernel will still iterate over PTEs, but it would need to handle more
pte_none()s than without the patch.

--
Kirill A. Shutemov