diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2012-11-27 20:29:03 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-11-27 20:29:15 -0500 |
commit | b48aa97e38206a84bf8485e7c553412274708ce5 (patch) | |
tree | 360f44bce8cf39836e916f3b5ed5c2e8849cd263 /arch/x86/kvm/trace.h | |
parent | 42897d866b120547777ae1fd316680ec53356d9c (diff) |
KVM: x86: require matched TSC offsets for master clock
With master clock, a pvclock clock read calculates:
ret = system_timestamp + [ (rdtsc + tsc_offset) - tsc_timestamp ]
Where 'rdtsc' is the host TSC.
system_timestamp and tsc_timestamp are unique, one tuple
per VM: the "master clock".
Given a host with synchronized TSCs, its obvious that
guest TSC must be matched for the above to guarantee monotonicity.
Allow master clock usage only if guest TSCs are synchronized.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/trace.h')
-rw-r--r-- | arch/x86/kvm/trace.h | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 1d6526856080..fe5e00ed7036 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h | |||
@@ -764,21 +764,54 @@ TRACE_EVENT( | |||
764 | {VCLOCK_HPET, "hpet"} \ | 764 | {VCLOCK_HPET, "hpet"} \ |
765 | 765 | ||
766 | TRACE_EVENT(kvm_update_master_clock, | 766 | TRACE_EVENT(kvm_update_master_clock, |
767 | TP_PROTO(bool use_master_clock, unsigned int host_clock), | 767 | TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched), |
768 | TP_ARGS(use_master_clock, host_clock), | 768 | TP_ARGS(use_master_clock, host_clock, offset_matched), |
769 | 769 | ||
770 | TP_STRUCT__entry( | 770 | TP_STRUCT__entry( |
771 | __field( bool, use_master_clock ) | 771 | __field( bool, use_master_clock ) |
772 | __field( unsigned int, host_clock ) | 772 | __field( unsigned int, host_clock ) |
773 | __field( bool, offset_matched ) | ||
773 | ), | 774 | ), |
774 | 775 | ||
775 | TP_fast_assign( | 776 | TP_fast_assign( |
776 | __entry->use_master_clock = use_master_clock; | 777 | __entry->use_master_clock = use_master_clock; |
777 | __entry->host_clock = host_clock; | 778 | __entry->host_clock = host_clock; |
779 | __entry->offset_matched = offset_matched; | ||
778 | ), | 780 | ), |
779 | 781 | ||
780 | TP_printk("masterclock %d hostclock %s", | 782 | TP_printk("masterclock %d hostclock %s offsetmatched %u", |
781 | __entry->use_master_clock, | 783 | __entry->use_master_clock, |
784 | __print_symbolic(__entry->host_clock, host_clocks), | ||
785 | __entry->offset_matched) | ||
786 | ); | ||
787 | |||
788 | TRACE_EVENT(kvm_track_tsc, | ||
789 | TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched, | ||
790 | unsigned int online_vcpus, bool use_master_clock, | ||
791 | unsigned int host_clock), | ||
792 | TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock, | ||
793 | host_clock), | ||
794 | |||
795 | TP_STRUCT__entry( | ||
796 | __field( unsigned int, vcpu_id ) | ||
797 | __field( unsigned int, nr_vcpus_matched_tsc ) | ||
798 | __field( unsigned int, online_vcpus ) | ||
799 | __field( bool, use_master_clock ) | ||
800 | __field( unsigned int, host_clock ) | ||
801 | ), | ||
802 | |||
803 | TP_fast_assign( | ||
804 | __entry->vcpu_id = vcpu_id; | ||
805 | __entry->nr_vcpus_matched_tsc = nr_matched; | ||
806 | __entry->online_vcpus = online_vcpus; | ||
807 | __entry->use_master_clock = use_master_clock; | ||
808 | __entry->host_clock = host_clock; | ||
809 | ), | ||
810 | |||
811 | TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u" | ||
812 | " hostclock %s", | ||
813 | __entry->vcpu_id, __entry->use_master_clock, | ||
814 | __entry->nr_vcpus_matched_tsc, __entry->online_vcpus, | ||
782 | __print_symbolic(__entry->host_clock, host_clocks)) | 815 | __print_symbolic(__entry->host_clock, host_clocks)) |
783 | ); | 816 | ); |
784 | 817 | ||