Re: inconsistence in mprotect_fixup mlock_fixup madvise_update_vma
From: Peter Xu
Date: Tue Jun 13 2023 - 16:17:17 EST
Hi, Jeff,
On Tue, Jun 13, 2023 at 08:26:26AM -0700, Jeff Xu wrote:
> + more ppl to the list.
>
> On Mon, Jun 12, 2023 at 6:04 PM Jeff Xu <jeffxu@xxxxxxxxxxxx> wrote:
> >
> > Hello,
> >
> > There seems to be inconsistency in different VMA fixup
> > implementations, for example:
> > mlock_fixup will skip VMA that is hugettlb, etc, but those checks do
> > not exist in mprotect_fixup and madvise_update_vma. Wouldn't this be a
> > problem? the merge/split skipped by mlock_fixup, might get acted on in
> > the madvice/mprotect case.
> >
> > mlock_fixup currently check for
> > if (newflags == oldflags || (oldflags & VM_SPECIAL) ||
> > is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm) ||
> > vma_is_dax(vma) || vma_is_secretmem(vma))
The special handling you mentioned in mlock_fixup mostly makes sense to me.
E.g., I think we can just ignore mlock a hugetlb page if it won't be
swapped anyway.
Do you encounter any issue with above?
> > Should there be a common function to handle VMA merge/split ?
IMHO vma_merge() and split_vma() are the "common functions". Copy Lorenzo
as I think he has plan to look into the interface to make it even easier to
use.
--
Peter Xu