aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_sched_switch.c
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2008-07-18 12:16:17 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:32:26 -0400
commitb07c3f193a8074aa4afe43cfa8ae38ec4c7ccfa9 (patch)
tree7d2b1d9efc5a8e24cb07c8d7f0b3e056fec8f150 /kernel/trace/trace_sched_switch.c
parent0a16b6075843325dc402edf80c1662838b929aff (diff)
ftrace: port to tracepoints
Porting the trace_mark() used by ftrace to tracepoints. (cleanup) Changelog : - Change error messages : marker -> tracepoint [ mingo@elte.hu: conflict resolutions ] Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Acked-by: 'Peter Zijlstra' <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_sched_switch.c')
-rw-r--r--kernel/trace/trace_sched_switch.c120
1 files changed, 24 insertions, 96 deletions
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index cb817a209aa0..789e927abc9c 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -9,8 +9,8 @@
9#include <linux/debugfs.h> 9#include <linux/debugfs.h>
10#include <linux/kallsyms.h> 10#include <linux/kallsyms.h>
11#include <linux/uaccess.h> 11#include <linux/uaccess.h>
12#include <linux/marker.h>
13#include <linux/ftrace.h> 12#include <linux/ftrace.h>
13#include <trace/sched.h>
14 14
15#include "trace.h" 15#include "trace.h"
16 16
@@ -19,16 +19,17 @@ static int __read_mostly tracer_enabled;
19static atomic_t sched_ref; 19static atomic_t sched_ref;
20 20
21static void 21static void
22sched_switch_func(void *private, void *__rq, struct task_struct *prev, 22probe_sched_switch(struct rq *__rq, struct task_struct *prev,
23 struct task_struct *next) 23 struct task_struct *next)
24{ 24{
25 struct trace_array **ptr = private;
26 struct trace_array *tr = *ptr;
27 struct trace_array_cpu *data; 25 struct trace_array_cpu *data;
28 unsigned long flags; 26 unsigned long flags;
29 long disabled; 27 long disabled;
30 int cpu; 28 int cpu;
31 29
30 if (!atomic_read(&sched_ref))
31 return;
32
32 tracing_record_cmdline(prev); 33 tracing_record_cmdline(prev);
33 tracing_record_cmdline(next); 34 tracing_record_cmdline(next);
34 35
@@ -37,95 +38,42 @@ sched_switch_func(void *private, void *__rq, struct task_struct *prev,
37 38
38 local_irq_save(flags); 39 local_irq_save(flags);
39 cpu = raw_smp_processor_id(); 40 cpu = raw_smp_processor_id();
40 data = tr->data[cpu]; 41 data = ctx_trace->data[cpu];
41 disabled = atomic_inc_return(&data->disabled); 42 disabled = atomic_inc_return(&data->disabled);
42 43
43 if (likely(disabled == 1)) 44 if (likely(disabled == 1))
44 tracing_sched_switch_trace(tr, data, prev, next, flags); 45 tracing_sched_switch_trace(ctx_trace, data, prev, next, flags);
45 46
46 atomic_dec(&data->disabled); 47 atomic_dec(&data->disabled);
47 local_irq_restore(flags); 48 local_irq_restore(flags);
48} 49}
49 50
50static notrace void
51sched_switch_callback(void *probe_data, void *call_data,
52 const char *format, va_list *args)
53{
54 struct task_struct *prev;
55 struct task_struct *next;
56 struct rq *__rq;
57
58 if (!atomic_read(&sched_ref))
59 return;
60
61 /* skip prev_pid %d next_pid %d prev_state %ld */
62 (void)va_arg(*args, int);
63 (void)va_arg(*args, int);
64 (void)va_arg(*args, long);
65 __rq = va_arg(*args, typeof(__rq));
66 prev = va_arg(*args, typeof(prev));
67 next = va_arg(*args, typeof(next));
68
69 /*
70 * If tracer_switch_func only points to the local
71 * switch func, it still needs the ptr passed to it.
72 */
73 sched_switch_func(probe_data, __rq, prev, next);
74}
75
76static void 51static void
77wakeup_func(void *private, void *__rq, struct task_struct *wakee, struct 52probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee)
78 task_struct *curr)
79{ 53{
80 struct trace_array **ptr = private;
81 struct trace_array *tr = *ptr;
82 struct trace_array_cpu *data; 54 struct trace_array_cpu *data;
83 unsigned long flags; 55 unsigned long flags;
84 long disabled; 56 long disabled;
85 int cpu; 57 int cpu;
86 58
87 if (!tracer_enabled) 59 if (!likely(tracer_enabled))
88 return; 60 return;
89 61
90 tracing_record_cmdline(curr); 62 tracing_record_cmdline(current);
91 63
92 local_irq_save(flags); 64 local_irq_save(flags);
93 cpu = raw_smp_processor_id(); 65 cpu = raw_smp_processor_id();
94 data = tr->data[cpu]; 66 data = ctx_trace->data[cpu];
95 disabled = atomic_inc_return(&data->disabled); 67 disabled = atomic_inc_return(&data->disabled);
96 68
97 if (likely(disabled == 1)) 69 if (likely(disabled == 1))
98 tracing_sched_wakeup_trace(tr, data, wakee, curr, flags); 70 tracing_sched_wakeup_trace(ctx_trace, data, wakee, current,
71 flags);
99 72
100 atomic_dec(&data->disabled); 73 atomic_dec(&data->disabled);
101 local_irq_restore(flags); 74 local_irq_restore(flags);
102} 75}
103 76
104static notrace void
105wake_up_callback(void *probe_data, void *call_data,
106 const char *format, va_list *args)
107{
108 struct task_struct *curr;
109 struct task_struct *task;
110 struct rq *__rq;
111
112 if (likely(!tracer_enabled))
113 return;
114
115 /* Skip pid %d state %ld */
116 (void)va_arg(*args, int);
117 (void)va_arg(*args, long);
118 /* now get the meat: "rq %p task %p rq->curr %p" */
119 __rq = va_arg(*args, typeof(__rq));
120 task = va_arg(*args, typeof(task));
121 curr = va_arg(*args, typeof(curr));
122
123 tracing_record_cmdline(task);
124 tracing_record_cmdline(curr);
125
126 wakeup_func(probe_data, __rq, task, curr);
127}
128
129static void sched_switch_reset(struct trace_array *tr) 77static void sched_switch_reset(struct trace_array *tr)
130{ 78{
131 int cpu; 79 int cpu;
@@ -140,60 +88,40 @@ static int tracing_sched_register(void)
140{ 88{
141 int ret; 89 int ret;
142 90
143 ret = marker_probe_register("kernel_sched_wakeup", 91 ret = register_trace_sched_wakeup(probe_sched_wakeup);
144 "pid %d state %ld ## rq %p task %p rq->curr %p",
145 wake_up_callback,
146 &ctx_trace);
147 if (ret) { 92 if (ret) {
148 pr_info("wakeup trace: Couldn't add marker" 93 pr_info("wakeup trace: Couldn't activate tracepoint"
149 " probe to kernel_sched_wakeup\n"); 94 " probe to kernel_sched_wakeup\n");
150 return ret; 95 return ret;
151 } 96 }
152 97
153 ret = marker_probe_register("kernel_sched_wakeup_new", 98 ret = register_trace_sched_wakeup_new(probe_sched_wakeup);
154 "pid %d state %ld ## rq %p task %p rq->curr %p",
155 wake_up_callback,
156 &ctx_trace);
157 if (ret) { 99 if (ret) {
158 pr_info("wakeup trace: Couldn't add marker" 100 pr_info("wakeup trace: Couldn't activate tracepoint"
159 " probe to kernel_sched_wakeup_new\n"); 101 " probe to kernel_sched_wakeup_new\n");
160 goto fail_deprobe; 102 goto fail_deprobe;
161 } 103 }
162 104
163 ret = marker_probe_register("kernel_sched_schedule", 105 ret = register_trace_sched_switch(probe_sched_switch);
164 "prev_pid %d next_pid %d prev_state %ld "
165 "## rq %p prev %p next %p",
166 sched_switch_callback,
167 &ctx_trace);
168 if (ret) { 106 if (ret) {
169 pr_info("sched trace: Couldn't add marker" 107 pr_info("sched trace: Couldn't activate tracepoint"
170 " probe to kernel_sched_schedule\n"); 108 " probe to kernel_sched_schedule\n");
171 goto fail_deprobe_wake_new; 109 goto fail_deprobe_wake_new;
172 } 110 }
173 111
174 return ret; 112 return ret;
175fail_deprobe_wake_new: 113fail_deprobe_wake_new:
176 marker_probe_unregister("kernel_sched_wakeup_new", 114 unregister_trace_sched_wakeup_new(probe_sched_wakeup);
177 wake_up_callback,
178 &ctx_trace);
179fail_deprobe: 115fail_deprobe:
180 marker_probe_unregister("kernel_sched_wakeup", 116 unregister_trace_sched_wakeup(probe_sched_wakeup);
181 wake_up_callback,
182 &ctx_trace);
183 return ret; 117 return ret;
184} 118}
185 119
186static void tracing_sched_unregister(void) 120static void tracing_sched_unregister(void)
187{ 121{
188 marker_probe_unregister("kernel_sched_schedule", 122 unregister_trace_sched_switch(probe_sched_switch);
189 sched_switch_callback, 123 unregister_trace_sched_wakeup_new(probe_sched_wakeup);
190 &ctx_trace); 124 unregister_trace_sched_wakeup(probe_sched_wakeup);
191 marker_probe_unregister("kernel_sched_wakeup_new",
192 wake_up_callback,
193 &ctx_trace);
194 marker_probe_unregister("kernel_sched_wakeup",
195 wake_up_callback,
196 &ctx_trace);
197} 125}
198 126
199static void tracing_start_sched_switch(void) 127static void tracing_start_sched_switch(void)