public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <christoffer.dall@linaro.org>
To: Yury Norov <ynorov@caviumnetworks.com>
Cc: "Goutham, Sunil" <Sunil.Goutham@cavium.com>,
	kvm@vger.kernel.org, marc.zyngier@arm.com, "Cherian,
	Linu" <Linu.Cherian@cavium.com>,
	pbonzini@redhat.com, kvmarm@lists.cs.columbia.edu,
	Shih-Wei Li <shihwei@cs.columbia.edu>
Subject: Re: [kvm-unit-tests PATCH] arm64: add micro test
Date: Tue, 19 Dec 2017 14:04:36 +0100	[thread overview]
Message-ID: <20171219130436.GC31048@cbox> (raw)
In-Reply-To: <20171219100521.oqnqlxhooe3jjlxb@yury-thinkpad>

On Tue, Dec 19, 2017 at 01:05:21PM +0300, Yury Norov wrote:
> On Tue, Dec 19, 2017 at 10:12:00AM +0100, Christoffer Dall wrote:
> > On Mon, Dec 18, 2017 at 08:31:21PM +0300, Yury Norov wrote:
> > > On Fri, Dec 15, 2017 at 04:15:39PM -0500, Shih-Wei Li wrote:
> > > > Here we provide the support for measuring various micro level
> > > > operations on arm64. We iterate each of the tests for millions of
> > > > times and output their average, minimum and maximum cost in timer
> > > > counts. Instruction barriers are used before and after taking
> > > > timestamps to avoid out-of-order execution or pipelining from
> > > > skewing our measurements.
> > > > 
> > > > The tests we currently support and measure are mostly
> > > > straightforward by the function names and the respective comments.
> > > > For IPI test, we measure the cost of sending IPI from a source
> > > > VCPU to a target VCPU, until the target VCPU receives the IPI.
> > > > 
> > > > Signed-off-by: Shih-Wei Li <shihwei@cs.columbia.edu>
> > > > ---
> > > >  arm/Makefile.common |   1 +
> > > >  arm/micro-test.c    | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >  arm/unittests.cfg   |   6 ++
> > > >  3 files changed, 296 insertions(+)
> > > >  create mode 100644 arm/micro-test.c
> > > > 
> > > > diff --git a/arm/Makefile.common b/arm/Makefile.common
> > > > index 0a039cf..c7d5c27 100644
> > > > --- a/arm/Makefile.common
> > > > +++ b/arm/Makefile.common
> > > > @@ -16,6 +16,7 @@ tests-common += $(TEST_DIR)/pmu.flat
> > > >  tests-common += $(TEST_DIR)/gic.flat
> > > >  tests-common += $(TEST_DIR)/psci.flat
> > > >  tests-common += $(TEST_DIR)/sieve.flat
> > > > +tests-common += $(TEST_DIR)/micro-test.flat
> > > >  
> > > >  tests-all = $(tests-common) $(tests)
> > > >  all: directories $(tests-all)
> > > > diff --git a/arm/micro-test.c b/arm/micro-test.c
> > > > new file mode 100644
> > > > index 0000000..7df2272
> > > > --- /dev/null
> > > > +++ b/arm/micro-test.c
> > > > @@ -0,0 +1,289 @@
> > > > +#include <util.h>
> > > > +#include <asm/gic.h>
> > > > +
> > > > +static volatile bool second_cpu_up;
> > > > +static volatile bool first_cpu_ack;
> > > > +static volatile bool ipi_acked;
> > > > +static volatile bool ipi_received;
> > > > +static volatile bool ipi_ready;
> > > > +#define IPI_IRQ		1
> > > > +
> > > > +#define TIMEOUT (1U << 28)
> > > > +
> > > > +#define ARR_SIZE(_x) ((int)(sizeof(_x) / sizeof(_x[0])))
> > > > +#define for_each_test(_iter, _tests, _tmp) \
> > > > +	for (_tmp = 0, _iter = _tests; \
> > > > +			_tmp < ARR_SIZE(_tests); \
> > > > +			_tmp++, _iter++)
> > > > +
> > > > +#define CYCLE_COUNT(c1, c2) \
> > > > +	(((c1) > (c2) || ((c1) == (c2))) ? 0 : (c2) - (c1))
> > > 
> > > Is my understanding correct that this is overflow protection?
> > > c1 and c2 are 64-bit values. To overflow them you need 58 years
> > > at 1G CPU freq.
> > > 
> > 
> > That's assuming your cycle counter starts at 0, and that nobody
> > programmed it near the overflow value to get an overflow interrupt.
> > 
> > So if you get rid of this, you have to make sure the host never plays
> > with the cycle counter behind your back, and that you've initialized it
> > to zero.
> 
> Ah, now I understand it. But if there's no evil intention to break the
> test, there's single chance to overflow in 584 years. And if it happened,
> isn't it simpler to run test again? 

I believe we used this to throw away results where there was an
overflow, which is nicer to the user than leaving them guessing 'this is
a very high number, I better run the test again'.

-Christoffer

  reply	other threads:[~2017-12-19 13:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15 21:15 [kvm-unit-tests PATCH] Support micro operation measurement on arm64 Shih-Wei Li
2017-12-15 21:15 ` [kvm-unit-tests PATCH] arm64: add micro test Shih-Wei Li
2017-12-18 17:31   ` Yury Norov
2017-12-18 21:32     ` Shih-Wei Li
2017-12-19  9:12     ` Christoffer Dall
2017-12-19 10:05       ` Yury Norov
2017-12-19 13:04         ` Christoffer Dall [this message]
2017-12-18 19:10   ` Andrew Jones
2017-12-18 21:58     ` Shih-Wei Li
2017-12-19 12:00       ` Andrew Jones
2017-12-20 17:00     ` Andrew Jones
2018-05-01 14:57       ` Kalra, Ashish
2018-05-02  9:23         ` Marc Zyngier
2018-05-03 11:12           ` Kalra, Ashish
2018-05-03 16:24             ` Marc Zyngier
2018-05-03 18:08               ` Kalra, Ashish
2017-12-18 22:17   ` Kalra, Ashish
2017-12-18 22:18   ` Kalra, Ashish
2017-12-18 22:31   ` Kalra, Ashish
2017-12-18 18:14 ` [kvm-unit-tests PATCH] Support micro operation measurement on arm64 Andrew Jones
2017-12-18 20:58   ` Shih-Wei Li
2017-12-19  9:06     ` Christoffer Dall
2017-12-19 12:11       ` Andrew Jones
2017-12-19 13:07         ` Christoffer Dall
2017-12-20 16:22           ` Andrew Jones
2017-12-21 11:31             ` Christoffer Dall
2017-12-21 14:32               ` Andrew Jones

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=20171219130436.GC31048@cbox \
    --to=christoffer.dall@linaro.org \
    --cc=Linu.Cherian@cavium.com \
    --cc=Sunil.Goutham@cavium.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=shihwei@cs.columbia.edu \
    --cc=ynorov@caviumnetworks.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