Re: [PATCH] tracing/profile: Fix profile_disable vs module_unload

From: Steven Rostedt
Date: Thu Aug 27 2009 - 12:03:49 EST

On Thu, 27 Aug 2009, Mathieu Desnoyers wrote:
> >
> > For this race to occur, the probe (code that hooks to the tracepoint) must
> > be in module that does not contain the tracepoint. We don't even need more
> > than one module, this could occur even with a core tracepoint. If a module
> > registers it, if it unregisters before unloading, the tracepoint may be
> > hit before the unregister and executing while the module is unloading.
> >
> > I don't think we need to worry about this with the case of TRACE_EVENT and
> > ftrace.h. The reason is that the trace point and probes are always in the
> > same location. The MACROS set up the probe code with the modules. Thus, to
> > remove the module, you must also remove the tracepoint itself along with
> > the probe. If you can be executing in the probe, then you must have hit
> > the trace point. If you hit the trace point, then you are executing code
> > inside the module you are removing, which is a bug in the module code
> > itself.
> >
> > Using the ftrace.h MACROS limits the use of tracepoints and this race
> > does not exist. I feel we are safe not needing to have the
> > tracepoint_synchronize_unregister within the ftrace.h code.
> >
> Looks right. If you can guarantee that the probe is only called from
> tracepoints located within the same module as the probe, you should be
> safe without tracepoint_synchronize_unregister. It's worth adding a
> comment in ftrace.h explaining that though.

Yeah, I tried to trick the code to see if I can get a probe in another
module than the trace point, and I get nothing but linking errors. I'm
sure if I work hard enough, I may trick it to do so, but if anyone does
that, I'll slap a big fat NAK on it ;-)

OK, I modify my fix to add a comment to this effect.


-- Steve
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at