Re: [PATCH] LTT for 2.5.38 1/9: Core infrastructure

Karim Yaghmour
2002-09-22T22:33:11Z

Ingo Molnar wrote:
> +int trace_event(u8 pm_event_id,
> + void *pm_event_struct)
> [...]
> + read_lock(&tracer_register_lock);
>
> ie. it's using a global spinlock. (sure, it can be made lockless, as other
> tracers have done it.)

It is, but this is separate from the trace driver. This global
spinlock is only used to avoid a race condition in the registration/
unregistration of the tracing function with the trace infrastructure.
The only case where the lock is taken in write mode is when a
tracer in being registered or unregistered (register_tracer() and
unregister_tracer()). Since tracing itself is NOT registeration/
unregistration intensive, there is no contention over this lock.

Any trace infrastructure that allows dynamic registration of tracers
needs this sort of lock in order to make sure that the function pointer
it has for the tracer is actually valid when it calls it. Of course if
the tracer itself was directly called from the inline trace statements,
then this would be a different story, but then the tracer has to be
in there all the time (which is exactly what happens with most, if
not all, the tracers already included in the kernel).

Karim

===================================================
Karim Yaghmour
karim@opersys.com
Embedded and Real-Time Linux Expert
===================================================