vma_needs_copy always true for VM_HUGETLB ?

From: Mike Kravetz
Date: Wed May 18 2022 - 18:37:00 EST


For most non-anonymous vmas, we do not copy page tables at fork time, but
rather lazily populate the tables after fork via faults. The routine
vma_needs_copy() is used to make this decision. For VM_HUGETLB vmas, it always
returns true.

Anyone know/remember why? The code was added more than 15 years ago and
my search for why hugetlb vmas were excluded came up empty.

I do not see a reason why VM_HUGETLB is in this list. Initial testing did
not reveal any problems when I removed the VM_HUGETLB check.

FYI - I am looking at the performance of fork and exec (unmap) of processes
with very large hugetlb mappings. Skipping the copy at fork time would
certainly speed things up. Of course, there could some users who would
notice if hugetlb page tables are not copied at fork time. However, this
is the behavior for 'normal' mappings. I am inclined to make hugetlb be
'more normal'.
--
Mike Kravetz