diff options
-rw-r--r-- | include/linux/perf_counter.h | 2 | ||||
-rw-r--r-- | kernel/perf_counter.c | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index ca2d4df29e0c..928a7fae0961 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -102,6 +102,7 @@ enum perf_counter_record_format { | |||
102 | PERF_RECORD_TID = 1U << 1, | 102 | PERF_RECORD_TID = 1U << 1, |
103 | PERF_RECORD_GROUP = 1U << 2, | 103 | PERF_RECORD_GROUP = 1U << 2, |
104 | PERF_RECORD_CALLCHAIN = 1U << 3, | 104 | PERF_RECORD_CALLCHAIN = 1U << 3, |
105 | PERF_RECORD_TIME = 1U << 4, | ||
105 | }; | 106 | }; |
106 | 107 | ||
107 | /* | 108 | /* |
@@ -221,6 +222,7 @@ enum perf_event_type { | |||
221 | __PERF_EVENT_TID = PERF_RECORD_TID, | 222 | __PERF_EVENT_TID = PERF_RECORD_TID, |
222 | __PERF_EVENT_GROUP = PERF_RECORD_GROUP, | 223 | __PERF_EVENT_GROUP = PERF_RECORD_GROUP, |
223 | __PERF_EVENT_CALLCHAIN = PERF_RECORD_CALLCHAIN, | 224 | __PERF_EVENT_CALLCHAIN = PERF_RECORD_CALLCHAIN, |
225 | __PERF_EVENT_TIME = PERF_RECORD_TIME, | ||
224 | }; | 226 | }; |
225 | 227 | ||
226 | #ifdef __KERNEL__ | 228 | #ifdef __KERNEL__ |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index c841563de043..19990d1f0215 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -1826,6 +1826,7 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1826 | } group_entry; | 1826 | } group_entry; |
1827 | struct perf_callchain_entry *callchain = NULL; | 1827 | struct perf_callchain_entry *callchain = NULL; |
1828 | int callchain_size = 0; | 1828 | int callchain_size = 0; |
1829 | u64 time; | ||
1829 | 1830 | ||
1830 | header.type = PERF_EVENT_COUNTER_OVERFLOW; | 1831 | header.type = PERF_EVENT_COUNTER_OVERFLOW; |
1831 | header.size = sizeof(header); | 1832 | header.size = sizeof(header); |
@@ -1862,6 +1863,16 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1862 | } | 1863 | } |
1863 | } | 1864 | } |
1864 | 1865 | ||
1866 | if (record_type & PERF_RECORD_TIME) { | ||
1867 | /* | ||
1868 | * Maybe do better on x86 and provide cpu_clock_nmi() | ||
1869 | */ | ||
1870 | time = sched_clock(); | ||
1871 | |||
1872 | header.type |= __PERF_EVENT_TIME; | ||
1873 | header.size += sizeof(u64); | ||
1874 | } | ||
1875 | |||
1865 | ret = perf_output_begin(&handle, counter, header.size, nmi); | 1876 | ret = perf_output_begin(&handle, counter, header.size, nmi); |
1866 | if (ret) | 1877 | if (ret) |
1867 | return; | 1878 | return; |
@@ -1895,6 +1906,9 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1895 | if (callchain) | 1906 | if (callchain) |
1896 | perf_output_copy(&handle, callchain, callchain_size); | 1907 | perf_output_copy(&handle, callchain, callchain_size); |
1897 | 1908 | ||
1909 | if (record_type & PERF_RECORD_TIME) | ||
1910 | perf_output_put(&handle, time); | ||
1911 | |||
1898 | perf_output_end(&handle); | 1912 | perf_output_end(&handle); |
1899 | } | 1913 | } |
1900 | 1914 | ||