On Thu, 22 Dec 2022 16:39:53 -0800 "Zach O'Keefe" <zokeefe@xxxxxxxxxx> wrote: > MADV_COLLAPSE acts on one hugepage-aligned/sized region at a time, until > it has collapsed all eligible memory contained within the bounds > supplied by the user. > > At the top of each hugepage iteration we (re)lock mmap_lock and > (re)validate the VMA for eligibility and update variables that might > have changed while mmap_lock was dropped. One thing that might occur, > is that the VMA could be resized, and as such, we refetch vma->vm_end > to make sure we don't collapse past the end of the VMA. > > However, it's possible that during this refetch that we expand the > region acted on by MADV_COLLAPSE if vma->vm_end is greater than the end > of the user-supplied range. > > Don't expand the acted-on region when refetching vma->vm_end. What are the user-visible effects of this? > Fixes: 4d24de9425f7 ("mm: MADV_COLLAPSE: refetch vm_end after reacquiring mmap_lock") Should we backport "mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE" and/or this patch into 6.1.x?