Commit 339f7c90 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf_counter: PERF_RECORD_TIME

By popular request, provide means to log a timestamp along with the
counter overflow event.
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090406094518.024173282@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ebb3c4c4
...@@ -102,6 +102,7 @@ enum perf_counter_record_format { ...@@ -102,6 +102,7 @@ enum perf_counter_record_format {
PERF_RECORD_TID = 1U << 1, PERF_RECORD_TID = 1U << 1,
PERF_RECORD_GROUP = 1U << 2, PERF_RECORD_GROUP = 1U << 2,
PERF_RECORD_CALLCHAIN = 1U << 3, PERF_RECORD_CALLCHAIN = 1U << 3,
PERF_RECORD_TIME = 1U << 4,
}; };
/* /*
...@@ -221,6 +222,7 @@ enum perf_event_type { ...@@ -221,6 +222,7 @@ enum perf_event_type {
__PERF_EVENT_TID = PERF_RECORD_TID, __PERF_EVENT_TID = PERF_RECORD_TID,
__PERF_EVENT_GROUP = PERF_RECORD_GROUP, __PERF_EVENT_GROUP = PERF_RECORD_GROUP,
__PERF_EVENT_CALLCHAIN = PERF_RECORD_CALLCHAIN, __PERF_EVENT_CALLCHAIN = PERF_RECORD_CALLCHAIN,
__PERF_EVENT_TIME = PERF_RECORD_TIME,
}; };
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -1826,6 +1826,7 @@ static void perf_counter_output(struct perf_counter *counter, ...@@ -1826,6 +1826,7 @@ static void perf_counter_output(struct perf_counter *counter,
} group_entry; } group_entry;
struct perf_callchain_entry *callchain = NULL; struct perf_callchain_entry *callchain = NULL;
int callchain_size = 0; int callchain_size = 0;
u64 time;
header.type = PERF_EVENT_COUNTER_OVERFLOW; header.type = PERF_EVENT_COUNTER_OVERFLOW;
header.size = sizeof(header); header.size = sizeof(header);
...@@ -1862,6 +1863,16 @@ static void perf_counter_output(struct perf_counter *counter, ...@@ -1862,6 +1863,16 @@ static void perf_counter_output(struct perf_counter *counter,
} }
} }
if (record_type & PERF_RECORD_TIME) {
/*
* Maybe do better on x86 and provide cpu_clock_nmi()
*/
time = sched_clock();
header.type |= __PERF_EVENT_TIME;
header.size += sizeof(u64);
}
ret = perf_output_begin(&handle, counter, header.size, nmi); ret = perf_output_begin(&handle, counter, header.size, nmi);
if (ret) if (ret)
return; return;
...@@ -1895,6 +1906,9 @@ static void perf_counter_output(struct perf_counter *counter, ...@@ -1895,6 +1906,9 @@ static void perf_counter_output(struct perf_counter *counter,
if (callchain) if (callchain)
perf_output_copy(&handle, callchain, callchain_size); perf_output_copy(&handle, callchain, callchain_size);
if (record_type & PERF_RECORD_TIME)
perf_output_put(&handle, time);
perf_output_end(&handle); perf_output_end(&handle);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment