public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian
@ 2008-05-23  6:54 Tan, Li
  2008-05-23 17:39 ` Hollis Blanchard
  2008-06-11 19:53 ` Jerone Young
  0 siblings, 2 replies; 4+ messages in thread
From: Tan, Li @ 2008-05-23  6:54 UTC (permalink / raw)
  To: kvm

>From 8f1cd69b77054681bbb7e81a1a2d31b887db9fbb Mon Sep 17 00:00:00 2001
From: Tan Li <li.tan@intel.com>
Date: Fri, 23 May 2008 14:41:17 +0800
Subject: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting
big_endian

Currently kvmtrace is not portable. This will prevent from copying a
trace
file from big-endian target to little-endian workstation for analysis.
In the patch, kernel outputs metadata containing a magic number to trace
log.

Signed-off-by: Tan Li <li.tan@intel.com>

---
 include/linux/kvm.h  |    4 ++--
 virt/kvm/kvm_trace.c |   18 ++++++++++++------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index a281afe..ca08cb1 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -294,14 +294,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/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
index 0e49547..58141f3 100644
--- a/virt/kvm/kvm_trace.c
+++ b/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);
-- 
1.5.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian
  2008-05-23  6:54 [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian Tan, Li
@ 2008-05-23 17:39 ` Hollis Blanchard
  2008-06-11 19:53 ` Jerone Young
  1 sibling, 0 replies; 4+ messages in thread
From: Hollis Blanchard @ 2008-05-23 17:39 UTC (permalink / raw)
  To: Tan, Li; +Cc: kvm

On Friday 23 May 2008 01:54:09 Tan, Li wrote:
> From 8f1cd69b77054681bbb7e81a1a2d31b887db9fbb Mon Sep 17 00:00:00 2001
> From: Tan Li <li.tan@intel.com>
> Date: Fri, 23 May 2008 14:41:17 +0800
> Subject: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting
> big_endian
> 
> Currently kvmtrace is not portable. This will prevent from copying a
> trace
> file from big-endian target to little-endian workstation for analysis.
> In the patch, kernel outputs metadata containing a magic number to trace
> log.
> 
> Signed-off-by: Tan Li <li.tan@intel.com>

Acked-by: Hollis Blanchard <hollisb@us.ibm.com>

Thanks for working on this, Tan.

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian
  2008-05-23  6:54 [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian Tan, Li
  2008-05-23 17:39 ` Hollis Blanchard
@ 2008-06-11 19:53 ` Jerone Young
  2008-06-12 13:38   ` Avi Kivity
  1 sibling, 1 reply; 4+ messages in thread
From: Jerone Young @ 2008-06-11 19:53 UTC (permalink / raw)
  To: Tan, Li; +Cc: kvm

This patch is not in yet. Wanted to make sure that it doesn't fall off
the radar. Please include upstream.
Acked-by: Jerone Young <jyoung5@us.ibm.com>

On Fri, 2008-05-23 at 14:54 +0800, Tan, Li wrote:
> From 8f1cd69b77054681bbb7e81a1a2d31b887db9fbb Mon Sep 17 00:00:00 2001
> From: Tan Li <li.tan@intel.com>
> Date: Fri, 23 May 2008 14:41:17 +0800
> Subject: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting
> big_endian
> 
> Currently kvmtrace is not portable. This will prevent from copying a
> trace
> file from big-endian target to little-endian workstation for analysis.
> In the patch, kernel outputs metadata containing a magic number to trace
> log.
> 
> Signed-off-by: Tan Li <li.tan@intel.com>
> 
> ---
>  include/linux/kvm.h  |    4 ++--
>  virt/kvm/kvm_trace.c |   18 ++++++++++++------
>  2 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index a281afe..ca08cb1 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -294,14 +294,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/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
> index 0e49547..58141f3 100644
> --- a/virt/kvm/kvm_trace.c
> +++ b/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);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian
  2008-06-11 19:53 ` Jerone Young
@ 2008-06-12 13:38   ` Avi Kivity
  0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2008-06-12 13:38 UTC (permalink / raw)
  To: jyoung5; +Cc: Tan, Li, kvm

Jerone Young wrote:
> This patch is not in yet. Wanted to make sure that it doesn't fall off
> the radar. Please include upstream.
> Acked-by: Jerone Young <jyoung5@us.ibm.com>
>
>   

Thanks for the reminder.  Patch applied.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-12 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-23  6:54 [PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian Tan, Li
2008-05-23 17:39 ` Hollis Blanchard
2008-06-11 19:53 ` Jerone Young
2008-06-12 13:38   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox