From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
To: Hollis Blanchard <hollisb@us.ibm.com>,
cotte@de.ibm.com, xiantao.zhang@intel.com
Cc: kvm@vger.kernel.org, avi@qumranet.com, kvm-ppc@vger.kernel.org,
eric.e.liu@intel.com
Subject: Re: [PATCH 2/5] kvmtrace: make cycle calculation architecture aware
Date: Wed, 09 Jul 2008 11:17:19 +0200 [thread overview]
Message-ID: <4874821F.4060509@linux.vnet.ibm.com> (raw)
In-Reply-To: <1215448660.11175.15.camel@localhost.localdomain>
Hollis Blanchard wrote:
> On Mon, 2008-07-07 at 15:56 +0200, ehrhardt@linux.vnet.ibm.com wrote:
>
>> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>>
>> The current implementation of kvmtrace uses always a 64 bit cycle variable,
>> but get_cycles() which is used to fill it is "unsigned long" which might be 32
>> bit.
>> This reduces the accuracy e.g. on embedded powerpc since we would have a 64bit
>> value but get_cycle() only returns the low 32 bit.
>> To solve that this patch introduces kvm_arch_trace_cycles() which allows us
>> to make this calculation architecture aware. That way every architecture can
>> insert whatever fits best for their "kvmtrace cycle counter".
>>
>> Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>>
>
> "cycles" is a very poor name, because that's not really what we're
> talking about at all. (Also, that function name made me wonder what a
> "trace cycle" is. :)
>
> I would strongly prefer using "timestamp" instead. It would be nice if
> we could rename the data structure too, but I'd settle for only properly
> naming the new architecture function hook.
>
> In fact, if we want to be rigorous about it, it should really be
> something like "nanoseconds" instead, so that userspace wouldn't need to
> perform awkward conversions of "cycles" or "timebase ticks" to real
> time. It looks like getnstimeofday() would do the trick, and that way we
> wouldn't need an arch-specific hook at all
I agree that the naming is poor. I also wondered about it and just
continued it to the kvm_arch function.
I'll change the naming - timestamp would be fine, but only if it is
really time and not a cycle counter.
I experimented with the tv_nsec portion and the classic current_time and
accuracy there was just far to low compared to the time base register
data (5 to 20 instructions until tv.nssec portion changed).
I checked the getnstimeofday function you mentioned and compared
accuracy again and yes that is exactly what I would like to use:
here a ittle example
263527418457 (+ 36696) ns=0x1c43286a
263527740677 (+ 322220) ns=0x1c4a880c (+ 75FA2 = 483234)
263527779757 (+ 39080) ns=0x1c4b6cae (+ E4A2 = 58530)
While the unit is not the same (explains the difference in the same line
e.g. 39080 vs. 58530) the accuracy is the same.
this can be seen due to the fact that it changes by the same ratio all
over the file.
For the example I had above
cycle = 322220/39080 = 8.25
nsec = 483234/58530 = 8.25
That leads me to the point where I completely agree with Hollis that the
naming should be timestamp as well as that the function should rely on
getnstimeofday() instead of get_cycles() and that way would remove the
need kvm_arch_ function.
So the question that is left before changing that is, if the original
author had something special in mind chosing cycles here.
I added Eric on CC for that.
I wait with my resubmission of the patch series until all architectures
agree *hope* on using getnstimeofday() - after an ack from all sides I
would revise my patch series and submit that changes alltogether.
--
Grüsse / regards,
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization
next prev parent reply other threads:[~2008-07-09 9:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 13:56 [PATCH 0/5] kvmtrace: add powerpc support for KVM_TRACE ehrhardt
2008-07-07 13:56 ` [PATCH 1/5] kvmtrace: Remove use of bit fields in kvm trace structure v3 ehrhardt
2008-07-07 13:56 ` [PATCH 2/5] kvmtrace: make cycle calculation architecture aware ehrhardt
2008-07-07 15:45 ` Hollis Blanchard
2008-07-09 8:25 ` Christian Ehrhardt
2008-07-07 16:37 ` Hollis Blanchard
2008-07-09 9:17 ` Christian Ehrhardt [this message]
2008-07-09 15:03 ` Hollis Blanchard
2008-07-10 10:22 ` Yang, Sheng
2008-07-10 10:24 ` Yang, Sheng
2008-07-10 13:32 ` Avi Kivity
2008-07-11 1:06 ` Yang, Sheng
2008-07-11 7:34 ` Carsten Otte
2008-07-11 15:19 ` Hollis Blanchard
2008-07-13 15:41 ` Avi Kivity
2008-07-14 7:44 ` Christian Borntraeger
2008-07-07 13:56 ` [PATCH 3/5] kvmppc: kvmtrace: enable KVM_TRACE building for powerpc ehrhardt
2008-07-07 13:56 ` [PATCH 4/5] kvmppc: kvmtrace: adds trace points for ppc tlb activity v2 ehrhardt
2008-07-07 13:56 ` [PATCH 5/5] kvmppc: kvmtrace: trace powerpc instruction emulation 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=4874821F.4060509@linux.vnet.ibm.com \
--to=ehrhardt@linux.vnet.ibm.com \
--cc=avi@qumranet.com \
--cc=cotte@de.ibm.com \
--cc=eric.e.liu@intel.com \
--cc=hollisb@us.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=xiantao.zhang@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