aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2009-05-14 07:48:08 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-15 10:38:56 -0400
commit9d23a90a67261e73b2fcac04d8ca963c6b496afb (patch)
tree81d453624f1834380740d3065cf022fe3500aad6 /include/linux
parentef923214a4816c289e4af2d67a9ebb1a31e4ac61 (diff)
perf_counter: allow arch to supply event misc flags and instruction pointer
At present the values we put in overflow events for the misc flags indicating processor mode and the instruction pointer are obtained using the standard user_mode() and instruction_pointer() functions. Those functions tell you where the performance monitor interrupt was taken, which might not be exactly where the counter overflow occurred, for example because interrupts were disabled at the point where the overflow occurred, or because the processor had many instructions in flight and chose to complete some more instructions beyond the one that caused the counter overflow. Some architectures (e.g. powerpc) can supply more precise information about where the counter overflow occurred and the processor mode at that point. This introduces new functions, perf_misc_flags() and perf_instruction_pointer(), which arch code can override to provide more precise information if available. They have default implementations which are identical to the existing code. This also adds a new misc flag value, PERF_EVENT_MISC_HYPERVISOR, for the case where a counter overflow occurred in the hypervisor. We encode the processor mode in the 2 bits previously used to indicate user or kernel mode; the values for user and kernel mode are unchanged and hypervisor mode is indicated by both bits being set. [ Impact: generalize perfcounter core facilities ] Signed-off-by: Paul Mackerras <paulus@samba.org> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <18956.1272.818511.561835@cargo.ozlabs.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/perf_counter.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 004b6e162b96..c8c1dfc22c93 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -215,8 +215,11 @@ struct perf_counter_mmap_page {
215 __u32 data_head; /* head in the data section */ 215 __u32 data_head; /* head in the data section */
216}; 216};
217 217
218#define PERF_EVENT_MISC_CPUMODE_MASK (3 << 0)
219#define PERF_EVENT_MISC_CPUMODE_UNKNOWN (0 << 0)
218#define PERF_EVENT_MISC_KERNEL (1 << 0) 220#define PERF_EVENT_MISC_KERNEL (1 << 0)
219#define PERF_EVENT_MISC_USER (1 << 1) 221#define PERF_EVENT_MISC_USER (2 << 0)
222#define PERF_EVENT_MISC_HYPERVISOR (3 << 0)
220#define PERF_EVENT_MISC_OVERFLOW (1 << 2) 223#define PERF_EVENT_MISC_OVERFLOW (1 << 2)
221 224
222struct perf_event_header { 225struct perf_event_header {
@@ -596,6 +599,12 @@ extern int sysctl_perf_counter_mlock;
596 599
597extern void perf_counter_init(void); 600extern void perf_counter_init(void);
598 601
602#ifndef perf_misc_flags
603#define perf_misc_flags(regs) (user_mode(regs) ? PERF_EVENT_MISC_USER : \
604 PERF_EVENT_MISC_KERNEL)
605#define perf_instruction_pointer(regs) instruction_pointer(regs)
606#endif
607
599#else 608#else
600static inline void 609static inline void
601perf_counter_task_sched_in(struct task_struct *task, int cpu) { } 610perf_counter_task_sched_in(struct task_struct *task, int cpu) { }