Re: [PATCH -tip v5 03/10] kprobes: Introduce kprobes jump optimization

Frederic Weisbecker
2009-11-24T03:31:35Z

On Tue, Nov 24, 2009 at 03:44:19AM +0100, Frederic Weisbecker wrote:
> On Mon, Nov 23, 2009 at 06:21:41PM -0500, Masami Hiramatsu wrote:
> > +static void kprobe_optimizer(struct work_struct *work);
> > +static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
> > +#define OPTIMIZE_DELAY 5
> > +
> > +/* Kprobe jump optimizer */
> > +static __kprobes void kprobe_optimizer(struct work_struct *work)
> > +{
> > + struct optimized_kprobe *op, *tmp;
> > +
> > + /* Lock modules while optimizing kprobes */
> > + mutex_lock(&module_mutex);
> > + mutex_lock(&kprobe_mutex);
> > + if (kprobes_all_disarmed)
> > + goto end;
> > +
> > + /* Wait quiesence period for ensuring all interrupts are done */
> > + synchronize_sched();
>
>
>
> It's not clear to me why you are doing that.
> Is this waiting for pending int 3 kprobes handlers
> to complete? If so, why, and what does that prevent?

I _might_ have understood.
You have set up the optimized flags, then you wait for
any old-style int 3 kprobes to complete and route
to detour buffer so that you can patch the jump
safely in the dead code? (and finish with first byte
by patching the int 3 itself)