aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 990e7dc666f8..74f95ae0510b 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1146,6 +1146,18 @@ int zeromap_page_range(struct vm_area_struct *vma,
1146 return err; 1146 return err;
1147} 1147}
1148 1148
1149pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl)
1150{
1151 pgd_t * pgd = pgd_offset(mm, addr);
1152 pud_t * pud = pud_alloc(mm, pgd, addr);
1153 if (pud) {
1154 pmd_t * pmd = pmd_alloc(mm, pgd, addr);
1155 if (pmd)
1156 return pte_alloc_map_lock(mm, pmd, addr, ptl);
1157 }
1158 return NULL;
1159}
1160
1149/* 1161/*
1150 * This is the old fallback for page remapping. 1162 * This is the old fallback for page remapping.
1151 * 1163 *
@@ -1156,10 +1168,7 @@ int zeromap_page_range(struct vm_area_struct *vma,
1156static int insert_page(struct mm_struct *mm, unsigned long addr, struct page *page, pgprot_t prot) 1168static int insert_page(struct mm_struct *mm, unsigned long addr, struct page *page, pgprot_t prot)
1157{ 1169{
1158 int retval; 1170 int retval;
1159 pgd_t * pgd; 1171 pte_t *pte;
1160 pud_t * pud;
1161 pmd_t * pmd;
1162 pte_t * pte;
1163 spinlock_t *ptl; 1172 spinlock_t *ptl;
1164 1173
1165 retval = -EINVAL; 1174 retval = -EINVAL;
@@ -1167,14 +1176,7 @@ static int insert_page(struct mm_struct *mm, unsigned long addr, struct page *pa
1167 goto out; 1176 goto out;
1168 retval = -ENOMEM; 1177 retval = -ENOMEM;
1169 flush_dcache_page(page); 1178 flush_dcache_page(page);
1170 pgd = pgd_offset(mm, addr); 1179 pte = get_locked_pte(mm, addr, &ptl);
1171 pud = pud_alloc(mm, pgd, addr);
1172 if (!pud)
1173 goto out;
1174 pmd = pmd_alloc(mm, pud, addr);
1175 if (!pmd)
1176 goto out;
1177 pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
1178 if (!pte) 1180 if (!pte)
1179 goto out; 1181 goto out;
1180 retval = -EBUSY; 1182 retval = -EBUSY;