diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-09-19 10:36:01 -0400 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2012-09-29 15:21:54 -0400 |
commit | e97f65a17deafacc360a4cb75ae944897ecea6d7 (patch) | |
tree | d87d1e779ae91b9a1c0f5fcb9ed0e220bb4dfb72 /kernel | |
parent | e40cfce626a5537994058ee9a940dcfdc0f68ef0 (diff) |
uprobes: Kill set_swbp()->is_swbp_at_addr()
A separate patch for better documentation.
set_swbp()->is_swbp_at_addr() is not needed for correctness, it is
harmless to do the unnecessary __replace_page(old_page, new_page)
when these 2 pages are identical.
And it can not be counted as optimization. mmap/register races are
very unlikely, while in the likely case is_swbp_at_addr() adds the
extra get_user_pages() even if the caller is uprobe_mmap(current->mm)
and returns false.
Note also that the semantics/usage of is_swbp_at_addr() in uprobe.c
is confusing. set_swbp() uses it to detect the case when this insn
was already modified by uprobes, that is why it should always compare
the opcode with UPROBE_SWBP_INSN even if the hardware (like powerpc)
has other trap insns. It doesn't matter if this breakpoint was in fact
installed by gdb or application itself, we are going to "steal" this
breakpoint anyway and execute the original insn from vm_file even if
it no longer matches the memory.
OTOH, handle_swbp()->find_active_uprobe() uses is_swbp_at_addr() to
figure out whether we need to send SIGTRAP or not if we can not find
uprobe, so in this case it should return true for all trap variants,
not only for UPROBE_SWBP_INSN.
This patch removes set_swbp()->is_swbp_at_addr(), the next patches
will remove it from set_orig_insn() which is similar to set_swbp()
in this respect. So the only caller will be handle_swbp() and we
can make its semantics clear.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/uprobes.c | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 8d182bdecc2e..a4453d1c8199 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -321,17 +321,6 @@ out: | |||
321 | */ | 321 | */ |
322 | int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) | 322 | int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) |
323 | { | 323 | { |
324 | int result; | ||
325 | /* | ||
326 | * See the comment near uprobes_hash(). | ||
327 | */ | ||
328 | result = is_swbp_at_addr(mm, vaddr); | ||
329 | if (result == 1) | ||
330 | return 0; | ||
331 | |||
332 | if (result) | ||
333 | return result; | ||
334 | |||
335 | return write_opcode(auprobe, mm, vaddr, UPROBE_SWBP_INSN); | 324 | return write_opcode(auprobe, mm, vaddr, UPROBE_SWBP_INSN); |
336 | } | 325 | } |
337 | 326 | ||