diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-04-08 09:01:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-08 12:53:28 -0400 |
commit | 6b6e5486b3a168f0328c82a8d4376caf901472b1 (patch) | |
tree | f47c942f813f1348b5218d2a8df0c76378faff0b | |
parent | 6fab01927e8bdbbc77bafba2abb4810c5591ad52 (diff) |
perf_counter: use misc field to widen type
Push the PERF_EVENT_COUNTER_OVERFLOW bit into the misc field so that
we can have the full 32bit for PERF_RECORD_ bits.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090408130408.891867663@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/perf_counter.h | 28 | ||||
-rw-r--r-- | kernel/perf_counter.c | 15 |
2 files changed, 18 insertions, 25 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 5bd8817b12d4..4809ae18a940 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -201,8 +201,9 @@ struct perf_counter_mmap_page { | |||
201 | __u32 data_head; /* head in the data section */ | 201 | __u32 data_head; /* head in the data section */ |
202 | }; | 202 | }; |
203 | 203 | ||
204 | #define PERF_EVENT_MISC_KERNEL (1 << 0) | 204 | #define PERF_EVENT_MISC_KERNEL (1 << 0) |
205 | #define PERF_EVENT_MISC_USER (1 << 1) | 205 | #define PERF_EVENT_MISC_USER (1 << 1) |
206 | #define PERF_EVENT_MISC_OVERFLOW (1 << 2) | ||
206 | 207 | ||
207 | struct perf_event_header { | 208 | struct perf_event_header { |
208 | __u32 type; | 209 | __u32 type; |
@@ -230,36 +231,27 @@ enum perf_event_type { | |||
230 | PERF_EVENT_MUNMAP = 2, | 231 | PERF_EVENT_MUNMAP = 2, |
231 | 232 | ||
232 | /* | 233 | /* |
233 | * Half the event type space is reserved for the counter overflow | 234 | * When header.misc & PERF_EVENT_MISC_OVERFLOW the event_type field |
234 | * bitfields, as found in hw_event.record_type. | 235 | * will be PERF_RECORD_* |
235 | * | ||
236 | * These events will have types of the form: | ||
237 | * PERF_EVENT_COUNTER_OVERFLOW { | __PERF_EVENT_* } * | ||
238 | * | 236 | * |
239 | * struct { | 237 | * struct { |
240 | * struct perf_event_header header; | 238 | * struct perf_event_header header; |
241 | * | 239 | * |
242 | * { u64 ip; } && __PERF_EVENT_IP | 240 | * { u64 ip; } && PERF_RECORD_IP |
243 | * { u32 pid, tid; } && __PERF_EVENT_TID | 241 | * { u32 pid, tid; } && PERF_RECORD_TID |
244 | * | 242 | * |
245 | * { u64 nr; | 243 | * { u64 nr; |
246 | * { u64 event, val; } cnt[nr]; } && __PERF_EVENT_GROUP | 244 | * { u64 event, val; } cnt[nr]; } && PERF_RECORD_GROUP |
247 | * | 245 | * |
248 | * { u16 nr, | 246 | * { u16 nr, |
249 | * hv, | 247 | * hv, |
250 | * kernel, | 248 | * kernel, |
251 | * user; | 249 | * user; |
252 | * u64 ips[nr]; } && __PERF_EVENT_CALLCHAIN | 250 | * u64 ips[nr]; } && PERF_RECORD_CALLCHAIN |
253 | * | 251 | * |
254 | * { u64 time; } && __PERF_EVENT_TIME | 252 | * { u64 time; } && PERF_RECORD_TIME |
255 | * }; | 253 | * }; |
256 | */ | 254 | */ |
257 | PERF_EVENT_COUNTER_OVERFLOW = 1UL << 31, | ||
258 | __PERF_EVENT_IP = PERF_RECORD_IP, | ||
259 | __PERF_EVENT_TID = PERF_RECORD_TID, | ||
260 | __PERF_EVENT_GROUP = PERF_RECORD_GROUP, | ||
261 | __PERF_EVENT_CALLCHAIN = PERF_RECORD_CALLCHAIN, | ||
262 | __PERF_EVENT_TIME = PERF_RECORD_TIME, | ||
263 | }; | 255 | }; |
264 | 256 | ||
265 | #ifdef __KERNEL__ | 257 | #ifdef __KERNEL__ |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 4af98f943d3b..bf12df6f3538 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -1828,15 +1828,16 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1828 | int callchain_size = 0; | 1828 | int callchain_size = 0; |
1829 | u64 time; | 1829 | u64 time; |
1830 | 1830 | ||
1831 | header.type = PERF_EVENT_COUNTER_OVERFLOW; | 1831 | header.type = 0; |
1832 | header.size = sizeof(header); | 1832 | header.size = sizeof(header); |
1833 | 1833 | ||
1834 | header.misc = user_mode(regs) ? | 1834 | header.misc = PERF_EVENT_MISC_OVERFLOW; |
1835 | header.misc |= user_mode(regs) ? | ||
1835 | PERF_EVENT_MISC_USER : PERF_EVENT_MISC_KERNEL; | 1836 | PERF_EVENT_MISC_USER : PERF_EVENT_MISC_KERNEL; |
1836 | 1837 | ||
1837 | if (record_type & PERF_RECORD_IP) { | 1838 | if (record_type & PERF_RECORD_IP) { |
1838 | ip = instruction_pointer(regs); | 1839 | ip = instruction_pointer(regs); |
1839 | header.type |= __PERF_EVENT_IP; | 1840 | header.type |= PERF_RECORD_IP; |
1840 | header.size += sizeof(ip); | 1841 | header.size += sizeof(ip); |
1841 | } | 1842 | } |
1842 | 1843 | ||
@@ -1845,12 +1846,12 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1845 | tid_entry.pid = current->group_leader->pid; | 1846 | tid_entry.pid = current->group_leader->pid; |
1846 | tid_entry.tid = current->pid; | 1847 | tid_entry.tid = current->pid; |
1847 | 1848 | ||
1848 | header.type |= __PERF_EVENT_TID; | 1849 | header.type |= PERF_RECORD_TID; |
1849 | header.size += sizeof(tid_entry); | 1850 | header.size += sizeof(tid_entry); |
1850 | } | 1851 | } |
1851 | 1852 | ||
1852 | if (record_type & PERF_RECORD_GROUP) { | 1853 | if (record_type & PERF_RECORD_GROUP) { |
1853 | header.type |= __PERF_EVENT_GROUP; | 1854 | header.type |= PERF_RECORD_GROUP; |
1854 | header.size += sizeof(u64) + | 1855 | header.size += sizeof(u64) + |
1855 | counter->nr_siblings * sizeof(group_entry); | 1856 | counter->nr_siblings * sizeof(group_entry); |
1856 | } | 1857 | } |
@@ -1861,7 +1862,7 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1861 | if (callchain) { | 1862 | if (callchain) { |
1862 | callchain_size = (1 + callchain->nr) * sizeof(u64); | 1863 | callchain_size = (1 + callchain->nr) * sizeof(u64); |
1863 | 1864 | ||
1864 | header.type |= __PERF_EVENT_CALLCHAIN; | 1865 | header.type |= PERF_RECORD_CALLCHAIN; |
1865 | header.size += callchain_size; | 1866 | header.size += callchain_size; |
1866 | } | 1867 | } |
1867 | } | 1868 | } |
@@ -1872,7 +1873,7 @@ static void perf_counter_output(struct perf_counter *counter, | |||
1872 | */ | 1873 | */ |
1873 | time = sched_clock(); | 1874 | time = sched_clock(); |
1874 | 1875 | ||
1875 | header.type |= __PERF_EVENT_TIME; | 1876 | header.type |= PERF_RECORD_TIME; |
1876 | header.size += sizeof(u64); | 1877 | header.size += sizeof(u64); |
1877 | } | 1878 | } |
1878 | 1879 | ||