diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-12-29 16:42:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-30 03:36:13 -0500 |
commit | 36994e58a48fb8f9651c7dc845a6de298aba5bfc (patch) | |
tree | fac4b8a1c30560e91460651487f3a57ef7f2b5cc /kernel/trace/trace.h | |
parent | 7a51cffbd10886c0557677dd916c090097c691ef (diff) |
tracing/kmemtrace: normalize the raw tracer event to the unified tracing API
Impact: new tracer plugin
This patch adapts kmemtrace raw events tracing to the unified tracing API.
To enable and use this tracer, just do the following:
echo kmemtrace > /debugfs/tracing/current_tracer
cat /debugfs/tracing/trace
You will have the following output:
# tracer: kmemtrace
#
#
# ALLOC TYPE REQ GIVEN FLAGS POINTER NODE CALLER
# FREE | | | | | | | |
# |
type_id 1 call_site 18446744071565527833 ptr 18446612134395152256
type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
type_id 0 call_site 18446744071565636711 ptr 18446612134345164672 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
type_id 0 call_site 18446744071565636711 ptr 18446612134345164912 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
type_id 0 call_site 18446744071565636711 ptr 18446612134345165152 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
type_id 0 call_site 18446744071566144042 ptr 18446612134346191680 bytes_req 1304 bytes_alloc 1312 gfp_flags 208 node -1
type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
That was to stay backward compatible with the format output produced in
inux/tracepoint.h.
This is the default ouput, but note that I tried something else.
If you change an option:
echo kmem_minimalistic > /debugfs/trace_options
and then cat /debugfs/trace, you will have the following output:
# tracer: kmemtrace
#
#
# ALLOC TYPE REQ GIVEN FLAGS POINTER NODE CALLER
# FREE | | | | | | | |
# |
- C 0xffff88007c088780 file_free_rcu
+ K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
- C 0xffff88007cad6000 putname
+ K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
+ K 240 240 000000d0 0xffff8800790dc780 -1 d_alloc
- C 0xffff88007cad6000 putname
+ K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
+ K 240 240 000000d0 0xffff8800790dc870 -1 d_alloc
- C 0xffff88007cad6000 putname
+ K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
+ K 240 240 000000d0 0xffff8800790dc960 -1 d_alloc
+ K 1304 1312 000000d0 0xffff8800791d7340 -1 reiserfs_alloc_inode
- C 0xffff88007cad6000 putname
+ K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
- C 0xffff88007cad6000 putname
+ K 992 1000 000000d0 0xffff880079045b58 -1 alloc_inode
+ K 768 1024 000080d0 0xffff88007c096400 -1 alloc_pipe_info
+ K 240 240 000000d0 0xffff8800790dca50 -1 d_alloc
+ K 272 320 000080d0 0xffff88007c088780 -1 get_empty_filp
+ K 272 320 000080d0 0xffff88007c088000 -1 get_empty_filp
Yeah I shall confess kmem_minimalistic should be: kmem_alternative.
Whatever, I find it more readable but this a personal opinion of course.
We can drop it if you want.
On the ALLOC/FREE column, + means an allocation and - a free.
On the type column, you have K = kmalloc, C = cache, P = page
I would like the flags to be GFP_* strings but that would not be easy to not
break the column with strings....
About the node...it seems to always be -1. I don't know why but that shouldn't
be difficult to find.
I moved linux/tracepoint.h to trace/tracepoint.h as well. I think that would
be more easy to find the tracer headers if they are all in their common
directory.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index cc7a4f864036..534505bb39b0 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/mmiotrace.h> | 9 | #include <linux/mmiotrace.h> |
10 | #include <linux/ftrace.h> | 10 | #include <linux/ftrace.h> |
11 | #include <trace/boot.h> | 11 | #include <trace/boot.h> |
12 | #include <trace/kmemtrace.h> | ||
12 | 13 | ||
13 | enum trace_type { | 14 | enum trace_type { |
14 | __TRACE_FIRST_TYPE = 0, | 15 | __TRACE_FIRST_TYPE = 0, |
@@ -29,6 +30,8 @@ enum trace_type { | |||
29 | TRACE_GRAPH_ENT, | 30 | TRACE_GRAPH_ENT, |
30 | TRACE_USER_STACK, | 31 | TRACE_USER_STACK, |
31 | TRACE_HW_BRANCHES, | 32 | TRACE_HW_BRANCHES, |
33 | TRACE_KMEM_ALLOC, | ||
34 | TRACE_KMEM_FREE, | ||
32 | TRACE_POWER, | 35 | TRACE_POWER, |
33 | 36 | ||
34 | __TRACE_LAST_TYPE | 37 | __TRACE_LAST_TYPE |
@@ -170,6 +173,24 @@ struct trace_power { | |||
170 | struct power_trace state_data; | 173 | struct power_trace state_data; |
171 | }; | 174 | }; |
172 | 175 | ||
176 | struct kmemtrace_alloc_entry { | ||
177 | struct trace_entry ent; | ||
178 | enum kmemtrace_type_id type_id; | ||
179 | unsigned long call_site; | ||
180 | const void *ptr; | ||
181 | size_t bytes_req; | ||
182 | size_t bytes_alloc; | ||
183 | gfp_t gfp_flags; | ||
184 | int node; | ||
185 | }; | ||
186 | |||
187 | struct kmemtrace_free_entry { | ||
188 | struct trace_entry ent; | ||
189 | enum kmemtrace_type_id type_id; | ||
190 | unsigned long call_site; | ||
191 | const void *ptr; | ||
192 | }; | ||
193 | |||
173 | /* | 194 | /* |
174 | * trace_flag_type is an enumeration that holds different | 195 | * trace_flag_type is an enumeration that holds different |
175 | * states when a trace occurs. These are: | 196 | * states when a trace occurs. These are: |
@@ -280,6 +301,10 @@ extern void __ftrace_bad_type(void); | |||
280 | TRACE_GRAPH_RET); \ | 301 | TRACE_GRAPH_RET); \ |
281 | IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ | 302 | IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ |
282 | IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \ | 303 | IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \ |
304 | IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \ | ||
305 | TRACE_KMEM_ALLOC); \ | ||
306 | IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ | ||
307 | TRACE_KMEM_FREE); \ | ||
283 | __ftrace_bad_type(); \ | 308 | __ftrace_bad_type(); \ |
284 | } while (0) | 309 | } while (0) |
285 | 310 | ||