diff options
| author | Davidlohr Bueso <dave@stgolabs.net> | 2014-12-12 19:54:33 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:45 -0500 |
| commit | 874bfcaf79e39135cd31e1cfc9265cf5222d1ec3 (patch) | |
| tree | 5a1406cdca818914446b73213f417e63531397d6 | |
| parent | 4a23717a236b2ab31efb1651f586126789fc997f (diff) | |
mm/xip: share the i_mmap_rwsem
__xip_unmap() will remove the xip sparse page from the cache and take down
pte mapping, without altering the interval tree, thus share the
i_mmap_rwsem when searching for the ptes to unmap.
Additionally, tidy up the function a bit and make variables only local to
the interval tree walk loop.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: "Kirill A. Shutemov" <kirill@shutemov.name>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | mm/filemap_xip.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c index bad746bde4a2..0d105aeff82f 100644 --- a/mm/filemap_xip.c +++ b/mm/filemap_xip.c | |||
| @@ -155,22 +155,14 @@ xip_file_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) | |||
| 155 | EXPORT_SYMBOL_GPL(xip_file_read); | 155 | EXPORT_SYMBOL_GPL(xip_file_read); |
| 156 | 156 | ||
| 157 | /* | 157 | /* |
| 158 | * __xip_unmap is invoked from xip_unmap and | 158 | * __xip_unmap is invoked from xip_unmap and xip_write |
| 159 | * xip_write | ||
| 160 | * | 159 | * |
| 161 | * This function walks all vmas of the address_space and unmaps the | 160 | * This function walks all vmas of the address_space and unmaps the |
| 162 | * __xip_sparse_page when found at pgoff. | 161 | * __xip_sparse_page when found at pgoff. |
| 163 | */ | 162 | */ |
| 164 | static void | 163 | static void __xip_unmap(struct address_space * mapping, unsigned long pgoff) |
| 165 | __xip_unmap (struct address_space * mapping, | ||
| 166 | unsigned long pgoff) | ||
| 167 | { | 164 | { |
| 168 | struct vm_area_struct *vma; | 165 | struct vm_area_struct *vma; |
| 169 | struct mm_struct *mm; | ||
| 170 | unsigned long address; | ||
| 171 | pte_t *pte; | ||
| 172 | pte_t pteval; | ||
| 173 | spinlock_t *ptl; | ||
| 174 | struct page *page; | 166 | struct page *page; |
| 175 | unsigned count; | 167 | unsigned count; |
| 176 | int locked = 0; | 168 | int locked = 0; |
| @@ -182,11 +174,14 @@ __xip_unmap (struct address_space * mapping, | |||
| 182 | return; | 174 | return; |
| 183 | 175 | ||
| 184 | retry: | 176 | retry: |
| 185 | i_mmap_lock_write(mapping); | 177 | i_mmap_lock_read(mapping); |
| 186 | vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { | 178 | vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { |
| 187 | mm = vma->vm_mm; | 179 | pte_t *pte, pteval; |
| 188 | address = vma->vm_start + | 180 | spinlock_t *ptl; |
| 181 | struct mm_struct *mm = vma->vm_mm; | ||
| 182 | unsigned long address = vma->vm_start + | ||
| 189 | ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); | 183 | ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); |
| 184 | |||
| 190 | BUG_ON(address < vma->vm_start || address >= vma->vm_end); | 185 | BUG_ON(address < vma->vm_start || address >= vma->vm_end); |
| 191 | pte = page_check_address(page, mm, address, &ptl, 1); | 186 | pte = page_check_address(page, mm, address, &ptl, 1); |
| 192 | if (pte) { | 187 | if (pte) { |
| @@ -202,7 +197,7 @@ retry: | |||
| 202 | page_cache_release(page); | 197 | page_cache_release(page); |
| 203 | } | 198 | } |
| 204 | } | 199 | } |
| 205 | i_mmap_unlock_write(mapping); | 200 | i_mmap_unlock_read(mapping); |
| 206 | 201 | ||
| 207 | if (locked) { | 202 | if (locked) { |
| 208 | mutex_unlock(&xip_sparse_mutex); | 203 | mutex_unlock(&xip_sparse_mutex); |
