From: Peter Zijlstra <peterz@infradead.org>
To: will.deacon@arm.com, fweisbec@gmail.com
Cc: mingo@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] perf: Fix arch_perf_out_copy_user default implementation
Date: Wed, 30 Oct 2013 19:44:42 +0100 [thread overview]
Message-ID: <20131030184442.GQ2490@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <20131030143750.GT19466@laptop.lan>
Subject: perf: Fix arch_perf_out_copy_user default implementation
I noticed that the arch_perf_output_copy_user default of
__copy_from_user_inatomic has different return semantics that all other
memcpy functions we use -- notably also copy_from_user_nmi() for x86.
So provide a compatible default function.
Also change all the memcpy functions to use unsigned long.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
kernel/events/internal.h | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index ca6599723be5..325e85776406 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -82,14 +82,14 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
}
#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
-static inline unsigned int \
+static inline unsigned long \
func_name(struct perf_output_handle *handle, \
- const void *buf, unsigned int len) \
+ const void *buf, unsigned long len) \
{ \
unsigned long size, written; \
\
do { \
- size = min_t(unsigned long, handle->size, len); \
+ size = min(handle->size, len); \
\
written = memcpy_func(handle->addr, buf, size); \
\
@@ -110,7 +110,8 @@ func_name(struct perf_output_handle *handle, \
return len; \
}
-static inline int memcpy_common(void *dst, const void *src, size_t n)
+static inline unsigned long
+memcpy_common(void *dst, const void *src, unsigned long n)
{
memcpy(dst, src, n);
return n;
@@ -118,12 +119,28 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
-#define MEMCPY_SKIP(dst, src, n) (n)
+static inline unsigned long
+memcpy_skip(void *dst, const void *src, unsigned long n)
+{
+ return n;
+}
-DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
+DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
#ifndef arch_perf_out_copy_user
-#define arch_perf_out_copy_user __copy_from_user_inatomic
+#define arch_perf_out_copy_user arch_perf_out_copy_user
+
+static inline unsigned long
+arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
+{
+ unsigned long ret;
+
+ pagefault_disable();
+ ret = __copy_from_user_inatomic(dst, src, n);
+ pagefault_enable();
+
+ return n - ret;
+}
#endif
DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
next prev parent reply other threads:[~2013-10-30 18:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 14:37 [BUG] perf: arch_perf_out_copy_user default Peter Zijlstra
2013-10-30 18:44 ` Peter Zijlstra [this message]
2013-10-30 19:29 ` Will Deacon
2013-10-30 19:35 ` Peter Zijlstra
2013-10-30 19:50 ` Frederic Weisbecker
2013-10-30 20:16 ` Peter Zijlstra
2013-10-30 20:47 ` Frederic Weisbecker
2013-10-30 22:31 ` Will Deacon
2013-11-06 13:19 ` [tip:perf/core] perf: Fix " tip-bot for Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131030184442.GQ2490@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.