Re: [PATCH] dax: Release PMD lock even when there is no PMD support in DAX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/18/2018 03:22 PM, Matthew Wilcox wrote:
> 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.

It would still skip the unlock, in case pmdp is !=NULL (and locked) after follow_pte_pmd().
So it wouldn't address, what I intended to address with the patch.

Regards
Jan

> 
> 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;
> 




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux