uprobes: Teach find_active_uprobe() to provide the "is_swbp" info
authorOleg Nesterov <oleg@redhat.com>
Tue, 29 May 2012 19:29:14 +0000 (21:29 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 6 Jun 2012 15:15:24 +0000 (17:15 +0200)
commitd790d34653ab20c74034902f5f0889bba807949a
tree05d475d4e0f22a2ae0815c77eff5fbe2665d8fd8
parent3a9ea0520f38def4a3915b91f82455b749f07d88
uprobes: Teach find_active_uprobe() to provide the "is_swbp" info

A separate patch to simplify the review, and for the
documentation.

The patch adds another "int *is_swbp" argument to
find_active_uprobe(), so far its only caller doesn't use this
info.

With this patch find_active_uprobe() additionally does:

- if find_vma() + ->vm_start check fails, *is_swbp = -EFAULT

- otherwise, if valid_vma() + find_uprobe() fails, it holds
  the result of is_swbp_at_addr(), can be negative too. The
  latter is only possible if we raced with another thread
  which did munmap/etc after we hit this bp.

IOW. If find_active_uprobe(&is_swbp) returns NULL, the caller
can look at is_swbp to figure out whether the current insn is bp
or not, or detect the race with another thread if it is
negative.

Note: I think that performance-wise this change is fine. This
adds is_swbp_at_addr(), but only if we raced with
uprobe_unregister() or if we hit the "normal" int3 but this mm
has uprobes as well. And even in this case the slow
read_opcode() path is very unlikely, this insn recently
triggered do_int3(), __copy_from_user_inatomic() shouldn't fail
in the likely case.

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/20120529192914.GD8057@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/uprobes.c