Skip to contentSkip to conversation

Always save/restore performance counters when HVM guest switching VCPU

PATCH Boris Ostrovsky 5 participants 8 messages Mar 8, 2013 – Mar 12, 2013

lore
Share & tools
lore
#0 lore raw
Quoted 29 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

Quoted 8 lines

of

Quoted 3 lines

a whole context switch.

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

Quoted 4 lines

I'm having a hard time telling what PERF is being talked about here -- couldn't this check be fixed on their side, by perhaps checking the CPUID leaf for the existence of Xen?

If by "here" you refer to the problem that Suravee's patch is trying to address then I suspect it's this:
http://lxr.linux.no/#linux+v3.8.2/arch/x86/kernel/cpu/perf_event.c#L210

Quoted 3 lines

If not I think a "lazy vpmu activation" is going to be the only option.

Yes, I actually was going to look at that.

-boris

#1 lore raw
Quoted 31 lines · Boris Ostrovsky
Quoted 29 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

Quoted 8 lines
Quoted 7 lines

of

Quoted 3 lines

a whole context switch.

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

Hmm -- well if it is the case that adding performance counters to the vcpu context switch path will add a measurable overhead, then we probably don't want them enabled for typical guests anyway. If people are actually using the performance counters to measure performance, that makes sense; but for watchdogs it seems like Xen should be able to provide something that is useful for a watchdog without the extra overhead of saving and restoring performance counters.

Konrad, any thoughts?

-George

#2 lore raw
Quoted 32 lines · George Dunlap
Quoted 31 lines · Boris Ostrovsky
Quoted 29 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

of

Quoted 3 lines

a whole context switch.

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

And by default it won't work as for Intel you need these flags:

cpuid=['0xa:eax=0x07300403,ebx=0x00000004,ecx=0x00000000,edx=0x00000603' ]

What we get right now when booting PVHVM under Intel is:

[    0.160989] Performance Events: unsupported p6 CPU model 45 no PMU driver, software events only.
[    0.168098] NMI watchdog disabled (cpu0): hardware events not enabled

Unless said above CPUID flag is provided.

Quoted 11 lines

Hmm -- well if it is the case that adding performance counters to the vcpu context switch path will add a measurable overhead, then we probably don't want them enabled for typical guests anyway. If people are actually using the performance counters to measure performance, that makes sense; but for watchdogs it seems like Xen should be able to provide something that is useful for a watchdog without the extra overhead of saving and restoring performance counters.

Konrad, any thoughts?

The other thing is that there is an Xen watchdog. The one that Jan Beulich wrote which should also work under PVHVM:

drivers/watchdog/xen_wdt.c

Quoted 2 lines

-George

#3 lore raw
Quoted 60 lines · Konrad Rzeszutek Wilk
Quoted 32 lines · George Dunlap
Quoted 31 lines · Boris Ostrovsky
Quoted 29 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

of

Quoted 3 lines

a whole context switch.

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

And by default it won't work as for Intel you need these flags:

cpuid=['0xa:eax=0x07300403,ebx=0x00000004,ecx=0x00000000,edx=0x00000603' ]

What we get right now when booting PVHVM under Intel is:

[    0.160989] Performance Events: unsupported p6 CPU model 45 no PMU driver, software events only.
[    0.168098] NMI watchdog disabled (cpu0): hardware events not enabled

Unless said above CPUID flag is provided.

Quoted 9 lines

Hmm -- well if it is the case that adding performance counters to the vcpu context switch path will add a measurable overhead, then we probably don't want them enabled for typical guests anyway. If people are actually using the performance counters to measure performance, that makes sense; but for watchdogs it seems like Xen should be able to provide something that is useful for a watchdog without the extra overhead of saving and restoring performance counters.

Quoted 5 lines
Quoted 1 line

Konrad, any thoughts?

The other thing is that there is an Xen watchdog. The one that Jan Beulich wrote which should also work under PVHVM:

drivers/watchdog/xen_wdt.c

But my main question is: If the Linux perf system successfully detects a vpmu, will it use the Xen watchdog, or will it try to use the vpmu? Do we need to do anything to make sure that when running under Xen, Linux will *not* try to use the vpmu for the watchdog?

-George

#4 lore raw
Quoted 61 lines · George Dunlap
Quoted 60 lines · Konrad Rzeszutek Wilk
Quoted 32 lines · George Dunlap
Quoted 31 lines · Boris Ostrovsky
Quoted 29 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

