Some micro-perf tests
Quoted 9 lines · speck for Andrew Cooper
Pre microcode:
* VERW of NUL => 65-69 cycles
* VERW of %ds => 33-37 cyclesPost microcode:
* VERW of NUL => 512-520 cycles
* VERW of %ds => 520-540 cycles
Andrew ��� can you please send me your code? We need to root-cause why the behavior you are seeing is different than our guidance.
Quoted 8 lines · David C
Quoted 6 lines · speck for Andrew Cooper
Pre microcode:
* VERW of NUL => 65-69 cycles
* VERW of %ds => 33-37 cycles
Quoted 5 lines
Quoted 3 lines
Post microcode:
* VERW of NUL => 512-520 cycles
* VERW of %ds => 520-540 cyclesAndrew – can you please send me your code? We need to root-cause why the behavior you are seeing is different than our guidance.
Hello,
The exact code is unlikely to be of direct interest, as it is specific to my Xen Test Framework.
The interesting subset, converted to work in regular userspace is:
andrewcoop@andrewcoop:/tmp/verw$ cat verw.c #include <inttypes.h> #include <stdint.h> #include <stdio.h>
#define barrier() asm volatile ("" ::: "memory")
static unsigned int read_ds(void)
{
unsigned int sel;
asm volatile ("mov %%ds, %0" : "=rm" (sel));
return sel;
}static uint64_t read_time(void)
{
unsigned long low, high;
asm volatile ("rdtscp"
: "=a" (low), "=d" (high) :: "ecx");
return ((uint64_t)high << 32) | low;
}static uint64_t time_sel(unsigned int sel)
{
uint64_t t1, t2;
barrier();
t1 = read_time();
asm volatile ("verw %0" :: "m" (sel));
t2 = read_time();
barrier();
return t2 - t1;
}int main(void)
{
static uint64_t times[2][50];
unsigned int i;
for ( i = 0; i < 50; ++i )
{
unsigned int sel = 0;
times[0][i] = time_sel(sel);
}
for ( i = 0; i < 50; ++i )
{
unsigned int sel = read_ds();
times[1][i] = time_sel(sel);
}
printf(" 0 \t%#4x\n", read_ds());
for ( i = 0; i < 50; ++i )
printf("[%02u] %"PRIu64"\t%"PRIu64"\n",
i, times[0][i], times[1][i]);
return 0;
}To compile,
$gcc -m32 -O3 verw.c -o verw
For 64bit, you need to hardcode a %ds other than 0. 0x2b looks to be the going candidate.
The exact CPU in question is:
[root@idol ~]# head /proc/cpuinfo
processor : 0vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
stepping : 10
microcode : 0x109a
cpu MHz : 3200.000
cache size : 12288 KB
physical id : 0
which is a CoffeeLake part using the alpha ucode drop.
Thanks,
~Andrew
From 15872ecbac1df9fba04b8a1e052b888f4b65eaf2 Mon Sep 17 00:00:00 2001
From: Andrew Cooper <[email protected]>
Date: Thu, 1 Nov 2018 20:21:36 +0000
Subject: [PATCH 1/1] time verw
--- docs/all-tests.dox | 2 + tests/verw/Makefile | 9 +++++ tests/verw/main.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 tests/verw/Makefile create mode 100644 tests/verw/main.c
docs/all-tests.dox +2 -0
@@ -146,3 +146,5 @@ enable BTS. @subpage test-nested-vmx - Nested VT-x tests. */ +# Placeholder: Merge into the appropriate location above +@subpage test-verw - @todo title
tests/verw/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +include $(ROOT)/build/common.mk + +NAME := verw +CATEGORY := utility +TEST-ENVS := pv64 hvm64 + +obj-perenv += main.o + +include $(ROOT)/build/gen.mk
tests/verw/main.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.1.4