Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c00b2750 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar
Browse files

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: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarSrikar 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: default avatarIngo Molnar <mingo@kernel.org>
parent 436d03fa
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -333,10 +333,20 @@ static int is_swbp_at_addr(struct mm_struct *mm, unsigned long vaddr)
	uprobe_opcode_t opcode;
	int result;

	if (current->mm == mm) {
		pagefault_disable();
		result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
								sizeof(opcode));
		pagefault_enable();

		if (likely(result == 0))
			goto out;
	}

	result = read_opcode(mm, vaddr, &opcode);
	if (result)
		return result;

out:
	if (is_swbp_insn(&opcode))
		return 1;