Skip to content

Commit ce1a5e6

Browse files
dmatlackbonzini
authored andcommitted
kvm: x86: add trace event for pvclock updates
The new trace event records: * the id of vcpu being updated * the pvclock_vcpu_time_info struct being written to guest memory This is useful for debugging pvclock bugs, such as the bug fixed by "[PATCH] kvm: x86: Fix kvm clock versioning.". Signed-off-by: David Matlack <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 09a0c3f commit ce1a5e6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

arch/x86/kvm/trace.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <asm/vmx.h>
66
#include <asm/svm.h>
77
#include <asm/clocksource.h>
8+
#include <asm/pvclock-abi.h>
89

910
#undef TRACE_SYSTEM
1011
#define TRACE_SYSTEM kvm
@@ -877,6 +878,42 @@ TRACE_EVENT(kvm_ple_window,
877878
#define trace_kvm_ple_window_shrink(vcpu_id, new, old) \
878879
trace_kvm_ple_window(false, vcpu_id, new, old)
879880

881+
TRACE_EVENT(kvm_pvclock_update,
882+
TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
883+
TP_ARGS(vcpu_id, pvclock),
884+
885+
TP_STRUCT__entry(
886+
__field( unsigned int, vcpu_id )
887+
__field( __u32, version )
888+
__field( __u64, tsc_timestamp )
889+
__field( __u64, system_time )
890+
__field( __u32, tsc_to_system_mul )
891+
__field( __s8, tsc_shift )
892+
__field( __u8, flags )
893+
),
894+
895+
TP_fast_assign(
896+
__entry->vcpu_id = vcpu_id;
897+
__entry->version = pvclock->version;
898+
__entry->tsc_timestamp = pvclock->tsc_timestamp;
899+
__entry->system_time = pvclock->system_time;
900+
__entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
901+
__entry->tsc_shift = pvclock->tsc_shift;
902+
__entry->flags = pvclock->flags;
903+
),
904+
905+
TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
906+
"system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
907+
"flags 0x%x }",
908+
__entry->vcpu_id,
909+
__entry->version,
910+
__entry->tsc_timestamp,
911+
__entry->system_time,
912+
__entry->tsc_to_system_mul,
913+
__entry->tsc_shift,
914+
__entry->flags)
915+
);
916+
880917
#endif /* _TRACE_KVM_H */
881918

882919
#undef TRACE_INCLUDE_PATH

arch/x86/kvm/x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,8 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
16611661

16621662
vcpu->hv_clock.flags = pvclock_flags;
16631663

1664+
trace_kvm_pvclock_update(v->vcpu_id, &vcpu->hv_clock);
1665+
16641666
kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
16651667
&vcpu->hv_clock,
16661668
sizeof(vcpu->hv_clock));

0 commit comments

Comments
 (0)