of

Quoted 3 lines

a whole context switch.

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

And by default it won't work as for Intel you need these flags:

cpuid=['0xa:eax=0x07300403,ebx=0x00000004,ecx=0x00000000,edx=0x00000603' ]

What we get right now when booting PVHVM under Intel is:

[    0.160989] Performance Events: unsupported p6 CPU model 45 no PMU driver, software events only.
[    0.168098] NMI watchdog disabled (cpu0): hardware events not enabled

Unless said above CPUID flag is provided.

Quoted 9 lines

Hmm -- well if it is the case that adding performance counters to the vcpu context switch path will add a measurable overhead, then we probably don't want them enabled for typical guests anyway. If people are actually using the performance counters to measure performance, that makes sense; but for watchdogs it seems like Xen should be able to provide something that is useful for a watchdog without the extra overhead of saving and restoring performance counters.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Konrad, any thoughts?

The other thing is that there is an Xen watchdog. The one that Jan Beulich wrote which should also work under PVHVM:

drivers/watchdog/xen_wdt.c

But my main question is: If the Linux perf system successfully detects a vpmu, will it use the Xen watchdog, or will it try to use the vpmu? Do we need to do anything to make sure that when running under Xen, Linux will *not* try to use the vpmu for the watchdog?

It looks to me that both watchdogs are running. Perf's counter 0 (which is what watchdog uses) is definitely enabled.

-boris

#5 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · George Dunlap

Konrad, any thoughts?

The other thing is that there is an Xen watchdog. The one that Jan Beulich wrote which should also work under PVHVM:

drivers/watchdog/xen_wdt.c

But that's a different kind of watchdog. The perf one is to check CPUs are alive, whereas this driver is a system (VM) wide one.

Jan

#6 lore raw
In reply to Konrad Rzeszutek Wilk

Am Montag 11 März 2013, 10:53:49 schrieb Konrad Rzeszutek Wilk:

Quoted 37 lines · George Dunlap
Quoted 36 lines · Boris Ostrovsky
Quoted 35 lines
Quoted 33 lines · ----- [email protected] wrote:
Quoted 3 lines · Boris Ostrovsky
Quoted 1 line · ----- [email protected] wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.03.13 at 13:42, George Dunlap

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line · wrote:

On Fri, Mar 1, 2013 at 8:49 PM, <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines

From: Suravee Suthikulpanit <[email protected]>

Currently, the performance counter registers are saved/restores when the HVM guest switchs VCPUs only if they are running. However, PERF has one check where it writes the MSR and read

back

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the value to check if the MSR is working. This has shown to

fails

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

the check if the VCPU is moved in between rdmsr and wrmsr and resulting in the values are different.

Many moons ago (circa 2005) when I used performance counters, I

found

Quoted 2 lines

that adding them to the save/restore path added a non-neligible overhead -- something like 5% slow-down. Do you have any reason

to

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

believe this is no longer the case? Have you done any benchmarks before and after?

I was doing some VPMU tracing a couple of weeks ago and by looking

at

Quoted 2 lines

trace timestamps I think I saw about 4000 cycles on VPMU save and ~9000 cycles on restore. Don't remember what it was percentage-wise

of

Quoted 3 lines

a whole context switch.

This was on Intel.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

And by default it won't work as for Intel you need these flags:

cpuid=['0xa:eax=0x07300403,ebx=0x00000004,ecx=0x00000000,edx=0x00000603' ]

This cpuid config variable should not be needed if your cpu is supported in vmx_vpmu_initialise() where you added a lot of processors with your patch. If not supported and you should see a message in the xen logs.

Quoted 5 lines

What we get right now when booting PVHVM under Intel is:

[    0.160989] Performance Events: unsupported p6 CPU model 45 no PMU driver, software events only.
[    0.168098] NMI watchdog disabled (cpu0): hardware events not enabled

Did you add vpmu to the xen boot parameter list?

I installed opensuse-12.2 as a HVM guest with xen-unstable running and the kernel log says:

Mar  7 15:06:18 linux kernel: [    0.183217] CPU0: Intel(R) Core(TM)2 Duo CPU     P8800  @ 2.66GHz stepping 0a
Mar  7 15:06:18 linux kernel: [    0.183980] Performance Events: 4-deep LBR, Core2 events, Intel PMU driver.
Mar  7 15:06:18 linux kernel: [    0.189994] ... version:                2
Mar  7 15:06:18 linux kernel: [    0.189997] ... bit width:              40
Mar  7 15:06:18 linux kernel: [    0.190000] ... generic registers:      2
Mar  7 15:06:18 linux kernel: [    0.190002] ... value mask:             000000ffffffffff
Mar  7 15:06:18 linux kernel: [    0.190005] ... max period:             000000007fffffff
Mar  7 15:06:18 linux kernel: [    0.190008] ... fixed-purpose events:   3
Mar  7 15:06:18 linux kernel: [    0.190011] ... event mask:             0000000700000003
Mar  7 15:06:18 linux kernel: [    0.198203] NMI watchdog: enabled, takes one hw-pmu counter.

When I call perf:

# perf stat ls
acpid             cups      kdm.log        mail.err        news              wtmp            zypper.log
alternatives.log  faillog   krb5           mail.info       ntp               Xorg.0.log
boot.log          firewall  lastlog        mail.warn       pm-powersave.log  Xorg.0.log.old
btmp              hp        localmessages  messages        samba             YaST2
ConsoleKit        journal   mail           NetworkManager  warn              zypp

Performance counter stats for 'ls':

          7.840869 task-clock                #    0.590 CPUs utilized          
                59 context-switches          #    0.008 M/sec                  
                 0 CPU-migrations            #    0.000 K/sec                  
               304 page-faults               #    0.039 M/sec                  
         6,583,834 cycles                    #    0.840 GHz                     [40.38%]
   <not supported> stalled-cycles-frontend 
   <not supported> stalled-cycles-backend  
         2,168,931 instructions              #    0.33  insns per cycle         [73.20%]
           525,628 branches                  #   67.037 M/sec                   [79.06%]
            27,138 branch-misses             #    5.16% of all branches         [83.55%]
       0.013283672 seconds time elapsed

As you can see performance counters are working for instructions, branches and branch-misses.

When I call this command in the dom0 it's a bit different:

# perf stat ls
acpid             journal        messages           wpa_supplicant.log
alternatives.log  kdm.log        NetworkManager     wtmp
boot.log          krb5           news               xen
btmp              lastlog        ntp                Xorg.0.log
ConsoleKit        localmessages  pk_backend_zypp    Xorg.0.log.old
cups              mail           pk_backend_zypp-1  YaST2
faillog           mail.err       pm-powersave.log   zypp
firewall          mail.info      samba              zypper.log
hp                mail.warn      warn               zypper.log-20130307.xz

Performance counter stats for 'ls':

          6.959326 task-clock                #    0.714 CPUs utilized          
                11 context-switches          #    0.002 M/sec                  
                 0 CPU-migrations            #    0.000 K/sec                  
               304 page-faults               #    0.044 M/sec                  

<not supported> cycles
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not supported> instructions
<not supported> branches
<not supported> branch-misses

       0.009746152 seconds time elapsed

This is because the hardware events are not supported in PV.

Dietmar.

Quoted 21 lines

Unless said above CPUID flag is provided.

Quoted 11 lines

Hmm -- well if it is the case that adding performance counters to the vcpu context switch path will add a measurable overhead, then we probably don't want them enabled for typical guests anyway. If people are actually using the performance counters to measure performance, that makes sense; but for watchdogs it seems like Xen should be able to provide something that is useful for a watchdog without the extra overhead of saving and restoring performance counters.

Konrad, any thoughts?

The other thing is that there is an Xen watchdog. The one that Jan Beulich wrote which should also work under PVHVM:

drivers/watchdog/xen_wdt.c

Quoted 2 lines

-George

Signature · 6 lines
Company details: http://ts.fujitsu.com/imprint.html

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#7 lore raw
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

This was on Intel.

That's a really hefty expense to make all users pay on every context switch, on behalf of a random check in a piece of software that only a handful of people are going to be actually using.

I believe Linux uses perf infrastructure to implement the watchdog.

And as mentioned here, this never gets enabled by default b/c to use the perf infrastructure you need 'vpmu=1' on the bootup line.

Quoted 8 lines
Quoted 4 lines

And by default it won't work as for Intel you need these flags:

cpuid=['0xa:eax=0x07300403,ebx=0x00000004,ecx=0x00000000,edx=0x00000603' ]

