From: Amos Kong <akong@redhat.com>
To: Lucas Meneghel Rodrigues <lmr@redhat.com>
Cc: autotest@test.kernel.org, glommer@redhat.com, zamsden@redhat.com,
kvm@vger.kernel.org
Subject: Re: [Autotest PATCH] KVM-test: TSC drift test
Date: Fri, 6 May 2011 23:00:23 +0800 [thread overview]
Message-ID: <20110506150023.GA2210@t400> (raw)
In-Reply-To: <BANLkTi=C42nuSR94K4H99YfqMLHZZ5vbCA@mail.gmail.com>
* On Fri, Apr 29, 2011 at 02:42:20AM -0300, Lucas Meneghel Rodrigues wrote:
> On Thu, Apr 21, 2011 at 4:33 AM, Amos Kong <akong@redhat.com> wrote:
> > This case is used to test the drift between host and guest.
> > Use taskset to make tsc program execute in a single cpu.
> > If the drift ratio bigger than 10%, then fail this case.
>
> The calculations of the tsc frequency looks wrong... See comments below.
>
> Also, when Glauber or Zach could take a look into this test it'd be great!
>
> > Signed-off-by: Amos Kong <akong@redhat.com>
> > ---
> > ?client/tests/kvm/deps/get_tsc.c ? ? ? ?| ? 27 ++++++++++
> > ?client/tests/kvm/tests/tsc_drift.py ? ?| ? 88 ++++++++++++++++++++++++++++++++
> > ?client/tests/kvm/tests_base.cfg.sample | ? ?5 ++
> > ?3 files changed, 120 insertions(+), 0 deletions(-)
> > ?create mode 100644 client/tests/kvm/deps/get_tsc.c
> > ?create mode 100644 client/tests/kvm/tests/tsc_drift.py
...
> > + ? ? ? ?delta = tsc2 - tsc1
> > + ? ? ? ?logging.info("Host TSC delta for cpu %s is %s" % (i, delta))
> > + ? ? ? ?if delta < 0:
> > + ? ? ? ? ? ?raise error.TestError("Host TSC for cpu %s warps %s" % (i, delta))
>
> ^ Yeah, I don't think this is expected to warp, but yet, good to check.
>
> > + ? ? ? ?host_freq += delta / ncpu
>
> Now, i really didn't understand the concept behind the tsc frequency.
> So we have a difference between 2 timestamps taken over an arbitrary
> period of time (in this case, looks 30s by default) and divide by the
> number of cpus, however we will repeat this procedure by the same
> amount so:
>
> N * ( d_tsc1/N + d_tsc2/N + d_tsc3/N + ... + d_tscn/N)
^ ?
I call it 'frequency' because the interval is fixed (30 seconds)
1) get a average tsc increment of host cpus in 30s
host_freq = ( d_tsc1/N + d_tsc2/N + d_tsc3/N + ... + d_tscn/N)
= ( d_tsc1 + d_tsc2 + d_tsc3 + ... + d_tscn)/N
2) get tsc increment of each vcpus in 30s
d_tsc_vcpu1
d_tsc_vcpu2
...
d_tsc_vcpuN
3) compare 'd_tsc_vcpu1' with 'host_freq'
ratio = (d_tsc_vcpu1 - host_freq) / host_freq
if ratio larger than 10%, then fail this test.
ratio = (d_tsc_vcpu2 - host_freq) / host_freq
if ratio larger than 10%, then fail this test.
...
Have talked with jason, I'll try to write a kvm-unit test for this testcase.
> This could be simplified to
>
> (d_tsc1 + d_tsc2 + d_tsc3 +.... + d_tscn)
>
> Unless I'm missing something... so
>
> host_freq = sum(d_tsci)
>
> The calculation could be simplified then... And by definition, isn't
> frequency how many times a phenomena occurs (in this case, change of
> timestamp counter) per time? So, don't we have to divide this sum by
> the time the program slept? Also, it looks like the whole logic to get
> the frequencies can be factored to a single function and just call
> that function for guest and host.
next prev parent reply other threads:[~2011-05-06 15:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 7:33 [Autotest PATCH] KVM-test: TSC drift test Amos Kong
2011-04-29 5:42 ` Lucas Meneghel Rodrigues
2011-05-06 15:00 ` Amos Kong [this message]
2011-07-26 18:45 ` [Autotest] " Lucas Meneghel Rodrigues
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=20110506150023.GA2210@t400 \
--to=akong@redhat.com \
--cc=autotest@test.kernel.org \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lmr@redhat.com \
--cc=zamsden@redhat.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;
as well as URLs for NNTP newsgroup(s).