SystemTap – DTrace for Linux ?

Since DTrace was released for Solaris I am missing it on Linux systems… It can’t be included in Linux by the same reason why ZFS can’t be – it’s licensing issue. Both ZFS and DTrace are under CDDL, which is incompatible with GPL. So you can see DTrace and ZFS on Solaris, FreeBSD, MacOS, but not on Linux.

However I follow the project SystemTap for couple of years (it was started in 2005), which is supposed to provide similar to DTrace functionality.

Why I am interested in this tool, because there is no simple way under Linux to profile not CPU-bound load (for CPU-bound there is OProfile, see for example I.e. for IO-bound or for mutex contention problems OProfile is not that useful.

SystemTap is included in RedHat 5 releases, but I was not able to get it running even in CentOS 5.3 (it crashed and hung every so often). Latest updated RedHat 5.4 promised some more fixes to SystemTap, so I decided to give it more try as soon as I got RedHat 5.4 on hands.

Surprising, but now it runs much more stable. I was able to get profiling of kernel and system calls.
Here is simple script to show IO activity per disk per process (well, it is similar to iotop, but iotop is not available in RedHat / CentOS)

with output like this

This example maybe is simple, but the point is that there is rich scripting language with tons
of probes you can intersect ( kernel functions, FS drivers functions, any other drives and modules)

What else I see very useful in SystemTap it can work in userspace. That is you can use it to profile your and any application that has -debuginfo packages ( all -debuginfo for standard RedHat RPMS you can download from RedHat FTP), but basically it is info you get compiling with


Well, there seems another war story going on. To profile userspace application with SystemTap your kernel should be patches with

patch, which fortunately is included in RedHat based kernels, but not included in vanilla kernel yet. So I am not sure if you can get userspace profiling running in another distributives.

There is quite simple script that I tried to hack around MySQL ®

with output which I get running simple SELECT against InnoDB table:

Again, this case is maybe too simple, but basically you can intersect internal MySQL function and script (measure time, count of call, statistics) what you what. I did not figure out yet how to intersect C++ style function (i.e.

), so there is area to investigate.

So I am going to play with it more and do some useful scripting to get profiling of MySQL.

And it seems SystemTap can re-use DTrace probes available in application, as you may know DTrace-probes were added into MySQL 5.4, so interesting how it works.

I should mention that there is second alternative of DTrace… It’s …. DTrace port. Looking on blog it seems one-man project and currently author is fighting with resolving userspace issues. I gave to this a try, but on my current RedHat 5.4 after several runs I got “Kernel panic”, so it’s enough for now.

Share this post

Comments (17)

  • herodiade

    > there is no simple way under Linux to profile not CPU-bound load
    > […]
    > I.e. for IO-bound or for mutex contention problems OProfile is not that useful.

    True, esp. when emphasing “simple”, and when compared to DTrace.
    But, beside SystemTap a couple of tools migth still give some help here:
    * blktrace , for I/O
    * the very recent “mutrace”, to track mutex contention (see ).

    the point of this comment was to introduce mutrace indeed 😉

    September 15, 2009 at 12:34 am
  • CoolCold

    I’m not really sure (using debian), but it looks like iotop should work now on rhel –

    September 15, 2009 at 1:16 am
  • Jordi Prats

    To get the real name of a C++ function you could use objdump:

    # objdump -t /usr/local/mysql/libexec/mysqld | grep index_read | grep ha_innoba |grep -v index_read_
    08269c80 g F .text 000002a9 _ZN11ha_innobase10index_readEPcPKcj16ha_rkey_function

    Unless it’s stripped:

    # file /usr/local/mysql/libexec/mysqld
    /usr/local/mysql/libexec/mysqld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
    # strip /usr/local/mysql/libexec/mysqld.stip
    # file /usr/local/mysql/libexec/mysqld.stip
    /usr/local/mysql/libexec/mysqld.stip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
    # objdump -t /usr/local/mysql/libexec/mysqld.stip

    /usr/local/mysql/libexec/mysqld.stip: file format elf32-i386

    no symbols

    September 30, 2009 at 7:26 am
  • otoburb

    DTrace for Linux looks like it’s being worked on here:

    October 6, 2009 at 6:59 am
  • Vadim


    I mention that in the post. It caused kernel panic when I tried it.

    October 6, 2009 at 9:13 am
  • popgo

    Linux port of DTrace
    June 2009
    Paul D. Fox

    Blog – latest news and stuff about the dtrace project:
    Download dtrace tarballs for linux here:

    December 17, 2009 at 2:10 am
  • Vadim


    I mentioned that tool at the end of post.
    Unfortunately when I tried it I got crashed server with Kernel panic error,
    so I would wait sometime before trying it in production.

    December 17, 2009 at 10:12 pm
  • Tony

    how did you get this working on Centos?

    May 25, 2010 at 6:05 pm
  • Vadim


    Centos 5.5 comes with stable 1.1 release of systemtap

    May 25, 2010 at 6:41 pm
  • Tony

    Okay, but how did you get mysql compiled with systemtap support?

    May 25, 2010 at 6:48 pm
  • Vadim


    You need only debug symbols to have that working. It is true for any package not only mysql.
    You can get debug symbols if you compile with CFLASG=”-g” CXXFLAGS=”-g”. Or alternative – there
    are available debug symbols packages almost for any software in CentOS distribution.

    May 25, 2010 at 8:53 pm
  • Tony

    I see, well i quick “yum search mysql” yields no debug packages.. is there a repo i need to enable?

    May 25, 2010 at 9:01 pm
  • Vadim


    You should install appropriate RPM from manually .

    May 25, 2010 at 9:48 pm
  • Tony

    Ah cool, thanks for the quick replies, this site looks like a great resource for mysql tips – *bookmarks*

    May 25, 2010 at 9:51 pm
  • Anto

    if I/O is your concern, you could look into blktrace and related tools

    the blkiomon command (part of the same package) seems very useful in particular, example:

    # blktrace /dev/sda -a issue -a complete -w 60 -o – | blkiomon -I 4 -h –

    December 21, 2010 at 3:47 pm
  • Bob Gu

    While I am was doing some test with SystemTap, I noticed two problems. Not sure, if there is anyone else ran into the same problems.

    1. The client session will be disconnected (MySQL server has gone away) after the SystemTap script is started or terminated.
    test@localhost [(none)]>select now();
    | now() |
    | 2011-07-27 19:58:39 |
    1 row in set (0.00 sec)

    test@localhost [(none)]>select now();
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect…
    Connection id: