Skip to content

Tests for kvmclock

Jason Wang kvm 1 version New

Get series with b4
b4 am 20100831083216.10672.20413.stgit@FreeLancer

Versions newest first

  1. v2 Latest8 patches 0 repliesNew

Changes in v2 from the cover letter

- Change the max cpu to 64 in order to test in larger systems.
- Make the per-cpu structure hv_clock 4 byte aligned.
- Fix the bug of the clobber list in atomic64_cmpxchg().
- Add the test of pure performance test based on guest TSC cycle.
- Record the count of stall when doing monotonic cycle test.
- Introduce some new type definitions.
- Fix the bug of the wallclock calculation and test.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8Introduce some type definiations.lib/libcflat.h+4 -00 replies
2/8Increase max_cpu to 64x86/cstart.S x86/cstart64.S+2 -20 replies
3/8Introduce memory barriers.lib/x86/smp.h+4 -00 replies
4/8Introduce atomic operationsconfig-x86-common.mak lib/x86/atomic.c lib/x86/atomic.h+202 -00 replies
5/8Export tsc related helperslib/x86/processor.h x86/tsc.c x86/vmexit.c+23 -300 replies
6/8Introduce atol()lib/libcflat.h lib/string.c+32 -00 replies
7/8Add a simple kvmclock driverx86/kvmclock.c x86/kvmclock.h+339 -00 replies
8/8Add tests for kvm-clockconfig-x86-common.mak x86/README x86/kvmclock_test.c +1 more+177 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH kvm-unit-tests v2 0/8] Tests for kvmclock

The following series implements three tests for kvmclock:

Wall clock test: check whether the kvmclock could return a correct TOD by pass the correct one to test and check it with the value returned by kvmclock.

Monotonic cycle test: check whether the cycles of kvmclock grows monotonically in smp guests.

Performance test: Measure the performance ( through guest TSC cycles ) of kvmclock driver for both with and without the guest side adjustment.

Change since V1:

- Change the max cpu to 64 in order to test in larger systems.
- Make the per-cpu structure hv_clock 4 byte aligned.
- Fix the bug of the clobber list in atomic64_cmpxchg().
- Add the test of pure performance test based on guest TSC cycle.
- Record the count of stall when doing monotonic cycle test.
- Introduce some new type definitions.
- Fix the bug of the wallclock calculation and test.

Here is a test result I got form a guest with 64 vcpus on a 64 cores intel X7550:

The test command is qemu-system-x86_64 -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -kernel ./x86/kvmclock_test.flat -smp 64 --append 100000

For 64bit guests:
The guest cycles spent on geting raw cycles is about 21543417. The guest cycles spent on geting adjusted cycles is 1067264988.

Which means it takes about 50x more time on correcting the cycles than just returning cycles supplied by hypervisor.

For 32bit guests:
The guest cycles spent on geting raw cycles is about 26916562. The guest cycles spent on geting adjusted cycles is 2020119174.

Which means it taks about 75x more time on correcting the cycles than just returning cycles supplied by hypervisor.

And for 4 core guests: we only take about 10x-15x more time on correcting.

Pay attention:
1 The performance test just read cycle and do not check anything else. 2 I've run the test for serverl times, the result are similar. 3 The cycles were measured from guest, so maybe not accurate.

Here is a sample test results of 64bit guest with 64 vcpus:

......
Check the stability of raw cycle ...
Worst warp -10
Worst warp -6537
Worst warp -11170
Worst warp -11370
Worst warp -11372
Worst warp -31754
Worst warp -31876
Worst warp -31904
Worst warp -36771
Worst warp -37382
Worst warp -37688
Worst warp -37707

Total vcpus: 64
Test  loops: 100000
Total warps:  53811
Total stalls: 408
Worst warp:   -37707
Raw cycle is not stable
Monotonic cycle test:
Total vcpus: 64
Test  loops: 100000
Total warps:  0
Total stalls: 214
Worst warp:   0
Measure the performance of raw cycle ...
Total vcpus: 64
Test  loops: 100000
TSC cycles:  21543417
Measure the performance of adjusted cycle ...
Total vcpus: 64
Test  loops: 100000
TSC cycles:  1067264988

---

Jason Wang (8):
Introduce some type definiations.
Increase max_cpu to 64
Introduce memory barriers.
Introduce atomic operations
Export tsc related helpers
Introduce atol()
Add a simple kvmclock driver
Add tests for kvm-clock

 config-x86-common.mak |    7 +
 lib/libcflat.h        |    5 +
 lib/string.c          |   31 +++++
 lib/x86/atomic.c      |   37 ++++++
 lib/x86/atomic.h      |  164 +++++++++++++++++++++++++++++
 lib/x86/processor.h   |   22 ++++
 lib/x86/smp.h         |    4 +
 x86/README            |    1 
 x86/cstart.S          |    2 
 x86/cstart64.S        |    2 
 x86/kvmclock.c        |  279 +++++++++++++++++++++++++++++++++++++++++++++++++
 x86/kvmclock.h        |   60 +++++++++++
 x86/kvmclock_test.c   |  166 +++++++++++++++++++++++++++++
 x86/tsc.c             |   16 ---
 x86/unittests.cfg     |    5 +
 x86/vmexit.c          |   15 ---
 16 files changed, 783 insertions(+), 33 deletions(-)
 create mode 100644 lib/x86/atomic.c
 create mode 100644 lib/x86/atomic.h
 create mode 100644 x86/kvmclock.c
 create mode 100644 x86/kvmclock.h
 create mode 100644 x86/kvmclock_test.c
Signature · 1 line
Jason Wang