diff options
Diffstat (limited to 'mm/msync.c')
-rw-r--r-- | mm/msync.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/mm/msync.c b/mm/msync.c index 860395486060..0e040e9c39d8 100644 --- a/mm/msync.c +++ b/mm/msync.c | |||
@@ -17,28 +17,22 @@ | |||
17 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
18 | #include <asm/tlbflush.h> | 18 | #include <asm/tlbflush.h> |
19 | 19 | ||
20 | /* | ||
21 | * Called with mm->page_table_lock held to protect against other | ||
22 | * threads/the swapper from ripping pte's out from under us. | ||
23 | */ | ||
24 | |||
25 | static void msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | 20 | static void msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd, |
26 | unsigned long addr, unsigned long end) | 21 | unsigned long addr, unsigned long end) |
27 | { | 22 | { |
28 | struct mm_struct *mm = vma->vm_mm; | ||
29 | pte_t *pte; | 23 | pte_t *pte; |
24 | spinlock_t *ptl; | ||
30 | int progress = 0; | 25 | int progress = 0; |
31 | 26 | ||
32 | again: | 27 | again: |
33 | pte = pte_offset_map(pmd, addr); | 28 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); |
34 | do { | 29 | do { |
35 | unsigned long pfn; | 30 | unsigned long pfn; |
36 | struct page *page; | 31 | struct page *page; |
37 | 32 | ||
38 | if (progress >= 64) { | 33 | if (progress >= 64) { |
39 | progress = 0; | 34 | progress = 0; |
40 | if (need_resched() || | 35 | if (need_resched() || need_lockbreak(ptl)) |
41 | need_lockbreak(&mm->page_table_lock)) | ||
42 | break; | 36 | break; |
43 | } | 37 | } |
44 | progress++; | 38 | progress++; |
@@ -58,8 +52,8 @@ again: | |||
58 | set_page_dirty(page); | 52 | set_page_dirty(page); |
59 | progress += 3; | 53 | progress += 3; |
60 | } while (pte++, addr += PAGE_SIZE, addr != end); | 54 | } while (pte++, addr += PAGE_SIZE, addr != end); |
61 | pte_unmap(pte - 1); | 55 | pte_unmap_unlock(pte - 1, ptl); |
62 | cond_resched_lock(&mm->page_table_lock); | 56 | cond_resched(); |
63 | if (addr != end) | 57 | if (addr != end) |
64 | goto again; | 58 | goto again; |
65 | } | 59 | } |
@@ -97,7 +91,6 @@ static inline void msync_pud_range(struct vm_area_struct *vma, pgd_t *pgd, | |||
97 | static void msync_page_range(struct vm_area_struct *vma, | 91 | static void msync_page_range(struct vm_area_struct *vma, |
98 | unsigned long addr, unsigned long end) | 92 | unsigned long addr, unsigned long end) |
99 | { | 93 | { |
100 | struct mm_struct *mm = vma->vm_mm; | ||
101 | pgd_t *pgd; | 94 | pgd_t *pgd; |
102 | unsigned long next; | 95 | unsigned long next; |
103 | 96 | ||
@@ -110,16 +103,14 @@ static void msync_page_range(struct vm_area_struct *vma, | |||
110 | return; | 103 | return; |
111 | 104 | ||
112 | BUG_ON(addr >= end); | 105 | BUG_ON(addr >= end); |
113 | pgd = pgd_offset(mm, addr); | 106 | pgd = pgd_offset(vma->vm_mm, addr); |
114 | flush_cache_range(vma, addr, end); | 107 | flush_cache_range(vma, addr, end); |
115 | spin_lock(&mm->page_table_lock); | ||
116 | do { | 108 | do { |
117 | next = pgd_addr_end(addr, end); | 109 | next = pgd_addr_end(addr, end); |
118 | if (pgd_none_or_clear_bad(pgd)) | 110 | if (pgd_none_or_clear_bad(pgd)) |
119 | continue; | 111 | continue; |
120 | msync_pud_range(vma, pgd, addr, next); | 112 | msync_pud_range(vma, pgd, addr, next); |
121 | } while (pgd++, addr = next, addr != end); | 113 | } while (pgd++, addr = next, addr != end); |
122 | spin_unlock(&mm->page_table_lock); | ||
123 | } | 114 | } |
124 | 115 | ||
125 | /* | 116 | /* |