diff options
| author | Jiri Olsa <jolsa@redhat.com> | 2013-12-03 08:09:28 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-04 13:26:05 -0500 |
| commit | f825628840e581f92f1c2e79dfa943f29c054e67 (patch) | |
| tree | 403612a6c942eb1261f65f6337faf41636143c15 | |
| parent | d9d13f8be6237950753e093683e9f415f31eccbc (diff) | |
tools lib traceevent: Add kmem plugin
Backporting kmem plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds call_site field resolving for following tracepoint
events:
kmem:kfree
kmem:kmalloc
kmem:kmalloc_node
kmem:kmem_cache_alloc
kmem:kmem_cache_alloc_node
kmem:kmem_cache_free
The diff of 'perf script' output generated by old and new code: (data
was generated by 'perf record -e 'kmem:*' -a')
--- script.kmem.old
+++ script.kmem.new
- perf 27846 [001] 29643.403319: kmem:kfree: call_site=ffffffff810e64f6 ptr=(nil)
+ perf 27846 [001] 29643.403238: kmem:kfree: (__audit_syscall_exit+0x1f6) call_site=ffffffff810e64f6 ptr=(nil)
- perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL
+ perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: (radix_tree_preload+0x35) call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL
- perf 27846 [001] 29643.403342: kmem:kmem_cache_free: call_site=ffffffff8126ec61 ptr=0xffff88020dffe750
+ perf 27846 [001] 29643.403342: kmem:kmem_cache_free: (jbd2_journal_stop+0x221) call_site=ffffffff8126ec61 ptr=0xffff88020dffe750
- firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1
+ firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: (__alloc_skb+0x4e) call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1
- perf 27846 [001] 29643.445510: kmem:kmalloc: call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO
+ perf 27846 [001] 29643.445510: kmem:kmalloc: (ext4_ext_find_extent+0x362) call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO
- X 888 [002] 29643.445546: kmem:kmalloc_node: call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1
+ X 888 [002] 29643.445546: kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1386076182-14484-15-git-send-email-jolsa@redhat.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/lib/traceevent/Makefile | 1 | ||||
| -rw-r--r-- | tools/lib/traceevent/plugin_kmem.c | 72 |
2 files changed, 73 insertions, 0 deletions
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 9ff2e2596614..245d6b4f0aed 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile | |||
| @@ -214,6 +214,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o | |||
| 214 | 214 | ||
| 215 | PLUGIN_OBJS = plugin_jbd2.o | 215 | PLUGIN_OBJS = plugin_jbd2.o |
| 216 | PLUGIN_OBJS += plugin_hrtimer.o | 216 | PLUGIN_OBJS += plugin_hrtimer.o |
| 217 | PLUGIN_OBJS += plugin_kmem.o | ||
| 217 | 218 | ||
| 218 | PLUGINS := $(PLUGIN_OBJS:.o=.so) | 219 | PLUGINS := $(PLUGIN_OBJS:.o=.so) |
| 219 | 220 | ||
diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c new file mode 100644 index 000000000000..7115c8037ea8 --- /dev/null +++ b/tools/lib/traceevent/plugin_kmem.c | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> | ||
| 3 | * | ||
| 4 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; | ||
| 8 | * version 2.1 of the License (not later!) | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this program; if not, see <http://www.gnu.org/licenses> | ||
| 17 | * | ||
| 18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 19 | */ | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <stdlib.h> | ||
| 22 | #include <string.h> | ||
| 23 | |||
| 24 | #include "event-parse.h" | ||
| 25 | |||
| 26 | static int call_site_handler(struct trace_seq *s, struct pevent_record *record, | ||
| 27 | struct event_format *event, void *context) | ||
| 28 | { | ||
| 29 | struct format_field *field; | ||
| 30 | unsigned long long val, addr; | ||
| 31 | void *data = record->data; | ||
| 32 | const char *func; | ||
| 33 | |||
| 34 | field = pevent_find_field(event, "call_site"); | ||
| 35 | if (!field) | ||
| 36 | return 1; | ||
| 37 | |||
| 38 | if (pevent_read_number_field(field, data, &val)) | ||
| 39 | return 1; | ||
| 40 | |||
| 41 | func = pevent_find_function(event->pevent, val); | ||
| 42 | if (!func) | ||
| 43 | return 1; | ||
| 44 | |||
| 45 | addr = pevent_find_function_address(event->pevent, val); | ||
| 46 | |||
| 47 | trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr)); | ||
| 48 | return 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | int PEVENT_PLUGIN_LOADER(struct pevent *pevent) | ||
| 52 | { | ||
| 53 | pevent_register_event_handler(pevent, -1, "kmem", "kfree", | ||
| 54 | call_site_handler, NULL); | ||
| 55 | |||
| 56 | pevent_register_event_handler(pevent, -1, "kmem", "kmalloc", | ||
| 57 | call_site_handler, NULL); | ||
| 58 | |||
| 59 | pevent_register_event_handler(pevent, -1, "kmem", "kmalloc_node", | ||
| 60 | call_site_handler, NULL); | ||
| 61 | |||
| 62 | pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc", | ||
| 63 | call_site_handler, NULL); | ||
| 64 | |||
| 65 | pevent_register_event_handler(pevent, -1, "kmem", | ||
| 66 | "kmem_cache_alloc_node", | ||
| 67 | call_site_handler, NULL); | ||
| 68 | |||
| 69 | pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_free", | ||
| 70 | call_site_handler, NULL); | ||
| 71 | return 0; | ||
| 72 | } | ||
