diff options
author | Zhang, Yanmin <yanmin_zhang@linux.intel.com> | 2010-04-19 22:13:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-20 02:08:28 -0400 |
commit | dcf46b9443ad48a227a61713adea001228925adf (patch) | |
tree | 1055614c98e8f6584e40fc4ca73ad611b5a77530 | |
parent | a1645ce12adb6c9cc9e19d7695466204e3f017fe (diff) |
perf & kvm: Clean up some of the guest profiling callback API details
Fix some build bug and programming style issues:
- use valid C
- fix up various style details
Signed-off-by: Zhang Yanmin <yanmin_zhang@linux.intel.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sheng Yang <sheng@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: oerg Roedel <joro@8bytes.org>
Cc: Jes Sorensen <Jes.Sorensen@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Zachary Amsden <zamsden@redhat.com>
Cc: zhiteng.huang@intel.com
Cc: tim.c.chen@intel.com
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
LKML-Reference: <1271729638.2078.624.camel@ymzhang.sh.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/cpu/perf_event.c | 20 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 4 | ||||
-rw-r--r-- | include/linux/perf_event.h | 10 |
3 files changed, 22 insertions, 12 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 2ea78abf69d9..7de70613e6c3 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
@@ -1752,23 +1752,31 @@ void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int ski | |||
1752 | unsigned long perf_instruction_pointer(struct pt_regs *regs) | 1752 | unsigned long perf_instruction_pointer(struct pt_regs *regs) |
1753 | { | 1753 | { |
1754 | unsigned long ip; | 1754 | unsigned long ip; |
1755 | |||
1755 | if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) | 1756 | if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) |
1756 | ip = perf_guest_cbs->get_guest_ip(); | 1757 | ip = perf_guest_cbs->get_guest_ip(); |
1757 | else | 1758 | else |
1758 | ip = instruction_pointer(regs); | 1759 | ip = instruction_pointer(regs); |
1760 | |||
1759 | return ip; | 1761 | return ip; |
1760 | } | 1762 | } |
1761 | 1763 | ||
1762 | unsigned long perf_misc_flags(struct pt_regs *regs) | 1764 | unsigned long perf_misc_flags(struct pt_regs *regs) |
1763 | { | 1765 | { |
1764 | int misc = 0; | 1766 | int misc = 0; |
1767 | |||
1765 | if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) { | 1768 | if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) { |
1766 | misc |= perf_guest_cbs->is_user_mode() ? | 1769 | if (perf_guest_cbs->is_user_mode()) |
1767 | PERF_RECORD_MISC_GUEST_USER : | 1770 | misc |= PERF_RECORD_MISC_GUEST_USER; |
1768 | PERF_RECORD_MISC_GUEST_KERNEL; | 1771 | else |
1769 | } else | 1772 | misc |= PERF_RECORD_MISC_GUEST_KERNEL; |
1770 | misc |= user_mode(regs) ? PERF_RECORD_MISC_USER : | 1773 | } else { |
1771 | PERF_RECORD_MISC_KERNEL; | 1774 | if (user_mode(regs)) |
1775 | misc |= PERF_RECORD_MISC_USER; | ||
1776 | else | ||
1777 | misc |= PERF_RECORD_MISC_KERNEL; | ||
1778 | } | ||
1779 | |||
1772 | if (regs->flags & PERF_EFLAGS_EXACT) | 1780 | if (regs->flags & PERF_EFLAGS_EXACT) |
1773 | misc |= PERF_RECORD_MISC_EXACT; | 1781 | misc |= PERF_RECORD_MISC_EXACT; |
1774 | 1782 | ||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c3a33b2bb169..21b9b6aa3e88 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3776,16 +3776,20 @@ static int kvm_is_in_guest(void) | |||
3776 | static int kvm_is_user_mode(void) | 3776 | static int kvm_is_user_mode(void) |
3777 | { | 3777 | { |
3778 | int user_mode = 3; | 3778 | int user_mode = 3; |
3779 | |||
3779 | if (percpu_read(current_vcpu)) | 3780 | if (percpu_read(current_vcpu)) |
3780 | user_mode = kvm_x86_ops->get_cpl(percpu_read(current_vcpu)); | 3781 | user_mode = kvm_x86_ops->get_cpl(percpu_read(current_vcpu)); |
3782 | |||
3781 | return user_mode != 0; | 3783 | return user_mode != 0; |
3782 | } | 3784 | } |
3783 | 3785 | ||
3784 | static unsigned long kvm_get_guest_ip(void) | 3786 | static unsigned long kvm_get_guest_ip(void) |
3785 | { | 3787 | { |
3786 | unsigned long ip = 0; | 3788 | unsigned long ip = 0; |
3789 | |||
3787 | if (percpu_read(current_vcpu)) | 3790 | if (percpu_read(current_vcpu)) |
3788 | ip = kvm_rip_read(percpu_read(current_vcpu)); | 3791 | ip = kvm_rip_read(percpu_read(current_vcpu)); |
3792 | |||
3789 | return ip; | 3793 | return ip; |
3790 | } | 3794 | } |
3791 | 3795 | ||
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 24de5f181a41..ace31fbac513 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -941,10 +941,8 @@ static inline void perf_event_mmap(struct vm_area_struct *vma) | |||
941 | } | 941 | } |
942 | 942 | ||
943 | extern struct perf_guest_info_callbacks *perf_guest_cbs; | 943 | extern struct perf_guest_info_callbacks *perf_guest_cbs; |
944 | extern int perf_register_guest_info_callbacks( | 944 | extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); |
945 | struct perf_guest_info_callbacks *); | 945 | extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); |
946 | extern int perf_unregister_guest_info_callbacks( | ||
947 | struct perf_guest_info_callbacks *); | ||
948 | 946 | ||
949 | extern void perf_event_comm(struct task_struct *tsk); | 947 | extern void perf_event_comm(struct task_struct *tsk); |
950 | extern void perf_event_fork(struct task_struct *tsk); | 948 | extern void perf_event_fork(struct task_struct *tsk); |
@@ -1016,9 +1014,9 @@ static inline void | |||
1016 | perf_bp_event(struct perf_event *event, void *data) { } | 1014 | perf_bp_event(struct perf_event *event, void *data) { } |
1017 | 1015 | ||
1018 | static inline int perf_register_guest_info_callbacks | 1016 | static inline int perf_register_guest_info_callbacks |
1019 | (struct perf_guest_info_callbacks *) {return 0; } | 1017 | (struct perf_guest_info_callbacks *callbacks) { return 0; } |
1020 | static inline int perf_unregister_guest_info_callbacks | 1018 | static inline int perf_unregister_guest_info_callbacks |
1021 | (struct perf_guest_info_callbacks *) {return 0; } | 1019 | (struct perf_guest_info_callbacks *callbacks) { return 0; } |
1022 | 1020 | ||
1023 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } | 1021 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } |
1024 | static inline void perf_event_comm(struct task_struct *tsk) { } | 1022 | static inline void perf_event_comm(struct task_struct *tsk) { } |