diff options
Diffstat (limited to 'virt/kvm/kvm_trace.c')
-rw-r--r-- | virt/kvm/kvm_trace.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c index 58141f31ea8f..41dcc845f78c 100644 --- a/virt/kvm/kvm_trace.c +++ b/virt/kvm/kvm_trace.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/relay.h> | 18 | #include <linux/relay.h> |
19 | #include <linux/debugfs.h> | 19 | #include <linux/debugfs.h> |
20 | #include <linux/ktime.h> | ||
20 | 21 | ||
21 | #include <linux/kvm_host.h> | 22 | #include <linux/kvm_host.h> |
22 | 23 | ||
@@ -35,16 +36,16 @@ static struct kvm_trace *kvm_trace; | |||
35 | struct kvm_trace_probe { | 36 | struct kvm_trace_probe { |
36 | const char *name; | 37 | const char *name; |
37 | const char *format; | 38 | const char *format; |
38 | u32 cycle_in; | 39 | u32 timestamp_in; |
39 | marker_probe_func *probe_func; | 40 | marker_probe_func *probe_func; |
40 | }; | 41 | }; |
41 | 42 | ||
42 | static inline int calc_rec_size(int cycle, int extra) | 43 | static inline int calc_rec_size(int timestamp, int extra) |
43 | { | 44 | { |
44 | int rec_size = KVM_TRC_HEAD_SIZE; | 45 | int rec_size = KVM_TRC_HEAD_SIZE; |
45 | 46 | ||
46 | rec_size += extra; | 47 | rec_size += extra; |
47 | return cycle ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size; | 48 | return timestamp ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size; |
48 | } | 49 | } |
49 | 50 | ||
50 | static void kvm_add_trace(void *probe_private, void *call_data, | 51 | static void kvm_add_trace(void *probe_private, void *call_data, |
@@ -54,12 +55,13 @@ static void kvm_add_trace(void *probe_private, void *call_data, | |||
54 | struct kvm_trace *kt = kvm_trace; | 55 | struct kvm_trace *kt = kvm_trace; |
55 | struct kvm_trace_rec rec; | 56 | struct kvm_trace_rec rec; |
56 | struct kvm_vcpu *vcpu; | 57 | struct kvm_vcpu *vcpu; |
57 | int i, extra, size; | 58 | int i, size; |
59 | u32 extra; | ||
58 | 60 | ||
59 | if (unlikely(kt->trace_state != KVM_TRACE_STATE_RUNNING)) | 61 | if (unlikely(kt->trace_state != KVM_TRACE_STATE_RUNNING)) |
60 | return; | 62 | return; |
61 | 63 | ||
62 | rec.event = va_arg(*args, u32); | 64 | rec.rec_val = TRACE_REC_EVENT_ID(va_arg(*args, u32)); |
63 | vcpu = va_arg(*args, struct kvm_vcpu *); | 65 | vcpu = va_arg(*args, struct kvm_vcpu *); |
64 | rec.pid = current->tgid; | 66 | rec.pid = current->tgid; |
65 | rec.vcpu_id = vcpu->vcpu_id; | 67 | rec.vcpu_id = vcpu->vcpu_id; |
@@ -67,21 +69,21 @@ static void kvm_add_trace(void *probe_private, void *call_data, | |||
67 | extra = va_arg(*args, u32); | 69 | extra = va_arg(*args, u32); |
68 | WARN_ON(!(extra <= KVM_TRC_EXTRA_MAX)); | 70 | WARN_ON(!(extra <= KVM_TRC_EXTRA_MAX)); |
69 | extra = min_t(u32, extra, KVM_TRC_EXTRA_MAX); | 71 | extra = min_t(u32, extra, KVM_TRC_EXTRA_MAX); |
70 | rec.extra_u32 = extra; | ||
71 | 72 | ||
72 | rec.cycle_in = p->cycle_in; | 73 | rec.rec_val |= TRACE_REC_TCS(p->timestamp_in) |
74 | | TRACE_REC_NUM_DATA_ARGS(extra); | ||
73 | 75 | ||
74 | if (rec.cycle_in) { | 76 | if (p->timestamp_in) { |
75 | rec.u.cycle.cycle_u64 = get_cycles(); | 77 | rec.u.timestamp.timestamp = ktime_to_ns(ktime_get()); |
76 | 78 | ||
77 | for (i = 0; i < rec.extra_u32; i++) | 79 | for (i = 0; i < extra; i++) |
78 | rec.u.cycle.extra_u32[i] = va_arg(*args, u32); | 80 | rec.u.timestamp.extra_u32[i] = va_arg(*args, u32); |
79 | } else { | 81 | } else { |
80 | for (i = 0; i < rec.extra_u32; i++) | 82 | for (i = 0; i < extra; i++) |
81 | rec.u.nocycle.extra_u32[i] = va_arg(*args, u32); | 83 | rec.u.notimestamp.extra_u32[i] = va_arg(*args, u32); |
82 | } | 84 | } |
83 | 85 | ||
84 | size = calc_rec_size(rec.cycle_in, rec.extra_u32 * sizeof(u32)); | 86 | size = calc_rec_size(p->timestamp_in, extra * sizeof(u32)); |
85 | relay_write(kt->rchan, &rec, size); | 87 | relay_write(kt->rchan, &rec, size); |
86 | } | 88 | } |
87 | 89 | ||