Commit 194f8dcb authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

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: default avatarOleg 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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 57683f72
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/swap.h> /* try_to_free_swap */ #include <linux/swap.h> /* try_to_free_swap */
#include <linux/ptrace.h> /* user_enable_single_step */ #include <linux/ptrace.h> /* user_enable_single_step */
#include <linux/kdebug.h> /* notifier mechanism */ #include <linux/kdebug.h> /* notifier mechanism */
#include "../../mm/internal.h" /* munlock_vma_page */
#include <linux/uprobes.h> #include <linux/uprobes.h>
...@@ -141,7 +142,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, ...@@ -141,7 +142,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
pte_t *ptep; pte_t *ptep;
int err; int err;
/* freeze PageSwapCache() for try_to_free_swap() below */ /* For try_to_free_swap() and munlock_vma_page() below */
lock_page(page); lock_page(page);
err = -EAGAIN; err = -EAGAIN;
...@@ -164,9 +165,12 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, ...@@ -164,9 +165,12 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
page_remove_rmap(page); page_remove_rmap(page);
if (!page_mapped(page)) if (!page_mapped(page))
try_to_free_swap(page); try_to_free_swap(page);
put_page(page);
pte_unmap_unlock(ptep, ptl); pte_unmap_unlock(ptep, ptl);
if (vma->vm_flags & VM_LOCKED)
munlock_vma_page(page);
put_page(page);
err = 0; err = 0;
unlock: unlock:
unlock_page(page); unlock_page(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment