Tuesday, April 12, 2016

Registering a probe to a kernel module using Systemtap

I was trying to register a probe on a function of a kernel module of mine using Systemtap. The .stp file was fairly simple:
$> cat mymod.stp
probe module("mymodule").function("myfunction") {
  now_time = gettimeofday_ns()
  print(now_time, "\n")
}

When I was trying to register the probe, Systemtap kept failing:
$> sudo stap mymod.stp
semantic error: while resolving probe point: identifier 'module' at mymod.stp:1:7
        source: probe module("mymodule").function("myfunction") {
                      ^

semantic error: no match

Pass 2: analysis failed.  [man error::pass2]

Yet my module was properly loaded:
$> lsmod | grep mymodule
mymodule               40960  0

And the symbol was valid:
$> grep myfunction /proc/kallsyms
0000000000000000 t myfunction    [mymodule]

Turns out you have to actually install the probe under /lib/modules/KERNEL_VERSION for Systemtap to be able to register the probe on it. The final fix:
$> sudo rmmod mymodule
$> sudo install ~/build/mymodule.ko /lib/modules/4.5.0/extra/
$> sudo modprobe mymodule

Be sure to replace 4.5.0 by your current kernel's version:
$> sudo install ~/build/mymodule.ko /lib/modules/`uname -r`/extra/


3 comments:

  1. Can truly relate and retain this outstanding post. Very well written. qemu linux

    ReplyDelete
  2. Panduan Cara Bet 2D Togel Klik4D Online yang tersedia di S128cash. Berhubung permainan togel adalah game legendaris di Indonesia, tahukah kamu kalau game togel sekarang bisa dimainkan secara online ? (Baca Selengkapnya Disini...)

    ReplyDelete
  3. I would like to say that this blog really convinced me to do it! Thanks, very good post.
    해외안전놀이터

    ReplyDelete

Registering a probe to a kernel module using Systemtap

I was trying to register a probe on a function of a kernel module of mine using Systemtap. The .stp file was fairly simple: $> cat mymod...