-1

I just want a information about linux "perf" for virtual environment. I am trying to get perf stat -e cycles "my process", so when i run this command on my VM(which is running on top of Vmware5.1)i got the message like..

/not supported> cycles

  10.498901015 seconds time elapsed

i could under stand there might be a permissions issue or configuration error for VMware hypervisor, can some one point-out those?. Also , i have read about kernel flag "PERF_COUNT_HW_REF_CPU_CYCLES",how should i check whether my kernel has this flag enabled or not? is there any command for this?

3 Answers3

1

Make sure that perf is compiled into your VM's kernel and disable paranoid mode via sysctl kernel.perf_event_paranoid, ie:

# sysctl kernel.perf_event_paranoid=0

Alec Istomin
  • 281
  • 2
  • 7
  • kernel.perf_event_paranoid is already 0 in my VM, how ever i could see this value is 1 in my bare metal linux PC.. also the flag u have mentioned is only for normal user. but i am root user in my VM. can u please tel about "PERF_COUNT_HW_REF_CPU_CYCLES", and how can i check this? – Sakthivel Thandabani Jul 27 '16 at 07:39
  • On CentOS it's easy to check: `grep PERF /boot/config-$(uname -r)` – Alec Istomin Jul 27 '16 at 23:03
1

I am running the following command on VM(not native harware machine which runs linux),so we have to make sure that the hardware PMC visibility to the VM.. then only the counters will be able to read by guest OS.

There is an vPMC option on ESXi5.1 or later versions. once we enable those hyprevisor option for our VM, guest can read the appropriate values from underlying HW architecture. for details chk here.

0

ESXi does not restrict kernel permissions for guest VMs. Since the kernel is unaware of the underlying hypervisor, we do not restrict what statistics you can pull from the kernel.

Whatever is wrong, it's within your guest instance.

Alex Jauch
  • 58
  • 5
  • i am not talking about kernel permoissions, i just asked whether ESXi hyper-visor may have any protection on its VMs, to access the Hardware registers, if so what are those and where can i found(like .vmx file)? – Sakthivel Thandabani Aug 02 '16 at 07:32
  • There is no "permissions" model per se. I just talked to some of the folks on the engineering team and they pointed me to this: https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2030221 Note that you can control which CPU features we light up and how much information we pass along from the physical CPU. Is this what you were looking for? – Alex Jauch Aug 02 '16 at 22:20
  • Thanks, I already aware about the link you provided. i need root permission for ESXi hypervisor to do these changes(even .vmx is per VM only), but i dont have root access to do so. My question is simple, if i run " perf stat -e cycles some_pid" on my real device(RHEL/cent/fedora) , it gives the proper output but same command gives "not supported" in Virtual devices(RHEL/cent).The same results are applicable for my own c code wichc does rdpmc/wrpmc. if i am correctly understand, VMs dont have provision to access HW registers due to some VM/hypervisor settings by default. – Sakthivel Thandabani Aug 03 '16 at 06:25
  • Yes, it sounds like they haven't enabled VPMC in the VMX file. As you say, you cannot do this without access to ESXi. – Alex Jauch Aug 03 '16 at 17:53