diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-07-29 14:22:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-07-30 05:27:25 -0400 |
commit | 194f8dcbe9629d8e9346cf96345a9c0bbf0e67ae (patch) | |
tree | 10aac2913ee4f9263af68c42682c456788d990fe /kernel/events/uprobes.c | |
parent | 57683f72b8c01c53c85fe13e82fe1feb3a06bcd5 (diff) |
uprobes: __replace_page() needs munlock_vma_page()
Like do_wp_page(), __replace_page() should do munlock_vma_page()
for the case when the old page still has other !VM_LOCKED
mappings. Unfortunately this needs mm/internal.h.
Also, move put_page() outside of ptl lock. This doesn't really
matter but looks a bit better.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar.vnet.ibm.com>
Cc: Anton Arapov <anton@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20120729182249.GA20372@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events/uprobes.c')
-rw-r--r-- | kernel/events/uprobes.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index bb30a4fc5050..c08a22d02f72 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/swap.h> /* try_to_free_swap */ | 32 | #include <linux/swap.h> /* try_to_free_swap */ |
33 | #include <linux/ptrace.h> /* user_enable_single_step */ | 33 | #include <linux/ptrace.h> /* user_enable_single_step */ |
34 | #include <linux/kdebug.h> /* notifier mechanism */ | 34 | #include <linux/kdebug.h> /* notifier mechanism */ |
35 | #include "../../mm/internal.h" /* munlock_vma_page */ | ||
35 | 36 | ||
36 | #include <linux/uprobes.h> | 37 | #include <linux/uprobes.h> |
37 | 38 | ||
@@ -141,7 +142,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, | |||
141 | pte_t *ptep; | 142 | pte_t *ptep; |
142 | int err; | 143 | int err; |
143 | 144 | ||
144 | /* freeze PageSwapCache() for try_to_free_swap() below */ | 145 | /* For try_to_free_swap() and munlock_vma_page() below */ |
145 | lock_page(page); | 146 | lock_page(page); |
146 | 147 | ||
147 | err = -EAGAIN; | 148 | err = -EAGAIN; |
@@ -164,9 +165,12 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, | |||
164 | page_remove_rmap(page); | 165 | page_remove_rmap(page); |
165 | if (!page_mapped(page)) | 166 | if (!page_mapped(page)) |
166 | try_to_free_swap(page); | 167 | try_to_free_swap(page); |
167 | put_page(page); | ||
168 | pte_unmap_unlock(ptep, ptl); | 168 | pte_unmap_unlock(ptep, ptl); |
169 | 169 | ||
170 | if (vma->vm_flags & VM_LOCKED) | ||
171 | munlock_vma_page(page); | ||
172 | put_page(page); | ||
173 | |||
170 | err = 0; | 174 | err = 0; |
171 | unlock: | 175 | unlock: |
172 | unlock_page(page); | 176 | unlock_page(page); |