public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: ehrhardt@linux.vnet.ibm.com
Cc: kvm@vger.kernel.org, hollisb@us.ibm.com, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 2/9] kvmtrace: replace get_cycles with getnstimeofday
Date: Thu, 10 Jul 2008 18:15:05 +0300	[thread overview]
Message-ID: <48762779.5070703@qumranet.com> (raw)
In-Reply-To: <1215687256-18155-3-git-send-email-ehrhardt@linux.vnet.ibm.com>

ehrhardt@linux.vnet.ibm.com wrote:
> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>
> The current kvmtrace code uses get_cycles() while the interpretation would be
> easier using using nanoseconds. Getnstimeofday should give the same accuracy
> as get_cycles on all architectures but at a better unit (e.g. comparable
> between two hosts with different frequencies.
>
> The implementation of kvmtrace uses a 64 bit cycle variable while get_cycles
> only provided a unsigned long which is != 64 bit on 32 bit architectures.
> Since this patch introduced getnstimeofday we can addtionally merge the
> tv_sec portion of the struct timespec returned to use the full 64 bit
> of the trace interface and therefor avoid some wraparounds. This merge
> is done always if the two values of a struct timespec fit into the u64.
>
> An alternative might be ktime_t instead of u64 and using as Sheng Yang
> suggested and ktime_get(), I had no time to test&compare that yet.
> Any comments or requirements from others what to prefer here ?
>
> Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
> ---
>
> [diffstat]
>  kvm_trace.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> [diff]
>
> 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
> @@ -56,6 +56,7 @@
>  	struct kvm_vcpu *vcpu;
>  	int    i, size;
>  	u32    extra;
> +	struct timespec tv;
>  
>  	if (unlikely(kt->trace_state != KVM_TRACE_STATE_RUNNING))
>  		return;
> @@ -73,7 +74,13 @@
>  			| TRACE_REC_NUM_DATA_ARGS(extra);
>  	
>  	if (p->cycle_in) {
> -		rec.u.cycle.cycle_u64 = get_cycles();
> +		getnstimeofday(&tv);
> +		/* compress both struct tv values into u64 on 32 bit archs */
> +		if (sizeof(tv) == sizeof(u64))
> +			rec.u.cycle.cycle_u64 = 
> +				(((u64)tv.tv_sec) << 32) | tv.tv_nsec;
> +		else
> +			rec.u.cycle.cycle_u64 = tv.tv_nsec;
>  (*args, u32);
>   

Surely, different results on 32-bit and 64-bit aren't what's wanted.  I 
guess ktime_get() is better.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2008-07-10 15:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 10:54 [PATCH 0/5] kvmtrace: powerpc support and timestamps for KVM_TRACE ehrhardt
2008-07-10 10:54 ` [PATCH 1/9] kvmtrace: Remove use of bit fields in kvm trace structure v3 ehrhardt
2008-07-10 10:54 ` [PATCH 2/9] kvmtrace: replace get_cycles with getnstimeofday ehrhardt
2008-07-10 15:15   ` Avi Kivity [this message]
2008-07-10 10:54 ` [PATCH 3/9] kvmtrace: rename cycles to timestamp ehrhardt
2008-07-10 10:54 ` [PATCH 3/9] kvmppc: kvmtrace: enable KVM_TRACE building for powerpc ehrhardt
2008-07-10 10:54 ` [PATCH 4/9] kvmppc: kvmtrace: adds trace points for ppc tlb activity v2 ehrhardt
2008-07-10 10:54 ` [PATCH 5/9] kvmppc: kvmtrace: trace powerpc instruction emulation ehrhardt
2008-07-10 10:54 ` [PATCH 7/9] kvm-userspace: kvmtrace_format: add ppc " ehrhardt
2008-07-10 10:54 ` [PATCH 8/9] kvm-userspace: kvmtrace_format: add statistic section ehrhardt
2008-07-10 10:54 ` [PATCH 9/9] kvm-userspace: kvmtrace: rename cycles to timestamp ehrhardt

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=48762779.5070703@qumranet.com \
    --to=avi@qumranet.com \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /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