On 07/03, Ravi Bangoria wrote: > > Ok let me explain the difference. > > Current approach: > > ------------ > register_for_each_vma() / uprobe_mmap() > install_breakpoint() > uprobe_write_opcode() { > if (instruction is not already patched) { > /* Gets called only _once_. */ > increment the reference counter; > patch the instruction; > } > } Yes I see. And I am not sure this all is correct. And I still hope we can do something better, I'll write another email. For now, let's discuss your current approach. > Now, if I put it inside install_breakpoint(): > > ------------ > uprobe_register() > register_for_each_vma() > install_breakpoint() { > /* Called _for each consumer_ */ How so? it is not called for each consumer. I think you misread this code. > increment the reference counter _once_; > uprobe_write_opcode() > ... > } So. I meant that you can move the _same_ logic into install_breakpoint() and remove_breakpoint(). And note that ref_ctr_updated in uprobe_write_opcode() is only needed because it can retry the fault. IOW, you can simply do update_ref_ctr(is_register => 1) at the start of install_breakpoint(), and update_ref_ctr(0) in remove_breakpoint(), there are no other callers of uprobe_write_opcode(). To clarify, it is indirectly called by set_swbp() and set_orig_insn(), but this doesn't matter. Or you can kill update_ref_ctr() and (roughly) do rc_vma = find_ref_ctr_vma(...); if (rc_vma) __update_ref_ctr(..., 1); else delayed_uprobe_add(...); at the start of install_breakpoint() and rc_vma = find_ref_ctr_vma(...); if (rc_vma) __update_ref_ctr(..., -1); delayed_uprobe_remove(...); in remove_breakpoint(). > uprobe_mmap() > install_breakpoint() { > increment the reference counter _for each consumer_; Again, I do not understand where do you see the "for each consumer" thing. > uprobe_write_opcode() In short. There is a 1:1 relationship between uprobe_write_opcode(is_register => 1) and install_breakpoint(), and between uprobe_write_opcode(is_register => 0) and remove_breakpoint(). Whatever uprobe_write_opcode() can do if is_register == 1 can be done in install_breakpoint(), the same for is_register == 0 and remove_breakpont(). What have I missed? Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html