Messages in this thread | | | Subject | Re: [PATCH 1/5] ftrace: Synchronize variable setting with breakpoints | From | Peter Zijlstra <> | Date | Thu, 31 May 2012 13:06:38 +0200 |
| |
On Wed, 2012-05-30 at 21:28 -0400, Steven Rostedt wrote: > From: Steven Rostedt <srostedt@redhat.com> > > When the function tracer starts modifying the code via breakpoints > it sets a variable (modifying_ftrace_code) to inform the breakpoint > handler to call the ftrace int3 code. > > But there's no synchronization between setting this code and the > handler, thus it is possible for the handler to be called on another > CPU before it sees the variable. This will cause a kernel crash as > the int3 handler will not know what to do with it. > > I originally added smp_mb()'s to force the visibility of the variable > but H. Peter Anvin suggested that I just make it atomic.
Uhm,. maybe. atomic_{inc,dec}() implies a full memory barrier on x86, but atomic_read() never has the smp_rmb() required.
Now smp_rmb() is mostly a nop on x86, except for CONFIG_X86_PPRO_FENCE.
So this should mostly work, but yuck.
Also, why does this stuff live in ftrace? I always thought you were going to replace text_poke() so everybody that uses cross-modifying code could profit?
| |