> This determines whether a VMA cannot be expanded or merged because what > they mapped was determined to be a set size at mmap time. > > This typically refers to kernel-owned mappings, however VMA_DONTEXPAND_BIT > is not reliably set alongside VMA_PFNMAP_BIT or VMA_MIXEDMAP_BIT, so we > must explicitly test for this for now. > > We also explicitly test for VMA_PFNMAP_BIT as VMA_DONTEXPAND_BIT may not be > set for VMA_PFNMAP_BIT's despite the one implying the other. > > Use this predicate in vma_flags_can_merge() and in check_prep_vma() in the > mremap logic testing to see if mremap() can expand the VMA. The criteria > for khugepaged and MADV_COLLAPSE eligibility in > __thp_vma_allowable_orders() are precisely those for mergeability, so use > vma_can_merge() there (with an expanded comment). > > This obviates the need for the VM_NO_KHUGEPAGED mask, so remove it. > > Hugetlb VMAs remain excluded from khugepaged as hugetlbfs always sets > VMA_DONTEXPAND_BIT. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260908-b4-mmap-prepare-vma-flag-sanify-v1-0-dacf19cce...@kernel.org?part=16
