From: Chuck Ebbert <76306.1226@compuserve.com> Fix and clean up kretprobe-kretprobe-booster by: - Not reserving 8 bytes at stack bottom - Making trampoline_handler fastcall and calling it directly - Using "iret" to return to original caller Using "iret" is slightly slower than direct return; time went from 1030 CPU cycles overhead per kretprobe to 1050 cycles (2%), but the code is cleaner. Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Cc: Masami Hiramatsu Cc: Prasanna S Panchamukhi Cc: Ananth N Mavinakayanahalli Cc: Anil S Keshavamurthy Cc: David S. Miller Signed-off-by: Andrew Morton --- arch/i386/kernel/kprobes.c | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-) diff -puN arch/i386/kernel/kprobes.c~kretprobe-kretprobe-booster-fixes arch/i386/kernel/kprobes.c --- 25/arch/i386/kernel/kprobes.c~kretprobe-kretprobe-booster-fixes Tue Feb 7 16:00:36 2006 +++ 25-akpm/arch/i386/kernel/kprobes.c Tue Feb 7 16:00:36 2006 @@ -325,9 +325,10 @@ no_kprobe: { asm volatile ( ".global kretprobe_trampoline\n" "kretprobe_trampoline: \n" - " subl $8, %esp\n" " pushf\n" - " subl $20, %esp\n" + " pushl %cs\n" + /* skip eip, orig_eax, es, ds */ + " subl $16, %esp\n" " pushl %eax\n" " pushl %ebp\n" " pushl %edi\n" @@ -336,13 +337,9 @@ no_kprobe: " pushl %ecx\n" " pushl %ebx\n" " movl %esp, %eax\n" - " pushl %eax\n" - " addl $60, %eax\n" - " movl %eax, 56(%esp)\n" - " movl $trampoline_handler, %eax\n" - " call *%eax\n" - " addl $4, %esp\n" - " movl %eax, 56(%esp)\n" + " call trampoline_handler\n" + /* save new eip */ + " movl %eax, 40(%esp)\n" " popl %ebx\n" " popl %ecx\n" " popl %edx\n" @@ -350,16 +347,15 @@ no_kprobe: " popl %edi\n" " popl %ebp\n" " popl %eax\n" - " addl $20, %esp\n" - " popf\n" - " addl $4, %esp\n" - " ret\n"); + /* skip ds, es, orig_eax */ + " addl $12, %esp\n" + " iret\n"); } /* * Called from kretprobe_trampoline */ -asmlinkage void *__kprobes trampoline_handler(struct pt_regs *regs) +fastcall void *__kprobes trampoline_handler(struct pt_regs *regs) { struct kretprobe_instance *ri = NULL; struct hlist_head *head; _