uprobes: Change write_opcode() to use copy_*page()
authorOleg Nesterov <oleg@redhat.com>
Sun, 24 Mar 2013 18:04:36 +0000 (19:04 +0100)
committerOleg Nesterov <oleg@redhat.com>
Thu, 4 Apr 2013 11:57:06 +0000 (13:57 +0200)
Change write_opcode() to use copy_highpage() + copy_to_page()
and simplify the code.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Anton Arapov <anton@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
kernel/events/uprobes.c

index b8255eaca1909b1334cb4b8393422565f415b93e..7312503caf2e5b03c41cc426e994442445df8c51 100644 (file)
@@ -255,7 +255,6 @@ static int write_opcode(struct mm_struct *mm, unsigned long vaddr,
                        uprobe_opcode_t opcode)
 {
        struct page *old_page, *new_page;
-       void *vaddr_old, *vaddr_new;
        struct vm_area_struct *vma;
        int ret;
 
@@ -276,15 +275,8 @@ retry:
 
        __SetPageUptodate(new_page);
 
-       /* copy the page now that we've got it stable */
-       vaddr_old = kmap_atomic(old_page);
-       vaddr_new = kmap_atomic(new_page);
-
-       memcpy(vaddr_new, vaddr_old, PAGE_SIZE);
-       memcpy(vaddr_new + (vaddr & ~PAGE_MASK), &opcode, UPROBE_SWBP_INSN_SIZE);
-
-       kunmap_atomic(vaddr_new);
-       kunmap_atomic(vaddr_old);
+       copy_highpage(new_page, old_page);
+       copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE);
 
        ret = anon_vma_prepare(vma);
        if (ret)