Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1269369
| From | Ross Zwisler <ross.zwisler@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 05/11] mm: add follow_pte_pmd() |
| Date | 2015-11-14 01:20 +0100 |
| Message-ID | <quwJs-4ZF-5@gated-at.bofh.it> (permalink) |
| References | <quwzM-4US-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Similar to follow_pte(), follow_pte_pmd() allows either a PTE leaf or a
huge page PMD leaf to be found and returned.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
---
include/linux/mm.h | 2 ++
mm/memory.c | 38 ++++++++++++++++++++++++++++++--------
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 80001de..393441c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1166,6 +1166,8 @@ int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
struct vm_area_struct *vma);
void unmap_mapping_range(struct address_space *mapping,
loff_t const holebegin, loff_t const holelen, int even_cows);
+int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
+ pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
int follow_pfn(struct vm_area_struct *vma, unsigned long address,
unsigned long *pfn);
int follow_phys(struct vm_area_struct *vma, unsigned long address,
diff --git a/mm/memory.c b/mm/memory.c
index deb679c..7f4090e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3512,8 +3512,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
}
#endif /* __PAGETABLE_PMD_FOLDED */
-static int __follow_pte(struct mm_struct *mm, unsigned long address,
- pte_t **ptepp, spinlock_t **ptlp)
+static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
+ pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
{
pgd_t *pgd;
pud_t *pud;
@@ -3529,12 +3529,20 @@ static int __follow_pte(struct mm_struct *mm, unsigned long address,
goto out;
pmd = pmd_offset(pud, address);
- VM_BUG_ON(pmd_trans_huge(*pmd));
- if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
- goto out;
- /* We cannot handle huge page PFN maps. Luckily they don't exist. */
- if (pmd_huge(*pmd))
+ if (pmd_huge(*pmd)) {
+ if (!pmdpp)
+ goto out;
+
+ *ptlp = pmd_lock(mm, pmd);
+ if (pmd_huge(*pmd)) {
+ *pmdpp = pmd;
+ return 0;
+ }
+ spin_unlock(*ptlp);
+ }
+
+ if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
goto out;
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
@@ -3557,9 +3565,23 @@ static inline int follow_pte(struct mm_struct *mm, unsigned long address,
/* (void) is needed to make gcc happy */
(void) __cond_lock(*ptlp,
- !(res = __follow_pte(mm, address, ptepp, ptlp)));
+ !(res = __follow_pte_pmd(mm, address, ptepp, NULL,
+ ptlp)));
+ return res;
+}
+
+int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
+ pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
+{
+ int res;
+
+ /* (void) is needed to make gcc happy */
+ (void) __cond_lock(*ptlp,
+ !(res = __follow_pte_pmd(mm, address, ptepp, pmdpp,
+ ptlp)));
return res;
}
+EXPORT_SYMBOL(follow_pte_pmd);
/**
* follow_pfn - look up PFN at a user virtual address
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 00/11] DAX fsynx/msync support Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:10 +0100
[PATCH v2 09/11] ext2: add support for DAX fsync/msync Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:10 +0100
[PATCH v2 07/11] mm: add find_get_entries_tag() Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:10 +0100
[PATCH v2 10/11] ext4: add support for DAX fsync/msync Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:10 +0100
[PATCH v2 11/11] xfs: add support for DAX fsync/msync Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:10 +0100
[PATCH v2 05/11] mm: add follow_pte_pmd() Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
[PATCH v2 01/11] pmem: add wb_cache_pmem() to the PMEM API Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
[PATCH v2 08/11] dax: add support for fsync/sync Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
[PATCH v2 03/11] pmem: enable REQ_FUA/REQ_FLUSH handling Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
Re: [PATCH v2 03/11] pmem: enable REQ_FUA/REQ_FLUSH handling Dan Williams <dan.j.williams@intel.com> - 2015-11-14 01:30 +0100
Re: [PATCH v2 03/11] pmem: enable REQ_FUA/REQ_FLUSH handling Andreas Dilger <adilger@dilger.ca> - 2015-11-14 01:50 +0100
Re: [PATCH v2 03/11] pmem: enable REQ_FUA/REQ_FLUSH handling Dan Williams <dan.j.williams@intel.com> - 2015-11-14 03:40 +0100
[PATCH v2 06/11] mm: add pgoff_mkclean() Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
[PATCH v2 02/11] mm: add pmd_mkclean() Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
Re: [PATCH v2 02/11] mm: add pmd_mkclean() Dave Hansen <dave.hansen@intel.com> - 2015-11-14 02:10 +0100
[PATCH v2 04/11] dax: support dirty DAX entries in radix tree Ross Zwisler <ross.zwisler@linux.intel.com> - 2015-11-14 01:20 +0100
csiph-web