aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2009-09-12 01:52:47 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-19 05:42:10 -0400
commit393b2ad8c757ba3ccd2a99ca5bbcd6db4d3fa53d (patch)
tree8972e2e9647c814e71be74d37adb85b18e9c6732
parent929bf0d0156562ce631728b6fa53d68004d456d2 (diff)
perf: Add a timestamp to fork events
perf timechart needs to know when a process forked, in order to be able to visualize properly when tasks start. This patch adds a time field to the event structure, and fills it in appropriately. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20090912130341.51ad2de2@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/linux/perf_counter.h2
-rw-r--r--kernel/perf_counter.c11
-rw-r--r--tools/perf/util/event.h1
3 files changed, 12 insertions, 2 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index c7375f97aa19..bd341007c4fc 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -336,6 +336,7 @@ enum perf_event_type {
336 * struct perf_event_header header; 336 * struct perf_event_header header;
337 * u32 pid, ppid; 337 * u32 pid, ppid;
338 * u32 tid, ptid; 338 * u32 tid, ptid;
339 * u64 time;
339 * }; 340 * };
340 */ 341 */
341 PERF_EVENT_EXIT = 4, 342 PERF_EVENT_EXIT = 4,
@@ -356,6 +357,7 @@ enum perf_event_type {
356 * struct perf_event_header header; 357 * struct perf_event_header header;
357 * u32 pid, ppid; 358 * u32 pid, ppid;
358 * u32 tid, ptid; 359 * u32 tid, ptid;
360 * { u64 time; } && PERF_SAMPLE_TIME
359 * }; 361 * };
360 */ 362 */
361 PERF_EVENT_FORK = 7, 363 PERF_EVENT_FORK = 7,
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index d013f4e89e9c..d5899b62b276 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -3083,6 +3083,7 @@ struct perf_task_event {
3083 u32 ppid; 3083 u32 ppid;
3084 u32 tid; 3084 u32 tid;
3085 u32 ptid; 3085 u32 ptid;
3086 u64 time;
3086 } event; 3087 } event;
3087}; 3088};
3088 3089
@@ -3090,9 +3091,12 @@ static void perf_counter_task_output(struct perf_counter *counter,
3090 struct perf_task_event *task_event) 3091 struct perf_task_event *task_event)
3091{ 3092{
3092 struct perf_output_handle handle; 3093 struct perf_output_handle handle;
3093 int size = task_event->event.header.size; 3094 int size;
3094 struct task_struct *task = task_event->task; 3095 struct task_struct *task = task_event->task;
3095 int ret = perf_output_begin(&handle, counter, size, 0, 0); 3096 int ret;
3097
3098 size = task_event->event.header.size;
3099 ret = perf_output_begin(&handle, counter, size, 0, 0);
3096 3100
3097 if (ret) 3101 if (ret)
3098 return; 3102 return;
@@ -3103,7 +3107,10 @@ static void perf_counter_task_output(struct perf_counter *counter,
3103 task_event->event.tid = perf_counter_tid(counter, task); 3107 task_event->event.tid = perf_counter_tid(counter, task);
3104 task_event->event.ptid = perf_counter_tid(counter, current); 3108 task_event->event.ptid = perf_counter_tid(counter, current);
3105 3109
3110 task_event->event.time = perf_clock();
3111
3106 perf_output_put(&handle, task_event->event); 3112 perf_output_put(&handle, task_event->event);
3113
3107 perf_output_end(&handle); 3114 perf_output_end(&handle);
3108} 3115}
3109 3116
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 2495529cae7d..28a579f8fa8e 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -39,6 +39,7 @@ struct fork_event {
39 struct perf_event_header header; 39 struct perf_event_header header;
40 u32 pid, ppid; 40 u32 pid, ppid;
41 u32 tid, ptid; 41 u32 tid, ptid;
42 u64 time;
42}; 43};
43 44
44struct lost_event { 45struct lost_event {