aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace
diff options
context:
space:
mode:
authorAndrew Vagin <avagin@openvz.org>2012-07-11 10:14:58 -0400
committerIngo Molnar <mingo@kernel.org>2012-07-31 11:02:05 -0400
commite6dab5ffab59e910ec0e3355f4a6f29f7a7be474 (patch)
tree87acf0fb071b8d09794ac7d834cb256de030cceb /include/trace
parentd07bdfd322d307789f15b427dbcc39257665356f (diff)
perf/trace: Add ability to set a target task for events
A few events are interesting not only for a current task. For example, sched_stat_* events are interesting for a task which wakes up. For this reason, it will be good if such events will be delivered to a target task too. Now a target task can be set by using __perf_task(). The original idea and a draft patch belongs to Peter Zijlstra. I need these events for profiling sleep times. sched_switch is used for getting callchains and sched_stat_* is used for getting time periods. These events are combined in user space, then it can be analyzed by perf tools. Inspired-by: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Arun Sharma <asharma@fb.com> Signed-off-by: Andrew Vagin <avagin@openvz.org> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1342016098-213063-1-git-send-email-avagin@openvz.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/trace')
-rw-r--r--include/trace/events/sched.h4
-rw-r--r--include/trace/ftrace.h6
2 files changed, 9 insertions, 1 deletions
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index ea7a2035456..5a8671e8a67 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -73,6 +73,9 @@ 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);
76 ), 79 ),
77 80
78 TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", 81 TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d",
@@ -325,6 +328,7 @@ DECLARE_EVENT_CLASS(sched_stat_template,
325 ) 328 )
326 TP_perf_assign( 329 TP_perf_assign(
327 __perf_count(delay); 330 __perf_count(delay);
331 __perf_task(tsk);
328 ), 332 ),
329 333
330 TP_printk("comm=%s pid=%d delay=%Lu [ns]", 334 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index c6bc2faaf26..a763888a36f 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -712,6 +712,9 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
712#undef __perf_count 712#undef __perf_count
713#define __perf_count(c) __count = (c) 713#define __perf_count(c) __count = (c)
714 714
715#undef __perf_task
716#define __perf_task(t) __task = (t)
717
715#undef TP_perf_assign 718#undef TP_perf_assign
716#define TP_perf_assign(args...) args 719#define TP_perf_assign(args...) args
717 720
@@ -725,6 +728,7 @@ perf_trace_##call(void *__data, proto) \
725 struct ftrace_raw_##call *entry; \ 728 struct ftrace_raw_##call *entry; \
726 struct pt_regs __regs; \ 729 struct pt_regs __regs; \
727 u64 __addr = 0, __count = 1; \ 730 u64 __addr = 0, __count = 1; \
731 struct task_struct *__task = NULL; \
728 struct hlist_head *head; \ 732 struct hlist_head *head; \
729 int __entry_size; \ 733 int __entry_size; \
730 int __data_size; \ 734 int __data_size; \
@@ -752,7 +756,7 @@ perf_trace_##call(void *__data, proto) \
752 \ 756 \
753 head = this_cpu_ptr(event_call->perf_events); \ 757 head = this_cpu_ptr(event_call->perf_events); \
754 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \ 758 perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
755 __count, &__regs, head); \ 759 __count, &__regs, head, __task); \
756} 760}
757 761
758/* 762/*