diff options
author | Peter Zijlstra <peterz@infradead.org> | 2013-10-30 16:16:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-11-06 06:34:25 -0500 |
commit | 0a196848ca365ec582c6d86659be456be6d4ed96 (patch) | |
tree | b850a9d23a0b487d3e0e6c72b0974569796edf56 /kernel/events/internal.h | |
parent | 394570b7939e1262f39373866166d8ee0a506e88 (diff) |
perf: Fix arch_perf_out_copy_user default
The arch_perf_output_copy_user() default of
__copy_from_user_inatomic() returns bytes not copied, while all other
argument functions given DEFINE_OUTPUT_COPY() return bytes copied.
Since copy_from_user_nmi() is the odd duck out by returning bytes
copied where all other *copy_{to,from}* functions return bytes not
copied, change it over and ammend DEFINE_OUTPUT_COPY() to expect bytes
not copied.
Oddly enough DEFINE_OUTPUT_COPY() already returned bytes not copied
while expecting its worker functions to return bytes copied.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: will.deacon@arm.com
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/20131030201622.GR16117@laptop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events/internal.h')
-rw-r--r-- | kernel/events/internal.h | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/kernel/events/internal.h b/kernel/events/internal.h index ca6599723be5..569b218782ad 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h | |||
@@ -82,16 +82,16 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb) | |||
82 | } | 82 | } |
83 | 83 | ||
84 | #define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \ | 84 | #define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \ |
85 | static inline unsigned int \ | 85 | static inline unsigned long \ |
86 | func_name(struct perf_output_handle *handle, \ | 86 | func_name(struct perf_output_handle *handle, \ |
87 | const void *buf, unsigned int len) \ | 87 | const void *buf, unsigned long len) \ |
88 | { \ | 88 | { \ |
89 | unsigned long size, written; \ | 89 | unsigned long size, written; \ |
90 | \ | 90 | \ |
91 | do { \ | 91 | do { \ |
92 | size = min_t(unsigned long, handle->size, len); \ | 92 | size = min(handle->size, len); \ |
93 | \ | ||
94 | written = memcpy_func(handle->addr, buf, size); \ | 93 | written = memcpy_func(handle->addr, buf, size); \ |
94 | written = size - written; \ | ||
95 | \ | 95 | \ |
96 | len -= written; \ | 96 | len -= written; \ |
97 | handle->addr += written; \ | 97 | handle->addr += written; \ |
@@ -110,20 +110,37 @@ func_name(struct perf_output_handle *handle, \ | |||
110 | return len; \ | 110 | return len; \ |
111 | } | 111 | } |
112 | 112 | ||
113 | static inline int memcpy_common(void *dst, const void *src, size_t n) | 113 | static inline unsigned long |
114 | memcpy_common(void *dst, const void *src, unsigned long n) | ||
114 | { | 115 | { |
115 | memcpy(dst, src, n); | 116 | memcpy(dst, src, n); |
116 | return n; | 117 | return 0; |
117 | } | 118 | } |
118 | 119 | ||
119 | DEFINE_OUTPUT_COPY(__output_copy, memcpy_common) | 120 | DEFINE_OUTPUT_COPY(__output_copy, memcpy_common) |
120 | 121 | ||
121 | #define MEMCPY_SKIP(dst, src, n) (n) | 122 | static inline unsigned long |
123 | memcpy_skip(void *dst, const void *src, unsigned long n) | ||
124 | { | ||
125 | return 0; | ||
126 | } | ||
122 | 127 | ||
123 | DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP) | 128 | DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip) |
124 | 129 | ||
125 | #ifndef arch_perf_out_copy_user | 130 | #ifndef arch_perf_out_copy_user |
126 | #define arch_perf_out_copy_user __copy_from_user_inatomic | 131 | #define arch_perf_out_copy_user arch_perf_out_copy_user |
132 | |||
133 | static inline unsigned long | ||
134 | arch_perf_out_copy_user(void *dst, const void *src, unsigned long n) | ||
135 | { | ||
136 | unsigned long ret; | ||
137 | |||
138 | pagefault_disable(); | ||
139 | ret = __copy_from_user_inatomic(dst, src, n); | ||
140 | pagefault_enable(); | ||
141 | |||
142 | return ret; | ||
143 | } | ||
127 | #endif | 144 | #endif |
128 | 145 | ||
129 | DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) | 146 | DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) |