On Fri, May 23, 2025 at 11:00:40AM +0100, Lorenzo Stoakes wrote: [snip]
mm/vma.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/mm/vma.c b/mm/vma.c index 839d12f02c885d3338d8d233583eb302d82bb80b..9d9f699ace977c9c869e5da5f88f12be183adcfb 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1834,6 +1834,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, return new_vma;
out_vma_link:
- if (is_vm_hugetlb_page(new_vma))
clear_vma_resv_huge_pages(new_vma);
So,
Could you implement this slightly differently please? We're duplicating this code now, so I think this should be in its own function with a copious comment.
Something like:
static void fixup_hugetlb_reservations(struct vm_area_struct *vma) { if (is_vm_hugetlb_page(new_vma)) clear_vma_resv_huge_pages(new_vma); }
And call this from here and also in copy_vma_and_data().
Sorry, I wasn't clear, Can you please ensure that you put a chonking big comment on this function too please? Something that explains the situation, e.g.:
/* * For hugetlb, mremap() is an odd edge case - while the VMA copying is * performed, we permit both the old and new VMAs to reference the same * reservation. * * We fix this up after the operation succeeds, or if a newly allocated VMA * is closed as a result of a failure to allocate memory. */
[snip]
Thanks!