diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-08-06 12:08:44 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-08-13 21:05:57 -0400 |
commit | 12473965c38a527a0c6f7a38d23edce60957f873 (patch) | |
tree | 390d32b5ae485dda15302f370812bf668f5cdd87 | |
parent | 36009d07b79d2a168d6037947357d96e5d8cebe7 (diff) |
tracing/perf: Reimplement TP_perf_assign() logic
The next patch tries to avoid the costly perf_trace_buf_* calls
when possible but there is a problem. We can only do this if
__task == NULL, perf_tp_event(task != NULL) has the additional
code for this case.
Unfortunately, TP_perf_assign/__perf_xxx which changes the default
values of __count/__task variables for perf_trace_buf_submit() is
called "too late", after we already did perf_trace_buf_prepare(),
and the optimization above can't work.
So this patch simply embeds __perf_xxx() into TP_ARGS(), this way
DECLARE_EVENT_CLASS() can use the result of assignments hidden in
"args" right after ftrace_get_offsets_##call() which is mostly
trivial. This allows us to have the fast-path "__task != NULL"
check at the start, see the next patch.
Link: http://lkml.kernel.org/r/20130806160844.GA2739@redhat.com
Tested-by: David Ahern <dsahern@gmail.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | include/trace/events/sched.h | 16 | ||||
-rw-r--r-- | include/trace/ftrace.h | 19 |
2 files changed, 14 insertions, 21 deletions
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 249c024e67ae..2e7d9947a10d 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h | |||
@@ -57,7 +57,7 @@ DECLARE_EVENT_CLASS(sched_wakeup_template, | |||
57 | 57 | ||
58 | TP_PROTO(struct task_struct *p, int success), | 58 | TP_PROTO(struct task_struct *p, int success), |
59 | 59 | ||
60 | TP_ARGS(p, success), | 60 | TP_ARGS(__perf_task(p), success), |
61 | 61 | ||
62 | TP_STRUCT__entry( | 62 | TP_STRUCT__entry( |
63 | __array( char, comm, TASK_COMM_LEN ) | 63 | __array( char, comm, TASK_COMM_LEN ) |
@@ -73,9 +73,6 @@ DECLARE_EVENT_CLASS(sched_wakeup_template, | |||
73 | __entry->prio = p->prio; | 73 | __entry->prio = p->prio; |
74 | __entry->success = success; | 74 | __entry->success = success; |
75 | __entry->target_cpu = task_cpu(p); | 75 | __entry->target_cpu = task_cpu(p); |
76 | ) | ||
77 | TP_perf_assign( | ||
78 | __perf_task(p); | ||
79 | ), | 76 | ), |
80 | 77 | ||
81 | TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", | 78 | TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", |
@@ -313,7 +310,7 @@ DECLARE_EVENT_CLASS(sched_stat_template, | |||
313 | 310 | ||
314 | TP_PROTO(struct task_struct *tsk, u64 delay), | 311 | TP_PROTO(struct task_struct *tsk, u64 delay), |
315 | 312 | ||
316 | TP_ARGS(tsk, delay), | 313 | TP_ARGS(__perf_task(tsk), __perf_count(delay)), |
317 | 314 | ||
318 | TP_STRUCT__entry( | 315 | TP_STRUCT__entry( |
319 | __array( char, comm, TASK_COMM_LEN ) | 316 | __array( char, comm, TASK_COMM_LEN ) |
@@ -325,10 +322,6 @@ DECLARE_EVENT_CLASS(sched_stat_template, | |||
325 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); | 322 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); |
326 | __entry->pid = tsk->pid; | 323 | __entry->pid = tsk->pid; |
327 | __entry->delay = delay; | 324 | __entry->delay = delay; |
328 | ) | ||
329 | TP_perf_assign( | ||
330 | __perf_count(delay); | ||
331 | __perf_task(tsk); | ||
332 | ), | 325 | ), |
333 | 326 | ||
334 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", | 327 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", |
@@ -376,7 +369,7 @@ DECLARE_EVENT_CLASS(sched_stat_runtime, | |||
376 | 369 | ||
377 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), | 370 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), |
378 | 371 | ||
379 | TP_ARGS(tsk, runtime, vruntime), | 372 | TP_ARGS(tsk, __perf_count(runtime), vruntime), |
380 | 373 | ||
381 | TP_STRUCT__entry( | 374 | TP_STRUCT__entry( |
382 | __array( char, comm, TASK_COMM_LEN ) | 375 | __array( char, comm, TASK_COMM_LEN ) |
@@ -390,9 +383,6 @@ DECLARE_EVENT_CLASS(sched_stat_runtime, | |||
390 | __entry->pid = tsk->pid; | 383 | __entry->pid = tsk->pid; |
391 | __entry->runtime = runtime; | 384 | __entry->runtime = runtime; |
392 | __entry->vruntime = vruntime; | 385 | __entry->vruntime = vruntime; |
393 | ) | ||
394 | TP_perf_assign( | ||
395 | __perf_count(runtime); | ||
396 | ), | 386 | ), |
397 | 387 | ||
398 | TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", | 388 | TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", |
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 618af05f0be6..4163d93ccf38 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -507,8 +507,14 @@ static inline notrace int ftrace_get_offsets_##call( \ | |||
507 | #undef TP_fast_assign | 507 | #undef TP_fast_assign |
508 | #define TP_fast_assign(args...) args | 508 | #define TP_fast_assign(args...) args |
509 | 509 | ||
510 | #undef TP_perf_assign | 510 | #undef __perf_addr |
511 | #define TP_perf_assign(args...) | 511 | #define __perf_addr(a) (a) |
512 | |||
513 | #undef __perf_count | ||
514 | #define __perf_count(c) (c) | ||
515 | |||
516 | #undef __perf_task | ||
517 | #define __perf_task(t) (t) | ||
512 | 518 | ||
513 | #undef DECLARE_EVENT_CLASS | 519 | #undef DECLARE_EVENT_CLASS |
514 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | 520 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
@@ -636,16 +642,13 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call | |||
636 | #define __get_str(field) (char *)__get_dynamic_array(field) | 642 | #define __get_str(field) (char *)__get_dynamic_array(field) |
637 | 643 | ||
638 | #undef __perf_addr | 644 | #undef __perf_addr |
639 | #define __perf_addr(a) __addr = (a) | 645 | #define __perf_addr(a) (__addr = (a)) |
640 | 646 | ||
641 | #undef __perf_count | 647 | #undef __perf_count |
642 | #define __perf_count(c) __count = (c) | 648 | #define __perf_count(c) (__count = (c)) |
643 | 649 | ||
644 | #undef __perf_task | 650 | #undef __perf_task |
645 | #define __perf_task(t) __task = (t) | 651 | #define __perf_task(t) (__task = (t)) |
646 | |||
647 | #undef TP_perf_assign | ||
648 | #define TP_perf_assign(args...) args | ||
649 | 652 | ||
650 | #undef DECLARE_EVENT_CLASS | 653 | #undef DECLARE_EVENT_CLASS |
651 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | 654 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |