]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - include/linux/mm.h
[PATCH] mm: ptd_alloc take ptlock
[net-next-2.6.git] / include / linux / mm.h
index 22c2d6922c0e9ca11b9c419d9d02f36d5267e8ce..d4c3512e7db41be32b816f57562bce2164d21ad5 100644 (file)
@@ -779,10 +779,28 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a
 }
 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
 
+#define pte_offset_map_lock(mm, pmd, address, ptlp)    \
+({                                                     \
+       spinlock_t *__ptl = &(mm)->page_table_lock;     \
+       pte_t *__pte = pte_offset_map(pmd, address);    \
+       *(ptlp) = __ptl;                                \
+       spin_lock(__ptl);                               \
+       __pte;                                          \
+})
+
+#define pte_unmap_unlock(pte, ptl)     do {            \
+       spin_unlock(ptl);                               \
+       pte_unmap(pte);                                 \
+} while (0)
+
 #define pte_alloc_map(mm, pmd, address)                        \
        ((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
                NULL: pte_offset_map(pmd, address))
 
+#define pte_alloc_map_lock(mm, pmd, address, ptlp)     \
+       ((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
+               NULL: pte_offset_map_lock(mm, pmd, address, ptlp))
+
 #define pte_alloc_kernel(pmd, address)                 \
        ((unlikely(!pmd_present(*(pmd))) && __pte_alloc_kernel(pmd, address))? \
                NULL: pte_offset_kernel(pmd, address))