aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/oprofile
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2011-06-07 05:49:55 -0400
committerIngo Molnar <mingo@elte.hu>2011-07-21 14:41:57 -0400
commit1ac2e6ca44e13a087eb7438d284f887097ee7e84 (patch)
tree7ee4f00a67850e1e247610cefeae0ee7aa7b239a /arch/x86/oprofile
parent9985c20f9e4aee6857c08246b273a3695a52b929 (diff)
x86, perf: Make copy_from_user_nmi() a library function
copy_from_user_nmi() is used in oprofile and perf. Moving it to other library functions like copy_from_user(). As this is x86 code for 32 and 64 bits, create a new file usercopy.c for unified code. Signed-off-by: Robert Richter <robert.richter@amd.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20110607172413.GJ20052@erda.amd.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/oprofile')
-rw-r--r--arch/x86/oprofile/backtrace.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
index 32f78eb46744..bff89dfe3619 100644
--- a/arch/x86/oprofile/backtrace.c
+++ b/arch/x86/oprofile/backtrace.c
@@ -12,10 +12,9 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/compat.h> 14#include <linux/compat.h>
15#include <linux/highmem.h> 15#include <linux/uaccess.h>
16 16
17#include <asm/ptrace.h> 17#include <asm/ptrace.h>
18#include <asm/uaccess.h>
19#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
20 19
21static int backtrace_stack(void *data, char *name) 20static int backtrace_stack(void *data, char *name)
@@ -38,42 +37,6 @@ static struct stacktrace_ops backtrace_ops = {
38 .walk_stack = print_context_stack, 37 .walk_stack = print_context_stack,
39}; 38};
40 39
41/* from arch/x86/kernel/cpu/perf_event.c: */
42
43/*
44 * best effort, GUP based copy_from_user() that assumes IRQ or NMI context
45 */
46static unsigned long
47copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
48{
49 unsigned long offset, addr = (unsigned long)from;
50 unsigned long size, len = 0;
51 struct page *page;
52 void *map;
53 int ret;
54
55 do {
56 ret = __get_user_pages_fast(addr, 1, 0, &page);
57 if (!ret)
58 break;
59
60 offset = addr & (PAGE_SIZE - 1);
61 size = min(PAGE_SIZE - offset, n - len);
62
63 map = kmap_atomic(page);
64 memcpy(to, map+offset, size);
65 kunmap_atomic(map);
66 put_page(page);
67
68 len += size;
69 to += size;
70 addr += size;
71
72 } while (len < n);
73
74 return len;
75}
76
77#ifdef CONFIG_COMPAT 40#ifdef CONFIG_COMPAT
78static struct stack_frame_ia32 * 41static struct stack_frame_ia32 *
79dump_user_backtrace_32(struct stack_frame_ia32 *head) 42dump_user_backtrace_32(struct stack_frame_ia32 *head)