public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: ehrhardt@linux.vnet.ibm.com
To: kvm@vger.kernel.org
Cc: hollisb@us.ibm.com, avi@qumranet.com, kvm-ppc@vger.kernel.org,
	ehrhardt@linux.vnet.ibm.com, borntraeger@de.ibm.com,
	sheng.yang@intel.com
Subject: [PATCH 2/8] kvmtrace: replace get_cycles with ktime_get v3
Date: Mon, 14 Jul 2008 14:00:01 +0200	[thread overview]
Message-ID: <1216036807-18277-3-git-send-email-ehrhardt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1216036807-18277-1-git-send-email-ehrhardt@linux.vnet.ibm.com>

From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

The current kvmtrace code uses get_cycles() while the interpretation would be
easier using using nanoseconds. ktime_get() should give at least the same
accuracy as get_cycles on all architectures (even better on 32bit archs) but
at a better unit (e.g. comparable between hosts with different frequencies.

V3 of this patch now uses the ktime_get() as discussed on the mailing list.
This ensures that the granularity is always 64 bit on all architetcures and
in the background getnstimeofday is used giving us ns granularity.
Additionally this gives us only one generic implementation without need for
an arch hook.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
---

[diffstat]
 include/linux/kvm.h  |    6 +++---
 virt/kvm/kvm_trace.c |   18 +++++++++---------
 2 files changed, 12 insertions(+), 12 deletions(-)

[diff]

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -322,12 +322,12 @@
 	__u32 vcpu_id;
 	union {
 		struct {
-			__u64 cycle_u64;
+			ktime_t timestamp;
 			__u32 extra_u32[KVM_TRC_EXTRA_MAX];
-		} cycle;
+		} timestamp;
 		struct {
 			__u32 extra_u32[KVM_TRC_EXTRA_MAX];
-		} nocycle;
+		} notimestamp;
 	} u;
 } __attribute__((packed));
 
diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
--- a/virt/kvm/kvm_trace.c
+++ b/virt/kvm/kvm_trace.c
@@ -35,16 +35,16 @@
 struct kvm_trace_probe {
 	const char *name;
 	const char *format;
-	u32 cycle_in;
+	u32 timestamp_in;
 	marker_probe_func *probe_func;
 };
 
-static inline int calc_rec_size(int cycle, int extra)
+static inline int calc_rec_size(int timestamp, int extra)
 {
 	int rec_size = KVM_TRC_HEAD_SIZE;
 
 	rec_size += extra;
-	return cycle ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size;
+	return timestamp ? rec_size += KVM_TRC_CYCLE_SIZE : rec_size;
 }
 
 static void kvm_add_trace(void *probe_private, void *call_data,
@@ -69,20 +69,20 @@
 	WARN_ON(!(extra <= KVM_TRC_EXTRA_MAX));
 	extra 		= min_t(u32, extra, KVM_TRC_EXTRA_MAX);
 
-	rec.rec_val |= TRACE_REC_TCS(p->cycle_in)
+	rec.rec_val |= TRACE_REC_TCS(p->timestamp_in)
 			| TRACE_REC_NUM_DATA_ARGS(extra);
 	
-	if (p->cycle_in) {
-		rec.u.cycle.cycle_u64 = get_cycles();
+	if (p->timestamp_in) {
+		rec.u.timestamp.timestamp = ktime_get();
 
 		for (i = 0; i < extra; i++)
-			rec.u.cycle.extra_u32[i] = va_arg(*args, u32);
+			rec.u.timestamp.extra_u32[i] = va_arg(*args, u32);
 	} else {
 		for (i = 0; i < extra; i++)
-			rec.u.nocycle.extra_u32[i] = va_arg(*args, u32);
+			rec.u.notimestamp.extra_u32[i] = va_arg(*args, u32);
 	}
 
-	size = calc_rec_size(p->cycle_in, extra * sizeof(u32));
+	size = calc_rec_size(p->timestamp_in, extra * sizeof(u32));
 	relay_write(kt->rchan, &rec, size);
 }
 

  parent reply	other threads:[~2008-07-14 12:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 11:59 [PATCH 0/8] kvmtrace: powerpc support and timestamps for KVM_TRACE v3 ehrhardt
2008-07-14 12:00 ` [PATCH 1/8] kvmtrace: Remove use of bit fields in kvm trace structure v3 ehrhardt
2008-07-14 12:00 ` ehrhardt [this message]
2008-07-14 12:00 ` [PATCH 3/8] kvmppc: kvmtrace: enable KVM_TRACE building for powerpc ehrhardt
2008-07-14 12:00 ` [PATCH 4/8] kvmppc: kvmtrace: adds trace points for ppc tlb activity v2 ehrhardt
2008-07-14 12:00 ` [PATCH 5/8] kvmppc: kvmtrace: trace powerpc instruction emulation ehrhardt
2008-07-14 12:00 ` [PATCH 6/8] kvm-userspace: kvmtrace_format: add ppc " ehrhardt
2008-07-14 12:00 ` [PATCH 7/8] kvm-userspace: kvmtrace_format: add statistic section ehrhardt
2008-07-14 12:00 ` [PATCH 8/8] kvm-userspace: kvmtrace: cycles are now ktime_t timestamps ehrhardt
2008-07-14 13:45 ` [PATCH 0/8] kvmtrace: powerpc support and timestamps for KVM_TRACE v3 Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1216036807-18277-3-git-send-email-ehrhardt@linux.vnet.ibm.com \
    --to=ehrhardt@linux.vnet.ibm.com \
    --cc=avi@qumranet.com \
    --cc=borntraeger@de.ibm.com \
    --cc=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sheng.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox