~ubuntu-branches/ubuntu/hardy/kvm/hardy-backports

« back to all changes in this revision

Viewing changes to user/test/vmexit.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-11-15 02:21:55 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20071115022155-pxoxb8kfcrkn72mi
Tags: 1:52+dfsg-0ubuntu1
* New upstream release.
* 08_default_tdf.patch
  - Make -tdf the default and add a -no-tdf option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include "printf.h"
3
 
 
4
 
static inline unsigned long long rdtsc()
5
 
{
6
 
        long long r;
7
 
 
8
 
#ifdef __x86_64__
9
 
        unsigned a, d;
10
 
 
11
 
        asm volatile ("rdtsc" : "=a"(a), "=d"(d));
12
 
        r = a | ((long long)d << 32);
13
 
#else
14
 
        asm volatile ("rdtsc" : "=A"(r));
15
 
#endif
16
 
        return r;
17
 
}
18
 
 
19
 
#define N (1 << 22)
20
 
 
21
 
int main()
22
 
{
23
 
        int i;
24
 
        unsigned long long t1, t2;
25
 
 
26
 
        t1 = rdtsc();
27
 
        for (i = 0; i < N; ++i)
28
 
                asm volatile ("cpuid" : : : "eax", "ebx", "ecx", "edx");
29
 
        t2 = rdtsc();
30
 
        printf("vmexit latency: %d\n", (int)((t2 - t1) / N));
31
 
        return 0;
32
 
}