Return-Path: Date: Sun, 23 Dec 2018 01:14:12 +0300 From: "Kirill A. Shutemov" To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Hugh Dickins , Naoya Horiguchi , "Aneesh Kumar K . V" , Andrea Arcangeli , "Kirill A . Shutemov" , Davidlohr Bueso , Prakash Sangappa , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH v2 2/2] hugetlbfs: Use i_mmap_rwsem to fix page fault/truncate race Message-ID: <20181222221411.ktm5qeebi43lvce5@kshutemo-mobl1> References: <20181218223557.5202-1-mike.kravetz@oracle.com> <20181218223557.5202-3-mike.kravetz@oracle.com> <20181221102824.5v36l6l5t2zthpgr@kshutemo-mobl1> <849f5202-2200-265f-7769-8363053e8373@oracle.com> <20181221202136.crrwojz3k7muvyrh@kshutemo-mobl1> <732c0b7d-5a4e-97a8-9677-30f3520893cb@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <732c0b7d-5a4e-97a8-9677-30f3520893cb@oracle.com> Sender: owner-linux-mm@kvack.org List-ID: 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