Xen Profiling: oprofile and perf: Difference between revisions

From Xen
Jump to navigationJump to search
No edit summary
Line 34: Line 34:
They are now at:
They are now at:


git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/oprofile.v1
: git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/oprofile.v1


I plan to tinker a bit with them so they aren't completly
I plan to tinker a bit with them so they aren't completely hacked in with <code><nowiki>#ifdef CONFIG_XEN</nowiki></code> but I do not have any plans to upstream them.
#ifdef CONFIG_XEN but I do not have any plans to upstream them.
I think the right direction is to make a new shiny perf driver.
I think the right direction is to make a new shiny perf driver.


Line 44: Line 43:


* Get the latest kernel from Linus's tree. Merge the above mentioned git branch
* Get the latest kernel from Linus's tree. Merge the above mentioned git branch
* Install oprofile. If you are using Fedora 17, the oprofile RPM already has the Xen enablement patches thanks to William Cohen (see [http://lists.xen.org/archives/html/xen-devel/2011-11/msg02181.html]). If you are using a different distro, get oprofile and apply the patch mentioned in the [http://www.flyn.org/patches/linux-xen-passive-oprofile/linux-3.0-xen-passive-oprofile.patch.gz URL].
* Install oprofile. If you are using Fedora 17, the oprofile RPM already
has the Xen enablement patches thanks to William Cohen
(see [http://lists.xen.org/archives/html/xen-devel/2011-11/msg02181.html]).
If you are using a different distro, get oprofile and apply the
patch mentioned in the [http://www.flyn.org/patches/linux-xen-passive-oprofile/linux-3.0-xen-passive-oprofile.patch.gz URL].


* Run it. This is what I've been doing:
* Run it. This is what I've been doing:
Line 60: Line 55:
must contain this "magic":
must contain this "magic":


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


for HVM guests. For PV guests the data shows up just fine.
for HVM guests. For PV guests the data shows up just fine.



[[Category:Xen]]
[[Category:Xen]]

Revision as of 09:41, 24 March 2013

By Konrad Rzeszutek Wilk from [1]

Summary

I've been toying with some perf tools using the v3.5 kernel to get an idea of what is working and what not. The executive summary is that we should write a perf driver to interact with perf Linux subsystem; and also to enhance the perf library to support the --xen extensions (similar to how the --kvm exists). It might also require adding some new hypercalls, though the existing ones (the oprofile variant) could be retooled to use with perf.

perf

What currently exists are two ways of collecting performance data in both dom0 and domU (and by that I also mean PVHVM). The easiest one is the 'perf' toolkit which works nicely - except that it is using a timer mode - so not very accurate. However, if Xen is booted with 'vpmu=1' parameter and perf is used within a PVHVM guest - the data is much more accurate. So what would be good is to implement a non-timer variant (so some model of APIC emulation combined with collecting data in a oprofile ring and avoiding MSRs).

oprofile

The good news is that the old performance system oprofile works with the non-timer variant with some patches. You could also run the oprofile in timer mode and get the same data that the 'perf' does. The patches for the oprofile have been in the past posted by Michael Petullo, and I created a git branch with them with some little changes (basically to make them work with the new kernel - they are still buggy though - rmmoding caused a crash). They are now at:

git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/oprofile.v1

I plan to tinker a bit with them so they aren't completely hacked in with #ifdef CONFIG_XEN but I do not have any plans to upstream them. I think the right direction is to make a new shiny perf driver.

Anyhow, if you want to play and get some performance data, the steps are:

  • Get the latest kernel from Linus's tree. Merge the above mentioned git branch
  • Install oprofile. If you are using Fedora 17, the oprofile RPM already has the Xen enablement patches thanks to William Cohen (see [2]). If you are using a different distro, get oprofile and apply the patch mentioned in the URL.
  • Run it. This is what I've been doing:
 opcontrol --start --passive-domains=2,3 
 --passive-images=/mnt/lab/nettest/vmlinux-pvhvm,/mnt/lab/nettest/vmlinux-pvhvm 
 --xen=/data/xen-syms --vmlinux=/data/vmlinux --callgraph=5

A co-worker mentioned that to get the exact data from the guest (which is not what I was using it for), your guest config file must contain this "magic":

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

for HVM guests. For PV guests the data shows up just fine.