From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: "Ricardo Cañuelo Navarro" <rcn@igalia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>,
revest@google.com, kernel-dev@igalia.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Oscar Salvador <osalvador@suse.de>
Subject: Re: [PATCH] mm: fix copy_vma() error handling for hugetlb mappings
Date: Fri, 23 May 2025 11:04:44 +0100 [thread overview]
Message-ID: <edd2b2d1-fdd7-4e11-9024-03098da78dd1@lucifer.local> (raw)
In-Reply-To: <afba02be-21d0-49f2-9ca1-36ee6f7fe27f@lucifer.local>
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!
next prev parent reply other threads:[~2025-05-23 10:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 7:56 Ricardo Cañuelo Navarro
2025-05-23 8:54 ` Oscar Salvador
2025-05-23 9:31 ` Lorenzo Stoakes
2025-05-23 10:00 ` Lorenzo Stoakes
2025-05-23 10:04 ` Lorenzo Stoakes [this message]
2025-05-23 10:44 ` Ricardo Cañuelo Navarro
2025-05-23 11:19 ` Lorenzo Stoakes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=edd2b2d1-fdd7-4e11-9024-03098da78dd1@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=rcn@igalia.com \
--cc=revest@google.com \
--cc=stable@vger.kernel.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox