Re: [PATCH 6/9][RFC] kprobes: Allow probe on ftrace reserved text(but move it)

From: Masami Hiramatsu
Date: Wed May 09 2012 - 04:12:20 EST

(2012/05/09 14:53), Masami Hiramatsu wrote:
> (2012/05/08 22:04), Steven Rostedt wrote:
>> Note, the big difference with using ftrace optimization and normal
>> kprobe jump optimization is that the ftrace one can be used on a preempt
>> kernel. But this code is still under development. I want to get a
>> solution for the current code (this patch set) now. It would be nice if
>> it was ready for 3.5.
> I doubt that we can really do this. If this is possible, I can make
> jump optimization work with preemptive kernel.

Now I'm clear that it can be done only with ftrace-nop.
What I concerned with is out-of-line execution buffer releasing
timing. but with the ftrace-nop, we don't need to do that.

Theoretically, that will be done in following steps;

1. call mcount (w/ push call-site address+5)
2. mcount calls ftrace handlers
3. mcount makes pt_regs on the stack
- on x86-32, regs->cs should be the call-site address+5, since
regs->sp must be the top of original stack.
- on x86-64, it is enough that regs->sp points the top of original
4. mcount store call-site address+5 to %ax
5. mcount calls new-optprobe handler (which returns call-site address+5)
6. mcount restores registers
7. mcount returns to the call-site address+5.

Between 6 and 7, original opt-probe has to do out-of-line execution,
but this ftrace-based one doesn't need to do that. In that case,
we don't need to allocate nor to release out-of-line execution buffer
for this probe.

Thank you!

Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
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