Cette page appartient aux archives web de l'EPFL et n'est plus tenue à jour.
This page belongs to EPFL's web archive and is no longer updated.

Daniel Tralamazza

OProfile + VMware = ?

Recently I had strange problem with OProfile on a VM. OProfile is pretty straightforward, here is an example of operation:


$ opcontrol --event=default

$ opcontrol --vmlinux=/usr/lib/debug/lib/modules/`uname -r`/vmlinux

$ opcontrol --start

(do something, benchmark etc)

$ opcontrol --stop

$ opcontrol --dump

$ opreport -l


You should see a pretty detailed output of where your CPU is spending time.

Back to the problem, running "opcontrol --list-events" gives you all performance counters (events) that the CPU supports. This command works inside a guest OS in vmware (fusion at least) as if it ran on the host OS, great!. Well, unfortunately there is no data coming from them. VMware doesn't support performance counters, and many other special registers for that matter, but it lets you list them anyway. So how can we use oprofile inside vmware ? A: timer interrupt mode.

First unload oprofile kernel module:

$ opcontrol --deinit

Now load it manually but passing an argument:

$ modprobe oprofile timer=1

Now you are good to go !


If opcontrol returns an error "You cannot specify any performance counter events because OProfile is in timer mode", just remove the file ~./oprofile/daemonrc and try again.


NOTE: This was done on a Fedora 10, you should check your distro on how to point to vmlinux.

Posted by Daniel Tralamazza at 16:13
FreeBSD kernel lock profiling

I recently discovered that FreeBSD has a neat way of doing kernel lock profiling. To use it you just need to add a single line in your kernel config script:


Rebuild, install and reboot your new kernel. To check if it's working call sysctl debug.lock, you should see some options. Now try:

> sysctl debug.lock.prof.enable=1

> (launch a program or just wait a few seconds)

> sysctl debug.lock.prof.enable=0

> sysctl debug.lock.prof.stats

The stats include: file:line and lock type, maximum time held, total time held, total wait time, count, average time held, average wait time, contention while holding, contention while locking

Posted by Daniel Tralamazza at 15:38
Lock profiling #1

My current research involves locking primitives profiling (e.g. mutex, conditional var, etc).

I search the internet almost everyday for profiling tools and papers, but sometimes I forget to search my own machine.

Today I "discovered" that my everyday macbook can lock profiling with one simple command:

tralamazza$ sudo plockstat -n 5 -A -s 8 -e 10 -p <app pid here>

This simple tool plockstat is implemented using DTrace (long live Leopard) and it can display lock contention/wait time along with backtrace for any application.

Even better you can instruct plockstat to show the generated DTrace script so you can customize it.

Not bad at all.

Posted by Daniel Tralamazza at 5:10