After installing perf
with the linux-tools-common
package, I still can't use the python/perl scripting abilities.
$ sudo perf script -g python
Python scripting not supported. Install libpython and rebuild perf to enable it.
For example:
# apt-get install python-dev (ubuntu)
# yum install python-devel (Fedora)
etc.
How can I install a perf version with scripting support, in Ubuntu?
Since Raring (13.04),
perf
is built without Python scripting enabled “to avoid a Python build dependency”. This came as a nasty shock to people like me who usedperf
in 12.04 LTS and upgraded to 14.04 LTS. This is documented in thedebian-master/changelog
file in the Ubuntu kernel git repos.In short, if your kernel is 3.8.0-6.11 or later, you are — to use the precise technical terminology — “shit outta luck”: you have to build your own
perf
.If you decide to do this the Ubuntu way, which is actually quite easy, you can google for tutorials with varying levels of detail (e.g. here or here). Once you have reached the stage where you have cloned the Ubuntu kernel
git
repo appropriate to your release and have checked out the tag corresponding to your current kernel (if your current kernel is 3.13.0-48-generic, the tag will be something like3.13.0-48.80
, i.e. with an extra number on the end), you must edit (w.r.t the root of thegit
repo)debian/rules.d/2-binary-arch.mk
and removeNO_LIBPYTHON=1
from one of themake
command-lines (it's used in\#ifdef
checks, so changing it toNO_LIBPYTHON=0
won't work). This clause only appears once, so just search for it and take it out.The distro's
linux-tools-3.x.x-y
package contains the actualperf
binary, which ends up in/usr/lib/linux-tools-3.x.x-y/perf
. This is built withfakeroot debian/rules binary-arch
. This rule (binary-arch
) takes a long time to build (~25 mins on my i7 laptop). If I'd paid more attention, I could probably have picked one that didn't build every kernel variant and module. Suggestions welcome.Assuming that you've made no other changes, once this finishes, the package you want is
linux-tools-3.13.0-48_3.13.0-48.80_amd64.deb
(modulo your kernel version): this is the one with the binary, rather than symlinks or shell wrappers.There may be a couple of other
linux-tools
packages, depending on exactly what you've built,linux-tools-3.13.0-48-generic_3.13.0-48.80_amd64.deb
just contains symlinks and stuff (less likely to be different) andlinux-tools-common_3.13.0-48.80_all.deb
just contains the short genericperf
wrapper script that ends up in/usr/bin
; the latter is built withfakeroot debian/rules binary-indep
.You can install your new Python-capable
perf
withYou can install as much, or as little, of the kernel, kernel modules, other tools packages, etc. as you're comfortable with. In principle, these should all be the same. I just installed the one package and everything seems to work OK: I have my Python-capable
perf
back.Of course, you're going to have to do a lot of this again (from a
git pull
andcheckout
of the new tag onward) next time there's a kernel update. I'll have to keep up with this myself, so I was half-thinking of sticking my .debs into a PPA, but there doesn't seem to be much interest (this question upvoted twice in 3 months).