diff options
author | Pekka J Enberg <penberg@cs.helsinki.fi> | 2008-12-19 05:08:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-19 10:29:34 -0500 |
commit | 213cc060797378059a28ebc5c539f3e9a80160bd (patch) | |
tree | e159f9fae35ca59fe2c02e905c2b4b91881d865c | |
parent | 30cd324e9787ccc9a5ede59742d5409857550692 (diff) |
ftrace: introduce tracing_reset_online_cpus() helper
Impact: cleanup
This patch factors out common code from multiple tracers into a
tracing_reset_online_cpus() function and converts the tracers to use it.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/trace/trace.c | 10 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 | ||||
-rw-r--r-- | kernel/trace/trace_boot.c | 12 | ||||
-rw-r--r-- | kernel/trace/trace_functions.c | 14 | ||||
-rw-r--r-- | kernel/trace/trace_hw_branches.c | 14 | ||||
-rw-r--r-- | kernel/trace/trace_mmiotrace.c | 6 | ||||
-rw-r--r-- | kernel/trace/trace_sched_switch.c | 14 | ||||
-rw-r--r-- | kernel/trace/trace_sysprof.c | 12 |
8 files changed, 20 insertions, 63 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0eb6d48347f7..79db26e8216e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -679,6 +679,16 @@ void tracing_reset(struct trace_array *tr, int cpu) | |||
679 | ftrace_enable_cpu(); | 679 | ftrace_enable_cpu(); |
680 | } | 680 | } |
681 | 681 | ||
682 | void tracing_reset_online_cpus(struct trace_array *tr) | ||
683 | { | ||
684 | int cpu; | ||
685 | |||
686 | tr->time_start = ftrace_now(tr->cpu); | ||
687 | |||
688 | for_each_online_cpu(cpu) | ||
689 | tracing_reset(tr, cpu); | ||
690 | } | ||
691 | |||
682 | #define SAVED_CMDLINES 128 | 692 | #define SAVED_CMDLINES 128 |
683 | static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1]; | 693 | static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1]; |
684 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; | 694 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index fc75dce7a664..cc7a4f864036 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -374,6 +374,7 @@ struct trace_iterator { | |||
374 | int tracing_is_enabled(void); | 374 | int tracing_is_enabled(void); |
375 | void trace_wake_up(void); | 375 | void trace_wake_up(void); |
376 | void tracing_reset(struct trace_array *tr, int cpu); | 376 | void tracing_reset(struct trace_array *tr, int cpu); |
377 | void tracing_reset_online_cpus(struct trace_array *tr); | ||
377 | int tracing_open_generic(struct inode *inode, struct file *filp); | 378 | int tracing_open_generic(struct inode *inode, struct file *filp); |
378 | struct dentry *tracing_init_dentry(void); | 379 | struct dentry *tracing_init_dentry(void); |
379 | void init_tracer_sysprof_debugfs(struct dentry *d_tracer); | 380 | void init_tracer_sysprof_debugfs(struct dentry *d_tracer); |
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c index a4fa2c57e34e..3ccebde28482 100644 --- a/kernel/trace/trace_boot.c +++ b/kernel/trace/trace_boot.c | |||
@@ -37,16 +37,6 @@ void disable_boot_trace(void) | |||
37 | tracing_stop_sched_switch_record(); | 37 | tracing_stop_sched_switch_record(); |
38 | } | 38 | } |
39 | 39 | ||
40 | static void reset_boot_trace(struct trace_array *tr) | ||
41 | { | ||
42 | int cpu; | ||
43 | |||
44 | tr->time_start = ftrace_now(tr->cpu); | ||
45 | |||
46 | for_each_online_cpu(cpu) | ||
47 | tracing_reset(tr, cpu); | ||
48 | } | ||
49 | |||
50 | static int boot_trace_init(struct trace_array *tr) | 40 | static int boot_trace_init(struct trace_array *tr) |
51 | { | 41 | { |
52 | int cpu; | 42 | int cpu; |
@@ -130,7 +120,7 @@ struct tracer boot_tracer __read_mostly = | |||
130 | { | 120 | { |
131 | .name = "initcall", | 121 | .name = "initcall", |
132 | .init = boot_trace_init, | 122 | .init = boot_trace_init, |
133 | .reset = reset_boot_trace, | 123 | .reset = tracing_reset_online_cpus, |
134 | .print_line = initcall_print_line, | 124 | .print_line = initcall_print_line, |
135 | }; | 125 | }; |
136 | 126 | ||
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index e74f6d0a3216..9236d7e25a16 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c | |||
@@ -16,20 +16,10 @@ | |||
16 | 16 | ||
17 | #include "trace.h" | 17 | #include "trace.h" |
18 | 18 | ||
19 | static void function_reset(struct trace_array *tr) | ||
20 | { | ||
21 | int cpu; | ||
22 | |||
23 | tr->time_start = ftrace_now(tr->cpu); | ||
24 | |||
25 | for_each_online_cpu(cpu) | ||
26 | tracing_reset(tr, cpu); | ||
27 | } | ||
28 | |||
29 | static void start_function_trace(struct trace_array *tr) | 19 | static void start_function_trace(struct trace_array *tr) |
30 | { | 20 | { |
31 | tr->cpu = get_cpu(); | 21 | tr->cpu = get_cpu(); |
32 | function_reset(tr); | 22 | tracing_reset_online_cpus(tr); |
33 | put_cpu(); | 23 | put_cpu(); |
34 | 24 | ||
35 | tracing_start_cmdline_record(); | 25 | tracing_start_cmdline_record(); |
@@ -55,7 +45,7 @@ static void function_trace_reset(struct trace_array *tr) | |||
55 | 45 | ||
56 | static void function_trace_start(struct trace_array *tr) | 46 | static void function_trace_start(struct trace_array *tr) |
57 | { | 47 | { |
58 | function_reset(tr); | 48 | tracing_reset_online_cpus(tr); |
59 | } | 49 | } |
60 | 50 | ||
61 | static struct tracer function_trace __read_mostly = | 51 | static struct tracer function_trace __read_mostly = |
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c index ee29e012aa97..b6a3e20a49a9 100644 --- a/kernel/trace/trace_hw_branches.c +++ b/kernel/trace/trace_hw_branches.c | |||
@@ -25,16 +25,6 @@ static DEFINE_PER_CPU(unsigned char[SIZEOF_BTS], buffer); | |||
25 | #define this_buffer per_cpu(buffer, smp_processor_id()) | 25 | #define this_buffer per_cpu(buffer, smp_processor_id()) |
26 | 26 | ||
27 | 27 | ||
28 | static void bts_trace_reset(struct trace_array *tr) | ||
29 | { | ||
30 | int cpu; | ||
31 | |||
32 | tr->time_start = ftrace_now(tr->cpu); | ||
33 | |||
34 | for_each_online_cpu(cpu) | ||
35 | tracing_reset(tr, cpu); | ||
36 | } | ||
37 | |||
38 | static void bts_trace_start_cpu(void *arg) | 28 | static void bts_trace_start_cpu(void *arg) |
39 | { | 29 | { |
40 | if (this_tracer) | 30 | if (this_tracer) |
@@ -54,7 +44,7 @@ static void bts_trace_start(struct trace_array *tr) | |||
54 | { | 44 | { |
55 | int cpu; | 45 | int cpu; |
56 | 46 | ||
57 | bts_trace_reset(tr); | 47 | tracing_reset_online_cpus(tr); |
58 | 48 | ||
59 | for_each_cpu_mask(cpu, cpu_possible_map) | 49 | for_each_cpu_mask(cpu, cpu_possible_map) |
60 | smp_call_function_single(cpu, bts_trace_start_cpu, NULL, 1); | 50 | smp_call_function_single(cpu, bts_trace_start_cpu, NULL, 1); |
@@ -78,7 +68,7 @@ static void bts_trace_stop(struct trace_array *tr) | |||
78 | 68 | ||
79 | static int bts_trace_init(struct trace_array *tr) | 69 | static int bts_trace_init(struct trace_array *tr) |
80 | { | 70 | { |
81 | bts_trace_reset(tr); | 71 | tracing_reset_online_cpus(tr); |
82 | bts_trace_start(tr); | 72 | bts_trace_start(tr); |
83 | 73 | ||
84 | return 0; | 74 | return 0; |
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index 2fb6da6523b3..fffcb069f1dc 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c | |||
@@ -22,14 +22,10 @@ static unsigned long prev_overruns; | |||
22 | 22 | ||
23 | static void mmio_reset_data(struct trace_array *tr) | 23 | static void mmio_reset_data(struct trace_array *tr) |
24 | { | 24 | { |
25 | int cpu; | ||
26 | |||
27 | overrun_detected = false; | 25 | overrun_detected = false; |
28 | prev_overruns = 0; | 26 | prev_overruns = 0; |
29 | tr->time_start = ftrace_now(tr->cpu); | ||
30 | 27 | ||
31 | for_each_online_cpu(cpu) | 28 | tracing_reset_online_cpus(tr); |
32 | tracing_reset(tr, cpu); | ||
33 | } | 29 | } |
34 | 30 | ||
35 | static int mmio_trace_init(struct trace_array *tr) | 31 | static int mmio_trace_init(struct trace_array *tr) |
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c index 781d72ef873c..add2c1fdae92 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c | |||
@@ -72,16 +72,6 @@ probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee) | |||
72 | local_irq_restore(flags); | 72 | local_irq_restore(flags); |
73 | } | 73 | } |
74 | 74 | ||
75 | static void sched_switch_reset(struct trace_array *tr) | ||
76 | { | ||
77 | int cpu; | ||
78 | |||
79 | tr->time_start = ftrace_now(tr->cpu); | ||
80 | |||
81 | for_each_online_cpu(cpu) | ||
82 | tracing_reset(tr, cpu); | ||
83 | } | ||
84 | |||
85 | static int tracing_sched_register(void) | 75 | static int tracing_sched_register(void) |
86 | { | 76 | { |
87 | int ret; | 77 | int ret; |
@@ -197,7 +187,7 @@ void tracing_sched_switch_assign_trace(struct trace_array *tr) | |||
197 | 187 | ||
198 | static void start_sched_trace(struct trace_array *tr) | 188 | static void start_sched_trace(struct trace_array *tr) |
199 | { | 189 | { |
200 | sched_switch_reset(tr); | 190 | tracing_reset_online_cpus(tr); |
201 | tracing_start_sched_switch_record(); | 191 | tracing_start_sched_switch_record(); |
202 | } | 192 | } |
203 | 193 | ||
@@ -221,7 +211,7 @@ static void sched_switch_trace_reset(struct trace_array *tr) | |||
221 | 211 | ||
222 | static void sched_switch_trace_start(struct trace_array *tr) | 212 | static void sched_switch_trace_start(struct trace_array *tr) |
223 | { | 213 | { |
224 | sched_switch_reset(tr); | 214 | tracing_reset_online_cpus(tr); |
225 | tracing_start_sched_switch(); | 215 | tracing_start_sched_switch(); |
226 | } | 216 | } |
227 | 217 | ||
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c index 54960edb96d0..01becf1f19ff 100644 --- a/kernel/trace/trace_sysprof.c +++ b/kernel/trace/trace_sysprof.c | |||
@@ -234,20 +234,10 @@ static void stop_stack_timers(void) | |||
234 | stop_stack_timer(cpu); | 234 | stop_stack_timer(cpu); |
235 | } | 235 | } |
236 | 236 | ||
237 | static void stack_reset(struct trace_array *tr) | ||
238 | { | ||
239 | int cpu; | ||
240 | |||
241 | tr->time_start = ftrace_now(tr->cpu); | ||
242 | |||
243 | for_each_online_cpu(cpu) | ||
244 | tracing_reset(tr, cpu); | ||
245 | } | ||
246 | |||
247 | static void start_stack_trace(struct trace_array *tr) | 237 | static void start_stack_trace(struct trace_array *tr) |
248 | { | 238 | { |
249 | mutex_lock(&sample_timer_lock); | 239 | mutex_lock(&sample_timer_lock); |
250 | stack_reset(tr); | 240 | tracing_reset_online_cpus(tr); |
251 | start_stack_timers(); | 241 | start_stack_timers(); |
252 | tracer_enabled = 1; | 242 | tracer_enabled = 1; |
253 | mutex_unlock(&sample_timer_lock); | 243 | mutex_unlock(&sample_timer_lock); |