From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([65.50.211.133]:54397 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756341AbeAROWJ (ORCPT ); Thu, 18 Jan 2018 09:22:09 -0500 Date: Thu, 18 Jan 2018 06:22:07 -0800 From: Matthew Wilcox To: Jan =?iso-8859-1?Q?H=2E_Sch=F6nherr?= Cc: Matthew Wilcox , Ross Zwisler , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] dax: Release PMD lock even when there is no PMD support in DAX Message-ID: <20180118142207.GB28322@bombadil.infradead.org> References: <20180118133839.20587-1-jschoenh@amazon.de> <20180118140739.GA28322@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180118140739.GA28322@bombadil.infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Jan 18, 2018 at 06:07:39AM -0800, Matthew Wilcox wrote: > On Thu, Jan 18, 2018 at 02:38:39PM +0100, Jan H. Sch�nherr wrote: > > The function follow_pte_pmd() can theoretically return after having > > acquired a PMD lock, even when DAX was not compiled with > > CONFIG_FS_DAX_PMD. > > I don't think it can. How would a PMD entry get into a DAX VMA if we > compiled the kernel without CONFIG_FS_DAX_PMD? How about this patch instead? Should shut up sparse nicely. diff --git a/fs/dax.c b/fs/dax.c index 78b72c48374e..fea1b64d111b 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -586,6 +586,12 @@ pgoff_address(pgoff_t pgoff, struct vm_area_struct *vma) return address; } +#ifdef CONFIG_FS_DAX_PMD +#define dax_pmd(pmdp) pmdp +#else +#define dax_pmd(pmdp) 0 +#endif + /* Walk all mappings of a given index of a file and writeprotect them */ static void dax_mapping_entry_mkclean(struct address_space *mapping, pgoff_t index, unsigned long pfn) @@ -621,8 +627,7 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping, * * See Documentation/vm/mmu_notifier.txt */ - if (pmdp) { -#ifdef CONFIG_FS_DAX_PMD + if (dax_pmd(pmdp)) { pmd_t pmd; if (pfn != pmd_pfn(*pmdp)) @@ -638,7 +643,6 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping, set_pmd_at(vma->vm_mm, address, pmdp, pmd); unlock_pmd: spin_unlock(ptl); -#endif } else { if (pfn != pte_pfn(*ptep)) goto unlock_pte;