[QUESTION] Is it safe to use lock in systemtap tapset?

Frank Ch. Eigler fche@redhat.com
Fri Nov 16 21:25:00 GMT 2018


spacewanderlzx wrote:

> I am searching for some information about lock usage in the systemtap
> tapset.

The general advice is to avoid explicit locking in embedded-C functions,
since they may in principle run in any context, including atomic.  I am
not sure how explicitly we spell this out in [man stap] or
tapset/DEVGUIDE.


> Is it safe to use lock in systemtap tapset?
> Maybe the answer is different for tapset used in different context
> (timers, kernel.function, process.function, etc.)?
> Which kind of lock should I use in the tapset?

It depends on the shared resource you are concerned about, in what
probe/context you want to access them, whether you want to read or
write, and whether you can tolerate corrupt data or not.

Note: systemtap's own script-level global variables (and hidden runtime
state) are all already protected automatically.  There's no need to
initialize or worry about locking them.  (This is a unique feature in
systemtap, in contrast to almost every other tracing/probing system.)


- FChE



More information about the Systemtap mailing list