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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Zexuan Luo
Hi,
I am searching for some information about lock usage in the systemtap tapset.
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?

Thanks for any reply.
Reply | Threaded
Open this post in threaded view
|

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

Frank Ch. Eigler

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
Reply | Threaded
Open this post in threaded view
|

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

Zexuan Luo
Thank you for your reply!
Frank Ch. Eigler <[hidden email]> 于2018年11月17日周六 上午5:24写道:

>
>
> 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