aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-05-29 15:27:44 -0400
committerIngo Molnar <mingo@kernel.org>2012-06-06 11:13:59 -0400
commitc00b275043adc14d668f36266b890f0c53d46640 (patch)
treecdb6db30f3f0d18049079d7a014f6561e056eb06 /kernel/events
parent436d03faf6961b30e13b2d0967aea9d772d6cf44 (diff)
uprobes: Optimize is_swbp_at_addr() for current->mm
Change is_swbp_at_addr() to try to avoid the costly read_opcode() if mm == current->mm, __copy_from_user_inatomic() should succeed in the likely case. Currently this optimization is not important, but we are going to add more is_swbp_at_addr(current->mm) callers. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Anton Arapov <anton@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20120529192744.GA8057@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/uprobes.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 985be4d80fe8..d0f5ec0dcdea 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -333,10 +333,20 @@ static int is_swbp_at_addr(struct mm_struct *mm, unsigned long vaddr)
333 uprobe_opcode_t opcode; 333 uprobe_opcode_t opcode;
334 int result; 334 int result;
335 335
336 if (current->mm == mm) {
337 pagefault_disable();
338 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
339 sizeof(opcode));
340 pagefault_enable();
341
342 if (likely(result == 0))
343 goto out;
344 }
345
336 result = read_opcode(mm, vaddr, &opcode); 346 result = read_opcode(mm, vaddr, &opcode);
337 if (result) 347 if (result)
338 return result; 348 return result;
339 349out:
340 if (is_swbp_insn(&opcode)) 350 if (is_swbp_insn(&opcode))
341 return 1; 351 return 1;
342 352