> > @@ -4828,6 +4830,23 @@ static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr) > > { > > if (addr & ~(huge_page_mask(hstate_vma(vma)))) > > return -EINVAL; > > + > > + /* We require PUD_SIZE VMA alignment for PMD sharing. */ > > I can get the point, but it reads slightly awkward. How about: > > /* > * If the address to split can be in the middle of a shared pmd > * range, unshare before split the vma. > */ > How about: /* * PMD sharing is only possible for PUD_SIZE-aligned address ranges * in HugeTLB VMAs. If we will lose PUD_SIZE alignment due to this split, * unshare PMDs in the PUD_SIZE interval surrounding addr now. */ > I remember you had a helper to check pmd sharing possibility. Can use here > depending on whether that existed in the code base or in your hgm series > (or just pick that up with this one?). Right, it introduces `pmd_sharing_possible` but I don't think it helps here. > > > + if (addr & ~PUD_MASK) { > > + /* > > + * hugetlb_vm_op_split is called right before we attempt to > > + * split the VMA. We will need to unshare PMDs in the old and > > + * new VMAs, so let's unshare before we split. > > + */ > > + unsigned long floor = addr & PUD_MASK; > > + unsigned long ceil = floor + PUD_SIZE; > > + > > + if (floor < vma->vm_start || ceil >= vma->vm_end) > > s/>=/>/? Indeed, thanks. > > > + /* PMD sharing is already impossible. */ > > + return 0; > > IMHO slightly cleaner to write in the reversed way and let it fall through: > > if (floor >= vma->vm_start && ceil <= vma->vm_end) > hugetlb_unshare_pmds(vma, floor, ceil); Will do. > > Thanks, > Thanks Peter!