Re: [PATCH v2 2/2] hugetlbfs: Use i_mmap_rwsem to fix page fault/truncate race

From: Kirill A. Shutemov
Date: Sat Dec 22 2018 - 17:22:46 EST


On Fri, Dec 21, 2018 at 02:17:32PM -0800, Mike Kravetz wrote:
> Am I misunderstanding your question/concern?

No. Thanks for the clarification.

>
> I have decided to add the locking (although unnecessary) with something like
> this in hugetlbfs_evict_inode.
>
> /*
> * The vfs layer guarantees that there are no other users of this
> * inode. Therefore, it would be safe to call remove_inode_hugepages
> * without holding i_mmap_rwsem. We acquire and hold here to be
> * consistent with other callers. Since there will be no contention
> * on the semaphore, overhead is negligible.
> */
> i_mmap_lock_write(mapping);
> remove_inode_hugepages(inode, 0, LLONG_MAX);
> i_mmap_unlock_write(mapping);

LGTM.

--
Kirill A. Shutemov