From 2f027c72ab6bce46c70b6ef0de4bf19d9e51d5d8 Mon Sep 17 00:00:00 2001
From: "Tan, Li"
Date: Fri, 23 May 2008 14:54:09 +0800
Subject: [PATCH] --- yaml --- r: 103731 b: refs/heads/master c:
9ef621d3be56e1188300476a8102ff54f7b6793f h: refs/heads/master i: 103729:
e1d57e55e5e764db926f12054c6a8bb857347648 103727:
5647cad8781eb1c5d033bf4d05dbaab16e466270 v: v3
---
[refs] | 2 +-
trunk/include/linux/kvm.h | 4 ++--
trunk/virt/kvm/kvm_trace.c | 18 ++++++++++++------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/[refs] b/[refs]
index 569651d30188..273927dfc20f 100644
--- a/[refs]
+++ b/[refs]
@@ -1,2 +1,2 @@
---
-refs/heads/master: 25be46080f1a446cb2bda3daadbd22a5682b955e
+refs/heads/master: 9ef621d3be56e1188300476a8102ff54f7b6793f
diff --git a/trunk/include/linux/kvm.h b/trunk/include/linux/kvm.h
index 1c908ac29c6c..0ea064cbfbc8 100644
--- a/trunk/include/linux/kvm.h
+++ b/trunk/include/linux/kvm.h
@@ -318,14 +318,14 @@ struct kvm_trace_rec {
__u32 vcpu_id;
union {
struct {
- __u32 cycle_lo, cycle_hi;
+ __u64 cycle_u64;
__u32 extra_u32[KVM_TRC_EXTRA_MAX];
} cycle;
struct {
__u32 extra_u32[KVM_TRC_EXTRA_MAX];
} nocycle;
} u;
-};
+} __attribute__((packed));
#define KVMIO 0xAE
diff --git a/trunk/virt/kvm/kvm_trace.c b/trunk/virt/kvm/kvm_trace.c
index 0e495470788d..58141f31ea8f 100644
--- a/trunk/virt/kvm/kvm_trace.c
+++ b/trunk/virt/kvm/kvm_trace.c
@@ -72,11 +72,7 @@ static void kvm_add_trace(void *probe_private, void *call_data,
rec.cycle_in = p->cycle_in;
if (rec.cycle_in) {
- u64 cycle = 0;
-
- cycle = get_cycles();
- rec.u.cycle.cycle_lo = (u32)cycle;
- rec.u.cycle.cycle_hi = (u32)(cycle >> 32);
+ rec.u.cycle.cycle_u64 = get_cycles();
for (i = 0; i < rec.extra_u32; i++)
rec.u.cycle.extra_u32[i] = va_arg(*args, u32);
@@ -114,8 +110,18 @@ static int kvm_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
{
struct kvm_trace *kt;
- if (!relay_buf_full(buf))
+ if (!relay_buf_full(buf)) {
+ if (!prev_subbuf) {
+ /*
+ * executed only once when the channel is opened
+ * save metadata as first record
+ */
+ subbuf_start_reserve(buf, sizeof(u32));
+ *(u32 *)subbuf = 0x12345678;
+ }
+
return 1;
+ }
kt = buf->chan->private_data;
atomic_inc(&kt->lost_records);