diff options
| -rw-r--r-- | fs/exec.c | 12 | ||||
| -rw-r--r-- | include/linux/mm.h | 2 | ||||
| -rw-r--r-- | mm/fremap.c | 24 | ||||
| -rw-r--r-- | mm/memory.c | 26 |
4 files changed, 19 insertions, 45 deletions
| @@ -306,9 +306,6 @@ void install_arg_page(struct vm_area_struct *vma, | |||
| 306 | struct page *page, unsigned long address) | 306 | struct page *page, unsigned long address) |
| 307 | { | 307 | { |
| 308 | struct mm_struct *mm = vma->vm_mm; | 308 | struct mm_struct *mm = vma->vm_mm; |
| 309 | pgd_t * pgd; | ||
| 310 | pud_t * pud; | ||
| 311 | pmd_t * pmd; | ||
| 312 | pte_t * pte; | 309 | pte_t * pte; |
| 313 | spinlock_t *ptl; | 310 | spinlock_t *ptl; |
| 314 | 311 | ||
| @@ -316,14 +313,7 @@ void install_arg_page(struct vm_area_struct *vma, | |||
| 316 | goto out; | 313 | goto out; |
| 317 | 314 | ||
| 318 | flush_dcache_page(page); | 315 | flush_dcache_page(page); |
| 319 | pgd = pgd_offset(mm, address); | 316 | pte = get_locked_pte(mm, address, &ptl); |
| 320 | pud = pud_alloc(mm, pgd, address); | ||
| 321 | if (!pud) | ||
| 322 | goto out; | ||
| 323 | pmd = pmd_alloc(mm, pud, address); | ||
| 324 | if (!pmd) | ||
| 325 | goto out; | ||
| 326 | pte = pte_alloc_map_lock(mm, pmd, address, &ptl); | ||
| 327 | if (!pte) | 317 | if (!pte) |
| 328 | goto out; | 318 | goto out; |
| 329 | if (!pte_none(*pte)) { | 319 | if (!pte_none(*pte)) { |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 74f90d7eb5ef..0e73f1539d08 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -742,6 +742,8 @@ struct shrinker; | |||
| 742 | extern struct shrinker *set_shrinker(int, shrinker_t); | 742 | extern struct shrinker *set_shrinker(int, shrinker_t); |
| 743 | extern void remove_shrinker(struct shrinker *shrinker); | 743 | extern void remove_shrinker(struct shrinker *shrinker); |
| 744 | 744 | ||
| 745 | extern pte_t *FASTCALL(get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl)); | ||
| 746 | |||
| 745 | int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address); | 747 | int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address); |
| 746 | int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address); | 748 | int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address); |
| 747 | int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address); | 749 | int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address); |
diff --git a/mm/fremap.c b/mm/fremap.c index f851775e09c2..9f381e58bf44 100644 --- a/mm/fremap.c +++ b/mm/fremap.c | |||
| @@ -55,20 +55,10 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 55 | pgoff_t size; | 55 | pgoff_t size; |
| 56 | int err = -ENOMEM; | 56 | int err = -ENOMEM; |
| 57 | pte_t *pte; | 57 | pte_t *pte; |
| 58 | pmd_t *pmd; | ||
| 59 | pud_t *pud; | ||
| 60 | pgd_t *pgd; | ||
| 61 | pte_t pte_val; | 58 | pte_t pte_val; |
| 62 | spinlock_t *ptl; | 59 | spinlock_t *ptl; |
| 63 | 60 | ||
| 64 | pgd = pgd_offset(mm, addr); | 61 | pte = get_locked_pte(mm, addr, &ptl); |
| 65 | pud = pud_alloc(mm, pgd, addr); | ||
| 66 | if (!pud) | ||
| 67 | goto out; | ||
| 68 | pmd = pmd_alloc(mm, pud, addr); | ||
| 69 | if (!pmd) | ||
| 70 | goto out; | ||
| 71 | pte = pte_alloc_map_lock(mm, pmd, addr, &ptl); | ||
| 72 | if (!pte) | 62 | if (!pte) |
| 73 | goto out; | 63 | goto out; |
| 74 | 64 | ||
| @@ -110,20 +100,10 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 110 | { | 100 | { |
| 111 | int err = -ENOMEM; | 101 | int err = -ENOMEM; |
| 112 | pte_t *pte; | 102 | pte_t *pte; |
| 113 | pmd_t *pmd; | ||
| 114 | pud_t *pud; | ||
| 115 | pgd_t *pgd; | ||
| 116 | pte_t pte_val; | 103 | pte_t pte_val; |
| 117 | spinlock_t *ptl; | 104 | spinlock_t *ptl; |
| 118 | 105 | ||
| 119 | pgd = pgd_offset(mm, addr); | 106 | pte = get_locked_pte(mm, addr, &ptl); |
| 120 | pud = pud_alloc(mm, pgd, addr); | ||
| 121 | if (!pud) | ||
| 122 | goto out; | ||
| 123 | pmd = pmd_alloc(mm, pud, addr); | ||
| 124 | if (!pmd) | ||
| 125 | goto out; | ||
| 126 | pte = pte_alloc_map_lock(mm, pmd, addr, &ptl); | ||
| 127 | if (!pte) | 107 | if (!pte) |
| 128 | goto out; | 108 | goto out; |
| 129 | 109 | ||
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 | ||
| 1149 | pte_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, | |||
| 1156 | static int insert_page(struct mm_struct *mm, unsigned long addr, struct page *page, pgprot_t prot) | 1168 | static 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; |
