Inspecting power states on Debian with turbostat



Turbostat is a utility created by Intel to check your (Intel) CPU's power states. It used to be part of the acpidump package, but not anymore. There are no prebuilt Debian binaries around; Ubuntu still packages it with the linux-tools package, which is linked to the kernel. Since Debian Testing is on kernel 3.14, I went looking for how to build it myself. You can find the source code floating online, but that won't help you much, since it spits out all kinds of errors when you run it through gcc.

Again, Arch comes to the rescue. The AUR package's PKGBUILD reveals it's actually child's play to compile the binary yourself. First, check your kernel version. Debian uses 3.14 for now, and this kernel appears to be a long term release Debian might be sticking with for Jessie. I'm pulling the main 3.14 release tarball, and then the latest point release Debian is running. This way I don't have to pull in a 75 MB tarball every time the kernel gets an update.

$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.tar.xz 
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.14.9.xz 
$ tar xf linux-3.14.tar.xz
$ cd linux-3.14/
$ xzcat ../patch-3.14.9.xz | patch -Np1
$ cd tools/power/x86/powerstat/
$ make

That will get you the turbostat binary. For cleanliness, you can move it to /usr/local/bin/. For the lazy people, I also have the binary available for download.

So, that's really all there's to it. Here's how turbostat's output looks on my server, to give you an idea:

cor CPU    %c0  GHz  TSC SMI    %c1    %c3    %c6    %c7 CTMP PTMP   %pc2   %pc3   %pc6   %pc7  
          0.21 1.62 2.59   0   0.10   0.00  99.69   0.00   29   29   0.18   0.00  99.13   0.00 
  0   0   0.29 1.63 2.59   0   0.13   0.01  99.58   0.00   29   29   0.18   0.00  99.13   0.00
  1   1   0.14 1.60 2.59   0   0.06   0.00  99.80   0.00   29

As you can see, it's neatly going into Package C6.