aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-03-02 10:53:15 -0500
committerSteven Rostedt <srostedt@redhat.com>2009-03-02 10:53:15 -0500
commitd20e3b03842bfeb9d21817ff19054c277cc3eac0 (patch)
tree5de7ef8a95f9391a264df358336842c9301f3868
parentf2034f1e1adaac6713a6d48b5a2d4f3aa3e63ccb (diff)
tracing: add TRACE_FIELD_SPECIAL to record complex entries
Tom Zanussi pointed out that the simple TRACE_FIELD was not enough to record trace data that required memcpy. This patch addresses this issue by adding a TRACE_FIELD_SPECIAL. The format is similar to TRACE_FIELD but looks like so: TRACE_FIELD_SPECIAL(type_item, item, cmd) What TRACE_FIELD gave was: TRACE_FIELD(type, item, assign) The TRACE_FIELD would be used in declaring a structure: struct { type item; }; And later assign it via: entry->item = assign; What TRACE_FIELD_SPECIAL gives us is: In the declaration of the structure: struct { type_item; }; And the assignment: cmd; This change log will explain the one example used in the patch: TRACE_EVENT_FORMAT(sched_switch, TPPROTO(struct rq *rq, struct task_struct *prev, struct task_struct *next), TPARGS(rq, prev, next), TPFMT("task %s:%d ==> %s:%d", prev->comm, prev->pid, next->comm, next->pid), TRACE_STRUCT( TRACE_FIELD(pid_t, prev_pid, prev->pid) TRACE_FIELD(int, prev_prio, prev->prio) TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN], next_comm, TPCMD(memcpy(TRACE_ENTRY->next_comm, next->comm, TASK_COMM_LEN))) TRACE_FIELD(pid_t, next_pid, next->pid) TRACE_FIELD(int, next_prio, next->prio) ), TPRAWFMT("prev %d:%d ==> next %s:%d:%d") ); The struct will be create as: struct { pid_t prev_pid; int prev_prio; char next_comm[TASK_COMM_LEN]; pid_t next_pid; int next_prio; }; Note the TRACE_ENTRY in the cmd part of TRACE_SPECIAL. TRACE_ENTRY will be set by the tracer to point to the structure inside the trace buffer. entry->prev_pid = prev->pid; entry->prev_prio = prev->prio; memcpy(entry->next_comm, next->comm, TASK_COMM_LEN); entry->next_pid = next->pid; entry->next_prio = next->prio Reported-by: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
-rw-r--r--include/trace/sched_event_types.h7
-rw-r--r--kernel/trace/trace_events_stage_1.h2
-rw-r--r--kernel/trace/trace_events_stage_2.h4
-rw-r--r--kernel/trace/trace_events_stage_3.h14
4 files changed, 26 insertions, 1 deletions
diff --git a/include/trace/sched_event_types.h b/include/trace/sched_event_types.h
index ba059c10b58a..a6de5c1601a0 100644
--- a/include/trace/sched_event_types.h
+++ b/include/trace/sched_event_types.h
@@ -71,10 +71,15 @@ TRACE_EVENT_FORMAT(sched_switch,
71 TRACE_STRUCT( 71 TRACE_STRUCT(
72 TRACE_FIELD(pid_t, prev_pid, prev->pid) 72 TRACE_FIELD(pid_t, prev_pid, prev->pid)
73 TRACE_FIELD(int, prev_prio, prev->prio) 73 TRACE_FIELD(int, prev_prio, prev->prio)
74 TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
75 next_comm,
76 TPCMD(memcpy(TRACE_ENTRY->next_comm,
77 next->comm,
78 TASK_COMM_LEN)))
74 TRACE_FIELD(pid_t, next_pid, next->pid) 79 TRACE_FIELD(pid_t, next_pid, next->pid)
75 TRACE_FIELD(int, next_prio, next->prio) 80 TRACE_FIELD(int, next_prio, next->prio)
76 ), 81 ),
77 TPRAWFMT("prev %d:%d ==> next %d:%d") 82 TPRAWFMT("prev %d:%d ==> next %s:%d:%d")
78 ); 83 );
79 84
80TRACE_EVENT_FORMAT(sched_migrate_task, 85TRACE_EVENT_FORMAT(sched_migrate_task,
diff --git a/kernel/trace/trace_events_stage_1.h b/kernel/trace/trace_events_stage_1.h
index fd3bf9382d37..3830a731424c 100644
--- a/kernel/trace/trace_events_stage_1.h
+++ b/kernel/trace/trace_events_stage_1.h
@@ -30,5 +30,7 @@
30 30
31#define TRACE_FIELD(type, item, assign) \ 31#define TRACE_FIELD(type, item, assign) \
32 type item; 32 type item;
33#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
34 type_item;
33 35
34#include <trace/trace_event_types.h> 36#include <trace/trace_event_types.h>
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index 3eaaef5f19e1..dc79fe3a2ecb 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -39,6 +39,10 @@
39#define TRACE_FIELD(type, item, assign) \ 39#define TRACE_FIELD(type, item, assign) \
40 field->item, 40 field->item,
41 41
42#undef TRACE_FIELD_SPECIAL
43#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
44 field->item,
45
42 46
43#undef TPRAWFMT 47#undef TPRAWFMT
44#define TPRAWFMT(args...) args 48#define TPRAWFMT(args...) args
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index 7a161c49deb4..2ab65e958223 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -147,6 +147,20 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
147#define TRACE_FIELD(type, item, assign)\ 147#define TRACE_FIELD(type, item, assign)\
148 entry->item = assign; 148 entry->item = assign;
149 149
150#undef TRACE_FIELD
151#define TRACE_FIELD(type, item, assign)\
152 entry->item = assign;
153
154#undef TPCMD
155#define TPCMD(cmd...) cmd
156
157#undef TRACE_ENTRY
158#define TRACE_ENTRY entry
159
160#undef TRACE_FIELD_SPECIAL
161#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
162 cmd;
163
150#undef TRACE_EVENT_FORMAT 164#undef TRACE_EVENT_FORMAT
151#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 165#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
152_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \ 166_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \