aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorZhang, Yanmin <yanmin_zhang@linux.intel.com>2010-04-19 01:32:41 -0400
committerAvi Kivity <avi@redhat.com>2010-04-19 05:35:33 -0400
commit39447b386c846bbf1c56f6403c5282837486200f (patch)
tree5ceaf9900919e4bd269b92c55df15e33039fefd1 /include
parentb5a80b7e91d6c067339e4d81a0176a835e9bf910 (diff)
perf: Enhance perf to allow for guest statistic collection from host
Below patch introduces perf_guest_info_callbacks and related register/unregister functions. Add more PERF_RECORD_MISC_XXX bits meaning guest kernel and guest user space. Signed-off-by: Zhang Yanmin <yanmin_zhang@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/perf_event.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index bf896d0b2e9c..24de5f181a41 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -288,11 +288,13 @@ struct perf_event_mmap_page {
288 __u64 data_tail; /* user-space written tail */ 288 __u64 data_tail; /* user-space written tail */
289}; 289};
290 290
291#define PERF_RECORD_MISC_CPUMODE_MASK (3 << 0) 291#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
292#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0) 292#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
293#define PERF_RECORD_MISC_KERNEL (1 << 0) 293#define PERF_RECORD_MISC_KERNEL (1 << 0)
294#define PERF_RECORD_MISC_USER (2 << 0) 294#define PERF_RECORD_MISC_USER (2 << 0)
295#define PERF_RECORD_MISC_HYPERVISOR (3 << 0) 295#define PERF_RECORD_MISC_HYPERVISOR (3 << 0)
296#define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0)
297#define PERF_RECORD_MISC_GUEST_USER (5 << 0)
296 298
297#define PERF_RECORD_MISC_EXACT (1 << 14) 299#define PERF_RECORD_MISC_EXACT (1 << 14)
298/* 300/*
@@ -446,6 +448,12 @@ enum perf_callchain_context {
446# include <asm/perf_event.h> 448# include <asm/perf_event.h>
447#endif 449#endif
448 450
451struct perf_guest_info_callbacks {
452 int (*is_in_guest) (void);
453 int (*is_user_mode) (void);
454 unsigned long (*get_guest_ip) (void);
455};
456
449#ifdef CONFIG_HAVE_HW_BREAKPOINT 457#ifdef CONFIG_HAVE_HW_BREAKPOINT
450#include <asm/hw_breakpoint.h> 458#include <asm/hw_breakpoint.h>
451#endif 459#endif
@@ -932,6 +940,12 @@ static inline void perf_event_mmap(struct vm_area_struct *vma)
932 __perf_event_mmap(vma); 940 __perf_event_mmap(vma);
933} 941}
934 942
943extern struct perf_guest_info_callbacks *perf_guest_cbs;
944extern int perf_register_guest_info_callbacks(
945 struct perf_guest_info_callbacks *);
946extern int perf_unregister_guest_info_callbacks(
947 struct perf_guest_info_callbacks *);
948
935extern void perf_event_comm(struct task_struct *tsk); 949extern void perf_event_comm(struct task_struct *tsk);
936extern void perf_event_fork(struct task_struct *tsk); 950extern void perf_event_fork(struct task_struct *tsk);
937 951
@@ -1001,6 +1015,11 @@ perf_sw_event(u32 event_id, u64 nr, int nmi,
1001static inline void 1015static inline void
1002perf_bp_event(struct perf_event *event, void *data) { } 1016perf_bp_event(struct perf_event *event, void *data) { }
1003 1017
1018static inline int perf_register_guest_info_callbacks
1019(struct perf_guest_info_callbacks *) {return 0; }
1020static inline int perf_unregister_guest_info_callbacks
1021(struct perf_guest_info_callbacks *) {return 0; }
1022
1004static inline void perf_event_mmap(struct vm_area_struct *vma) { } 1023static inline void perf_event_mmap(struct vm_area_struct *vma) { }
1005static inline void perf_event_comm(struct task_struct *tsk) { } 1024static inline void perf_event_comm(struct task_struct *tsk) { }
1006static inline void perf_event_fork(struct task_struct *tsk) { } 1025static inline void perf_event_fork(struct task_struct *tsk) { }