lkml.org 
[lkml]   [2013]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] uprobes: Change __copy_insn() to use copy_from_page()
On Sun, Mar 24, 2013 at 07:21:15PM +0100, Oleg Nesterov wrote:
> Change __copy_insn() to use copy_from_page() and simplify the code.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> kernel/events/uprobes.c | 13 ++-----------
> 1 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index d6891cb..0a759c6 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -477,30 +477,21 @@ __copy_insn(struct address_space *mapping, struct file *filp, char *insn,
> unsigned long nbytes, loff_t offset)
> {
> struct page *page;
> - void *vaddr;
> - unsigned long off;
> - pgoff_t idx;
>
> if (!filp)
> return -EINVAL;
>
> if (!mapping->a_ops->readpage)
> return -EIO;
> -
> - idx = offset >> PAGE_CACHE_SHIFT;
> - off = offset & ~PAGE_MASK;
> -
> /*
> * Ensure that the page that has the original instruction is
> * populated and in page-cache.
> */
> - page = read_mapping_page(mapping, idx, filp);
> + page = read_mapping_page(mapping, offset >> PAGE_CACHE_SHIFT, filp);
> if (IS_ERR(page))
> return PTR_ERR(page);
>
> - vaddr = kmap_atomic(page);
> - memcpy(insn, vaddr + off, nbytes);
> - kunmap_atomic(vaddr);
> + copy_from_page(page, offset, insn, nbytes);
> page_cache_release(page);
>
> return 0;
> --
> 1.5.5.1
>
Acked-by: Anton Arapov <anton@redhat.com>


\
 
 \ /
  Last update: 2013-03-25 12:01    [W:0.378 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site