perf: Add a timestamp to fork events
authorArjan van de Ven <arjan@linux.intel.com>
Sat, 12 Sep 2009 05:52:47 +0000 (07:52 +0200)
committerIngo Molnar <mingo@elte.hu>
Sat, 19 Sep 2009 09:42:10 +0000 (11:42 +0200)
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>
include/linux/perf_counter.h
kernel/perf_counter.c
tools/perf/util/event.h

index c7375f97aa197d3347c5e41460c1f2661723d682..bd341007c4fca1abe1968993778a74a71a08306a 100644 (file)
@@ -336,6 +336,7 @@ enum perf_event_type {
         *      struct perf_event_header        header;
         *      u32                             pid, ppid;
         *      u32                             tid, ptid;
+        *      u64                             time;
         * };
         */
        PERF_EVENT_EXIT                 = 4,
@@ -356,6 +357,7 @@ enum perf_event_type {
         *      struct perf_event_header        header;
         *      u32                             pid, ppid;
         *      u32                             tid, ptid;
+        *      { u64                           time;     } && PERF_SAMPLE_TIME
         * };
         */
        PERF_EVENT_FORK                 = 7,
index d013f4e89e9cdee913b117cbbc83e4e326889113..d5899b62b2769854c04e5447483e31525791d791 100644 (file)
@@ -3083,6 +3083,7 @@ struct perf_task_event {
                u32                             ppid;
                u32                             tid;
                u32                             ptid;
+               u64                             time;
        } event;
 };
 
@@ -3090,9 +3091,12 @@ static void perf_counter_task_output(struct perf_counter *counter,
                                     struct perf_task_event *task_event)
 {
        struct perf_output_handle handle;
-       int size = task_event->event.header.size;
+       int size;
        struct task_struct *task = task_event->task;
-       int ret = perf_output_begin(&handle, counter, size, 0, 0);
+       int ret;
+
+       size  = task_event->event.header.size;
+       ret = perf_output_begin(&handle, counter, size, 0, 0);
 
        if (ret)
                return;
@@ -3103,7 +3107,10 @@ static void perf_counter_task_output(struct perf_counter *counter,
        task_event->event.tid = perf_counter_tid(counter, task);
        task_event->event.ptid = perf_counter_tid(counter, current);
 
+       task_event->event.time = perf_clock();
+
        perf_output_put(&handle, task_event->event);
+
        perf_output_end(&handle);
 }
 
index 2495529cae7dada7cd11ff1d42397186141fd4f5..28a579f8fa8ece2de39d84f43378fd22da309cf7 100644 (file)
@@ -39,6 +39,7 @@ struct fork_event {
        struct perf_event_header header;
        u32 pid, ppid;
        u32 tid, ptid;
+       u64 time;
 };
 
 struct lost_event {