diff options
author | Steve Capper <steve.capper@linaro.org> | 2014-07-10 14:50:12 +0100 |
---|---|---|
committer | Steve Capper <steve.capper@linaro.org> | 2014-07-14 16:19:03 +0100 |
commit | 384a981d667088ed37fd7e7677c63d7a1113c17f (patch) | |
tree | 4912c3edb0d3cb2a8e35175be6f7e3fa9288a96d | |
parent | 1795cd9b3a91d4b5473c97f491d63892442212ab (diff) | |
download | linux-384a981d667088ed37fd7e7677c63d7a1113c17f.tar.gz |
arm64: lib: Add static tracepoint for memcpyarm64-memcpy-trace
To better gauge the memcpy usage across the kernel, this patch creates
a static ftrace probe for memcpy taking the src, dest, size and caller
pc.
TODO: this will add a function call overhead, we could inline the new
memcpy, that would need some thought on how to handle the trace point
logic.
Signed-off-by: Steve Capper <steve.capper@linaro.org>
-rw-r--r-- | arch/arm64/include/asm/trace/events/string.h | 37 | ||||
-rw-r--r-- | arch/arm64/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/arm64/lib/memcpy.S | 4 | ||||
-rw-r--r-- | arch/arm64/lib/tracememcpy.c | 12 |
4 files changed, 52 insertions, 3 deletions
diff --git a/arch/arm64/include/asm/trace/events/string.h b/arch/arm64/include/asm/trace/events/string.h new file mode 100644 index 00000000000..c3649d20003 --- /dev/null +++ b/arch/arm64/include/asm/trace/events/string.h @@ -0,0 +1,37 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM string + +#if !defined(_TRACE_STRING_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_STRING_H + +#include <linux/tracepoint.h> + +TRACE_EVENT(memcpy, + TP_PROTO(void *dest, const void *src, size_t count, void *location), + + TP_ARGS(dest, src, count, location), + + TP_STRUCT__entry( + __field(void *, dest) + __field(const void *, src) + __field(size_t, count) + __field(void *, location) + ), + + TP_fast_assign( + __entry->dest = dest; + __entry->src = src; + __entry->count = count; + __entry->location = location; + ), + + TP_printk("dest=%p src=%p count=%ld location=%p", + __entry->dest, __entry->src, + __entry->count, __entry->location) +); + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH asm/trace/events +#endif /*_TRACE_STRING_H */ + +#include <trace/define_trace.h> diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index d98d3e39879..46c1d40ce31 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -2,4 +2,4 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ - strchr.o strrchr.o + strchr.o strrchr.o tracememcpy.o diff --git a/arch/arm64/lib/memcpy.S b/arch/arm64/lib/memcpy.S index 8a9a96d3dda..0de0ee60776 100644 --- a/arch/arm64/lib/memcpy.S +++ b/arch/arm64/lib/memcpy.S @@ -56,7 +56,7 @@ C_h .req x12 D_l .req x13 D_h .req x14 -ENTRY(memcpy) +ENTRY(memcpy_asm) mov dst, dstin cmp count, #16 /*When memory length is less than 16, the accessed are not aligned.*/ @@ -198,4 +198,4 @@ ENTRY(memcpy) tst count, #0x3f b.ne .Ltail63 ret -ENDPROC(memcpy) +ENDPROC(memcpy_asm) diff --git a/arch/arm64/lib/tracememcpy.c b/arch/arm64/lib/tracememcpy.c new file mode 100644 index 00000000000..0a951c4d9d9 --- /dev/null +++ b/arch/arm64/lib/tracememcpy.c @@ -0,0 +1,12 @@ + +#define CREATE_TRACE_POINTS +#include <asm/trace/events/string.h> + +extern void *memcpy_asm(void *dest, const void *src, size_t count); + +void *memcpy(void *dest, const void *src, size_t count) +{ + trace_memcpy(dest, src, count, __builtin_return_address(0)); + return memcpy_asm(dest, src, count); +} + |