Re: [PATCH 1/2] hugetlbfs: extend hugetlb_vma_lock to private VMAs

From: Mike Kravetz
Date: Wed Sep 20 2023 - 12:37:36 EST


On 09/20/23 00:09, Rik van Riel wrote:
> On Wed, 2023-09-20 at 04:57 +0100, Matthew Wilcox wrote:
> > On Tue, Sep 19, 2023 at 10:16:09PM -0400, riel@xxxxxxxxxxx wrote:
> > > From: Rik van Riel <riel@xxxxxxxxxxx>
> > >
> > > Extend the locking scheme used to protect shared hugetlb mappings
> > > from truncate vs page fault races, in order to protect private
> > > hugetlb mappings (with resv_map) against MADV_DONTNEED.
> > >
> > > Add a read-write semaphore to the resv_map data structure, and
> > > use that from the hugetlb_vma_(un)lock_* functions, in preparation
> > > for closing the race between MADV_DONTNEED and page faults.
> >
> > This feels an awful lot like the invalidate_lock in struct
> > address_space
> > which was recently added by Jan Kara.
> >
> Indeed it does.
>
> It might be even nicer if we could replace the hugetlb_vma_lock
> special logic with the invalidate_lock for hugetlbfs.
>
> Mike, can you think of any reason why the hugetlb_vma_lock logic
> should not be replaced with the invalidate_lock?
>
> If not, I'd be happy to implement that.
>

Sorry Rik,

I have some other things that need immediate attention and have not had a
chance to take a close look here. I'll take a closer look later (my) today
or tomorrow.
--
Mike Kravetz