This cpuid config variable should not be needed if your cpu is supported in vmx_vpmu_initialise() where you added a lot of processors with your patch. If not supported and you should see a message in the xen logs.

Found out that is b/c I was using 'xend'. With that there are some CPUID flags cleared while 'xl' does not do it.

Quoted 8 lines
Quoted 6 lines

What we get right now when booting PVHVM under Intel is:

[    0.160989] Performance Events: unsupported p6 CPU model 45 no PMU driver, software events only.
[    0.168098] NMI watchdog disabled (cpu0): hardware events not enabled

Did you add vpmu to the xen boot parameter list?

Yes.

Quoted 3 lines

I installed opensuse-12.2 as a HVM guest with xen-unstable running and the kernel log says:

With Xen 4.3 and using 'xl' I get it working too. Albeit on that particular box (model 45) I am hitting some weird crashes while on on a lesser SandyBridge (model 44) it works OK. Anyhow that is a different thread.

Quoted 65 lines
Mar  7 15:06:18 linux kernel: [    0.183217] CPU0: Intel(R) Core(TM)2 Duo CPU     P8800  @ 2.66GHz stepping 0a
Mar  7 15:06:18 linux kernel: [    0.183980] Performance Events: 4-deep LBR, Core2 events, Intel PMU driver.
Mar  7 15:06:18 linux kernel: [    0.189994] ... version:                2
Mar  7 15:06:18 linux kernel: [    0.189997] ... bit width:              40
Mar  7 15:06:18 linux kernel: [    0.190000] ... generic registers:      2
Mar  7 15:06:18 linux kernel: [    0.190002] ... value mask:             000000ffffffffff
Mar  7 15:06:18 linux kernel: [    0.190005] ... max period:             000000007fffffff
Mar  7 15:06:18 linux kernel: [    0.190008] ... fixed-purpose events:   3
Mar  7 15:06:18 linux kernel: [    0.190011] ... event mask:             0000000700000003
Mar  7 15:06:18 linux kernel: [    0.198203] NMI watchdog: enabled, takes one hw-pmu counter.

When I call perf:

# perf stat ls
acpid             cups      kdm.log        mail.err        news              wtmp            zypper.log
alternatives.log  faillog   krb5           mail.info       ntp               Xorg.0.log
boot.log          firewall  lastlog        mail.warn       pm-powersave.log  Xorg.0.log.old
btmp              hp        localmessages  messages        samba             YaST2
ConsoleKit        journal   mail           NetworkManager  warn              zypp

Performance counter stats for 'ls':

          7.840869 task-clock                #    0.590 CPUs utilized          
                59 context-switches          #    0.008 M/sec                  
                 0 CPU-migrations            #    0.000 K/sec                  
               304 page-faults               #    0.039 M/sec                  
         6,583,834 cycles                    #    0.840 GHz                     [40.38%]
   <not supported> stalled-cycles-frontend 
   <not supported> stalled-cycles-backend  
         2,168,931 instructions              #    0.33  insns per cycle         [73.20%]
           525,628 branches                  #   67.037 M/sec                   [79.06%]
            27,138 branch-misses             #    5.16% of all branches         [83.55%]
       0.013283672 seconds time elapsed

As you can see performance counters are working for instructions, branches and branch-misses.

When I call this command in the dom0 it's a bit different:

# perf stat ls
acpid             journal        messages           wpa_supplicant.log
alternatives.log  kdm.log        NetworkManager     wtmp
boot.log          krb5           news               xen
btmp              lastlog        ntp                Xorg.0.log
ConsoleKit        localmessages  pk_backend_zypp    Xorg.0.log.old
cups              mail           pk_backend_zypp-1  YaST2
faillog           mail.err       pm-powersave.log   zypp
firewall          mail.info      samba              zypper.log
hp                mail.warn      warn               zypper.log-20130307.xz

Performance counter stats for 'ls':

          6.959326 task-clock                #    0.714 CPUs utilized          
                11 context-switches          #    0.002 M/sec                  
                 0 CPU-migrations            #    0.000 K/sec                  
               304 page-faults               #    0.044 M/sec                  

<not supported> cycles
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not supported> instructions
<not supported> branches
<not supported> branch-misses

Quoted 3 lines
       0.009746152 seconds time elapsed

This is because the hardware events are not supported in PV.

Right.