diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-11-15 23:57:26 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-16 01:55:23 -0500 |
commit | 1c80025a49855b12fa09bb6db71820e3367b1369 (patch) | |
tree | 063fe72ed9bb3410c3293c83a7882cecc46e7410 /kernel/trace/trace_selftest.c | |
parent | e6e7a65aabdb696cf05a56cfd495c49a11fd4cde (diff) |
tracing/ftrace: change the type of the init() callback
Impact: extend the ->init() method with the ability to fail
This bring a way to know if the initialization of a tracer successed.
A tracer must return 0 on success and a traditional error (ie:
-ENOMEM) if it fails.
If a tracer fails to init, it is free to print a detailed warn. The
tracing api will not and switch to a new tracer will just return the
error from the init callback.
Note: this will be used for the return tracer.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r-- | kernel/trace/trace_selftest.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 5cb64ea061b5..88c8eb70f54a 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -71,6 +71,11 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) | |||
71 | return ret; | 71 | return ret; |
72 | } | 72 | } |
73 | 73 | ||
74 | static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret) | ||
75 | { | ||
76 | printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n", | ||
77 | trace->name, init_ret); | ||
78 | } | ||
74 | #ifdef CONFIG_FUNCTION_TRACER | 79 | #ifdef CONFIG_FUNCTION_TRACER |
75 | 80 | ||
76 | #ifdef CONFIG_DYNAMIC_FTRACE | 81 | #ifdef CONFIG_DYNAMIC_FTRACE |
@@ -111,7 +116,11 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace, | |||
111 | ftrace_set_filter(func_name, strlen(func_name), 1); | 116 | ftrace_set_filter(func_name, strlen(func_name), 1); |
112 | 117 | ||
113 | /* enable tracing */ | 118 | /* enable tracing */ |
114 | trace->init(tr); | 119 | ret = trace->init(tr); |
120 | if (ret) { | ||
121 | warn_failed_init_tracer(trace, ret); | ||
122 | goto out; | ||
123 | } | ||
115 | 124 | ||
116 | /* Sleep for a 1/10 of a second */ | 125 | /* Sleep for a 1/10 of a second */ |
117 | msleep(100); | 126 | msleep(100); |
@@ -181,7 +190,12 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr) | |||
181 | ftrace_enabled = 1; | 190 | ftrace_enabled = 1; |
182 | tracer_enabled = 1; | 191 | tracer_enabled = 1; |
183 | 192 | ||
184 | trace->init(tr); | 193 | ret = trace->init(tr); |
194 | if (ret) { | ||
195 | warn_failed_init_tracer(trace, ret); | ||
196 | goto out; | ||
197 | } | ||
198 | |||
185 | /* Sleep for a 1/10 of a second */ | 199 | /* Sleep for a 1/10 of a second */ |
186 | msleep(100); | 200 | msleep(100); |
187 | /* stop the tracing. */ | 201 | /* stop the tracing. */ |
@@ -223,7 +237,12 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr) | |||
223 | int ret; | 237 | int ret; |
224 | 238 | ||
225 | /* start the tracing */ | 239 | /* start the tracing */ |
226 | trace->init(tr); | 240 | ret = trace->init(tr); |
241 | if (ret) { | ||
242 | warn_failed_init_tracer(trace, ret); | ||
243 | return ret; | ||
244 | } | ||
245 | |||
227 | /* reset the max latency */ | 246 | /* reset the max latency */ |
228 | tracing_max_latency = 0; | 247 | tracing_max_latency = 0; |
229 | /* disable interrupts for a bit */ | 248 | /* disable interrupts for a bit */ |
@@ -272,7 +291,12 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr) | |||
272 | } | 291 | } |
273 | 292 | ||
274 | /* start the tracing */ | 293 | /* start the tracing */ |
275 | trace->init(tr); | 294 | ret = trace->init(tr); |
295 | if (ret) { | ||
296 | warn_failed_init_tracer(trace, ret); | ||
297 | return ret; | ||
298 | } | ||
299 | |||
276 | /* reset the max latency */ | 300 | /* reset the max latency */ |
277 | tracing_max_latency = 0; | 301 | tracing_max_latency = 0; |
278 | /* disable preemption for a bit */ | 302 | /* disable preemption for a bit */ |
@@ -321,7 +345,11 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array * | |||
321 | } | 345 | } |
322 | 346 | ||
323 | /* start the tracing */ | 347 | /* start the tracing */ |
324 | trace->init(tr); | 348 | ret = trace->init(tr); |
349 | if (ret) { | ||
350 | warn_failed_init_tracer(trace, ret); | ||
351 | goto out; | ||
352 | } | ||
325 | 353 | ||
326 | /* reset the max latency */ | 354 | /* reset the max latency */ |
327 | tracing_max_latency = 0; | 355 | tracing_max_latency = 0; |
@@ -449,7 +477,12 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr) | |||
449 | wait_for_completion(&isrt); | 477 | wait_for_completion(&isrt); |
450 | 478 | ||
451 | /* start the tracing */ | 479 | /* start the tracing */ |
452 | trace->init(tr); | 480 | ret = trace->init(tr); |
481 | if (ret) { | ||
482 | warn_failed_init_tracer(trace, ret); | ||
483 | return ret; | ||
484 | } | ||
485 | |||
453 | /* reset the max latency */ | 486 | /* reset the max latency */ |
454 | tracing_max_latency = 0; | 487 | tracing_max_latency = 0; |
455 | 488 | ||
@@ -505,7 +538,12 @@ trace_selftest_startup_sched_switch(struct tracer *trace, struct trace_array *tr | |||
505 | int ret; | 538 | int ret; |
506 | 539 | ||
507 | /* start the tracing */ | 540 | /* start the tracing */ |
508 | trace->init(tr); | 541 | ret = trace->init(tr); |
542 | if (ret) { | ||
543 | warn_failed_init_tracer(trace, ret); | ||
544 | return ret; | ||
545 | } | ||
546 | |||
509 | /* Sleep for a 1/10 of a second */ | 547 | /* Sleep for a 1/10 of a second */ |
510 | msleep(100); | 548 | msleep(100); |
511 | /* stop the tracing. */ | 549 | /* stop the tracing. */ |
@@ -532,7 +570,12 @@ trace_selftest_startup_sysprof(struct tracer *trace, struct trace_array *tr) | |||
532 | int ret; | 570 | int ret; |
533 | 571 | ||
534 | /* start the tracing */ | 572 | /* start the tracing */ |
535 | trace->init(tr); | 573 | ret = trace->init(tr); |
574 | if (ret) { | ||
575 | warn_failed_init_tracer(trace, ret); | ||
576 | return 0; | ||
577 | } | ||
578 | |||
536 | /* Sleep for a 1/10 of a second */ | 579 | /* Sleep for a 1/10 of a second */ |
537 | msleep(100); | 580 | msleep(100); |
538 | /* stop the tracing. */ | 581 | /* stop the tracing. */ |
@@ -554,7 +597,12 @@ trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr) | |||
554 | int ret; | 597 | int ret; |
555 | 598 | ||
556 | /* start the tracing */ | 599 | /* start the tracing */ |
557 | trace->init(tr); | 600 | ret = trace->init(tr); |
601 | if (ret) { | ||
602 | warn_failed_init_tracer(trace, ret); | ||
603 | return ret; | ||
604 | } | ||
605 | |||
558 | /* Sleep for a 1/10 of a second */ | 606 | /* Sleep for a 1/10 of a second */ |
559 | msleep(100); | 607 | msleep(100); |
560 | /* stop the tracing. */ | 608 | /* stop the tracing. */ |