diff options
| author | Srikar Dronamraju <srikar@linux.vnet.ibm.com> | 2012-03-12 05:25:30 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2012-03-13 01:22:20 -0400 |
| commit | e3343e6a2819ff5d0dfc4bb5c9fb7f9a4d04da73 (patch) | |
| tree | 4c391fa0cb4408e9fb2e8448c410fc54b9a8abe1 /kernel/events | |
| parent | 900771a483ef28915a48066d7895d8252315607a (diff) | |
uprobes/core: Make order of function parameters consistent across functions
If a function takes struct uprobe or struct arch_uprobe, then it
is passed as the first parameter.
This is pure cleanup, no functional change intended.
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com>
Cc: Linux-mm <linux-mm@kvack.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120312092530.5379.18394.sendpatchset@srdronam.in.ibm.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/events')
| -rw-r--r-- | kernel/events/uprobes.c | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 0d36bf3920ba..9c5ddff1c8da 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
| @@ -192,8 +192,8 @@ bool __weak is_bkpt_insn(uprobe_opcode_t *insn) | |||
| 192 | 192 | ||
| 193 | /* | 193 | /* |
| 194 | * write_opcode - write the opcode at a given virtual address. | 194 | * write_opcode - write the opcode at a given virtual address. |
| 195 | * @auprobe: arch breakpointing information. | ||
| 195 | * @mm: the probed process address space. | 196 | * @mm: the probed process address space. |
| 196 | * @arch_uprobe: the breakpointing information. | ||
| 197 | * @vaddr: the virtual address to store the opcode. | 197 | * @vaddr: the virtual address to store the opcode. |
| 198 | * @opcode: opcode to be written at @vaddr. | 198 | * @opcode: opcode to be written at @vaddr. |
| 199 | * | 199 | * |
| @@ -203,7 +203,7 @@ bool __weak is_bkpt_insn(uprobe_opcode_t *insn) | |||
| 203 | * For mm @mm, write the opcode at @vaddr. | 203 | * For mm @mm, write the opcode at @vaddr. |
| 204 | * Return 0 (success) or a negative errno. | 204 | * Return 0 (success) or a negative errno. |
| 205 | */ | 205 | */ |
| 206 | static int write_opcode(struct mm_struct *mm, struct arch_uprobe *auprobe, | 206 | static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, |
| 207 | unsigned long vaddr, uprobe_opcode_t opcode) | 207 | unsigned long vaddr, uprobe_opcode_t opcode) |
| 208 | { | 208 | { |
| 209 | struct page *old_page, *new_page; | 209 | struct page *old_page, *new_page; |
| @@ -334,14 +334,14 @@ static int is_bkpt_at_addr(struct mm_struct *mm, unsigned long vaddr) | |||
| 334 | 334 | ||
| 335 | /** | 335 | /** |
| 336 | * set_bkpt - store breakpoint at a given address. | 336 | * set_bkpt - store breakpoint at a given address. |
| 337 | * @auprobe: arch specific probepoint information. | ||
| 337 | * @mm: the probed process address space. | 338 | * @mm: the probed process address space. |
| 338 | * @uprobe: the probepoint information. | ||
| 339 | * @vaddr: the virtual address to insert the opcode. | 339 | * @vaddr: the virtual address to insert the opcode. |
| 340 | * | 340 | * |
| 341 | * For mm @mm, store the breakpoint instruction at @vaddr. | 341 | * For mm @mm, store the breakpoint instruction at @vaddr. |
| 342 | * Return 0 (success) or a negative errno. | 342 | * Return 0 (success) or a negative errno. |
| 343 | */ | 343 | */ |
| 344 | int __weak set_bkpt(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr) | 344 | int __weak set_bkpt(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) |
| 345 | { | 345 | { |
| 346 | int result; | 346 | int result; |
| 347 | 347 | ||
| @@ -352,13 +352,13 @@ int __weak set_bkpt(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned | |||
| 352 | if (result) | 352 | if (result) |
| 353 | return result; | 353 | return result; |
| 354 | 354 | ||
| 355 | return write_opcode(mm, auprobe, vaddr, UPROBE_BKPT_INSN); | 355 | return write_opcode(auprobe, mm, vaddr, UPROBE_BKPT_INSN); |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | /** | 358 | /** |
| 359 | * set_orig_insn - Restore the original instruction. | 359 | * set_orig_insn - Restore the original instruction. |
| 360 | * @mm: the probed process address space. | 360 | * @mm: the probed process address space. |
| 361 | * @uprobe: the probepoint information. | 361 | * @auprobe: arch specific probepoint information. |
| 362 | * @vaddr: the virtual address to insert the opcode. | 362 | * @vaddr: the virtual address to insert the opcode. |
| 363 | * @verify: if true, verify existance of breakpoint instruction. | 363 | * @verify: if true, verify existance of breakpoint instruction. |
| 364 | * | 364 | * |
| @@ -366,7 +366,7 @@ int __weak set_bkpt(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned | |||
| 366 | * Return 0 (success) or a negative errno. | 366 | * Return 0 (success) or a negative errno. |
| 367 | */ | 367 | */ |
| 368 | int __weak | 368 | int __weak |
| 369 | set_orig_insn(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr, bool verify) | 369 | set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr, bool verify) |
| 370 | { | 370 | { |
| 371 | if (verify) { | 371 | if (verify) { |
| 372 | int result; | 372 | int result; |
| @@ -378,7 +378,7 @@ set_orig_insn(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long v | |||
| 378 | if (result != 1) | 378 | if (result != 1) |
| 379 | return result; | 379 | return result; |
| 380 | } | 380 | } |
| 381 | return write_opcode(mm, auprobe, vaddr, *(uprobe_opcode_t *)auprobe->insn); | 381 | return write_opcode(auprobe, mm, vaddr, *(uprobe_opcode_t *)auprobe->insn); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | static int match_uprobe(struct uprobe *l, struct uprobe *r) | 384 | static int match_uprobe(struct uprobe *l, struct uprobe *r) |
| @@ -525,30 +525,30 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset) | |||
| 525 | 525 | ||
| 526 | /* Returns the previous consumer */ | 526 | /* Returns the previous consumer */ |
| 527 | static struct uprobe_consumer * | 527 | static struct uprobe_consumer * |
| 528 | consumer_add(struct uprobe *uprobe, struct uprobe_consumer *consumer) | 528 | consumer_add(struct uprobe *uprobe, struct uprobe_consumer *uc) |
| 529 | { | 529 | { |
| 530 | down_write(&uprobe->consumer_rwsem); | 530 | down_write(&uprobe->consumer_rwsem); |
| 531 | consumer->next = uprobe->consumers; | 531 | uc->next = uprobe->consumers; |
| 532 | uprobe->consumers = consumer; | 532 | uprobe->consumers = uc; |
| 533 | up_write(&uprobe->consumer_rwsem); | 533 | up_write(&uprobe->consumer_rwsem); |
| 534 | 534 | ||
| 535 | return consumer->next; | 535 | return uc->next; |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | /* | 538 | /* |
| 539 | * For uprobe @uprobe, delete the consumer @consumer. | 539 | * For uprobe @uprobe, delete the consumer @uc. |
| 540 | * Return true if the @consumer is deleted successfully | 540 | * Return true if the @uc is deleted successfully |
| 541 | * or return false. | 541 | * or return false. |
| 542 | */ | 542 | */ |
| 543 | static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *consumer) | 543 | static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *uc) |
| 544 | { | 544 | { |
| 545 | struct uprobe_consumer **con; | 545 | struct uprobe_consumer **con; |
| 546 | bool ret = false; | 546 | bool ret = false; |
| 547 | 547 | ||
| 548 | down_write(&uprobe->consumer_rwsem); | 548 | down_write(&uprobe->consumer_rwsem); |
| 549 | for (con = &uprobe->consumers; *con; con = &(*con)->next) { | 549 | for (con = &uprobe->consumers; *con; con = &(*con)->next) { |
| 550 | if (*con == consumer) { | 550 | if (*con == uc) { |
| 551 | *con = consumer->next; | 551 | *con = uc->next; |
| 552 | ret = true; | 552 | ret = true; |
| 553 | break; | 553 | break; |
| 554 | } | 554 | } |
| @@ -558,8 +558,8 @@ static bool consumer_del(struct uprobe *uprobe, struct uprobe_consumer *consumer | |||
| 558 | return ret; | 558 | return ret; |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | static int __copy_insn(struct address_space *mapping, | 561 | static int |
| 562 | struct vm_area_struct *vma, char *insn, | 562 | __copy_insn(struct address_space *mapping, struct vm_area_struct *vma, char *insn, |
| 563 | unsigned long nbytes, unsigned long offset) | 563 | unsigned long nbytes, unsigned long offset) |
| 564 | { | 564 | { |
| 565 | struct file *filp = vma->vm_file; | 565 | struct file *filp = vma->vm_file; |
| @@ -590,7 +590,8 @@ static int __copy_insn(struct address_space *mapping, | |||
| 590 | return 0; | 590 | return 0; |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | static int copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned long addr) | 593 | static int |
| 594 | copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned long addr) | ||
| 594 | { | 595 | { |
| 595 | struct address_space *mapping; | 596 | struct address_space *mapping; |
| 596 | unsigned long nbytes; | 597 | unsigned long nbytes; |
| @@ -617,8 +618,9 @@ static int copy_insn(struct uprobe *uprobe, struct vm_area_struct *vma, unsigned | |||
| 617 | return __copy_insn(mapping, vma, uprobe->arch.insn, bytes, uprobe->offset); | 618 | return __copy_insn(mapping, vma, uprobe->arch.insn, bytes, uprobe->offset); |
| 618 | } | 619 | } |
| 619 | 620 | ||
| 620 | static int install_breakpoint(struct mm_struct *mm, struct uprobe *uprobe, | 621 | static int |
| 621 | struct vm_area_struct *vma, loff_t vaddr) | 622 | install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, |
| 623 | struct vm_area_struct *vma, loff_t vaddr) | ||
| 622 | { | 624 | { |
| 623 | unsigned long addr; | 625 | unsigned long addr; |
| 624 | int ret; | 626 | int ret; |
| @@ -643,20 +645,21 @@ static int install_breakpoint(struct mm_struct *mm, struct uprobe *uprobe, | |||
| 643 | if (is_bkpt_insn((uprobe_opcode_t *)uprobe->arch.insn)) | 645 | if (is_bkpt_insn((uprobe_opcode_t *)uprobe->arch.insn)) |
| 644 | return -EEXIST; | 646 | return -EEXIST; |
| 645 | 647 | ||
| 646 | ret = arch_uprobes_analyze_insn(mm, &uprobe->arch); | 648 | ret = arch_uprobes_analyze_insn(&uprobe->arch, mm); |
| 647 | if (ret) | 649 | if (ret) |
| 648 | return ret; | 650 | return ret; |
| 649 | 651 | ||
| 650 | uprobe->flags |= UPROBE_COPY_INSN; | 652 | uprobe->flags |= UPROBE_COPY_INSN; |
| 651 | } | 653 | } |
| 652 | ret = set_bkpt(mm, &uprobe->arch, addr); | 654 | ret = set_bkpt(&uprobe->arch, mm, addr); |
| 653 | 655 | ||
| 654 | return ret; | 656 | return ret; |
| 655 | } | 657 | } |
| 656 | 658 | ||
| 657 | static void remove_breakpoint(struct mm_struct *mm, struct uprobe *uprobe, loff_t vaddr) | 659 | static void |
| 660 | remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, loff_t vaddr) | ||
| 658 | { | 661 | { |
| 659 | set_orig_insn(mm, &uprobe->arch, (unsigned long)vaddr, true); | 662 | set_orig_insn(&uprobe->arch, mm, (unsigned long)vaddr, true); |
| 660 | } | 663 | } |
| 661 | 664 | ||
| 662 | static void delete_uprobe(struct uprobe *uprobe) | 665 | static void delete_uprobe(struct uprobe *uprobe) |
| @@ -671,9 +674,9 @@ static void delete_uprobe(struct uprobe *uprobe) | |||
| 671 | atomic_dec(&uprobe_events); | 674 | atomic_dec(&uprobe_events); |
| 672 | } | 675 | } |
| 673 | 676 | ||
| 674 | static struct vma_info *__find_next_vma_info(struct list_head *head, | 677 | static struct vma_info * |
| 675 | loff_t offset, struct address_space *mapping, | 678 | __find_next_vma_info(struct address_space *mapping, struct list_head *head, |
| 676 | struct vma_info *vi, bool is_register) | 679 | struct vma_info *vi, loff_t offset, bool is_register) |
| 677 | { | 680 | { |
| 678 | struct prio_tree_iter iter; | 681 | struct prio_tree_iter iter; |
| 679 | struct vm_area_struct *vma; | 682 | struct vm_area_struct *vma; |
| @@ -719,8 +722,8 @@ static struct vma_info *__find_next_vma_info(struct list_head *head, | |||
| 719 | * yet been inserted. | 722 | * yet been inserted. |
| 720 | */ | 723 | */ |
| 721 | static struct vma_info * | 724 | static struct vma_info * |
| 722 | find_next_vma_info(struct list_head *head, loff_t offset, struct address_space *mapping, | 725 | find_next_vma_info(struct address_space *mapping, struct list_head *head, |
| 723 | bool is_register) | 726 | loff_t offset, bool is_register) |
| 724 | { | 727 | { |
| 725 | struct vma_info *vi, *retvi; | 728 | struct vma_info *vi, *retvi; |
| 726 | 729 | ||
| @@ -729,7 +732,7 @@ find_next_vma_info(struct list_head *head, loff_t offset, struct address_space * | |||
| 729 | return ERR_PTR(-ENOMEM); | 732 | return ERR_PTR(-ENOMEM); |
| 730 | 733 | ||
| 731 | mutex_lock(&mapping->i_mmap_mutex); | 734 | mutex_lock(&mapping->i_mmap_mutex); |
| 732 | retvi = __find_next_vma_info(head, offset, mapping, vi, is_register); | 735 | retvi = __find_next_vma_info(mapping, head, vi, offset, is_register); |
| 733 | mutex_unlock(&mapping->i_mmap_mutex); | 736 | mutex_unlock(&mapping->i_mmap_mutex); |
| 734 | 737 | ||
| 735 | if (!retvi) | 738 | if (!retvi) |
| @@ -754,7 +757,7 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) | |||
| 754 | ret = 0; | 757 | ret = 0; |
| 755 | 758 | ||
| 756 | for (;;) { | 759 | for (;;) { |
| 757 | vi = find_next_vma_info(&try_list, uprobe->offset, mapping, is_register); | 760 | vi = find_next_vma_info(mapping, &try_list, uprobe->offset, is_register); |
| 758 | if (!vi) | 761 | if (!vi) |
| 759 | break; | 762 | break; |
| 760 | 763 | ||
| @@ -784,9 +787,9 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) | |||
| 784 | } | 787 | } |
| 785 | 788 | ||
| 786 | if (is_register) | 789 | if (is_register) |
| 787 | ret = install_breakpoint(mm, uprobe, vma, vi->vaddr); | 790 | ret = install_breakpoint(uprobe, mm, vma, vi->vaddr); |
| 788 | else | 791 | else |
| 789 | remove_breakpoint(mm, uprobe, vi->vaddr); | 792 | remove_breakpoint(uprobe, mm, vi->vaddr); |
| 790 | 793 | ||
| 791 | up_read(&mm->mmap_sem); | 794 | up_read(&mm->mmap_sem); |
| 792 | mmput(mm); | 795 | mmput(mm); |
| @@ -823,25 +826,25 @@ static void __uprobe_unregister(struct uprobe *uprobe) | |||
| 823 | * uprobe_register - register a probe | 826 | * uprobe_register - register a probe |
| 824 | * @inode: the file in which the probe has to be placed. | 827 | * @inode: the file in which the probe has to be placed. |
| 825 | * @offset: offset from the start of the file. | 828 | * @offset: offset from the start of the file. |
| 826 | * @consumer: information on howto handle the probe.. | 829 | * @uc: information on howto handle the probe.. |
| 827 | * | 830 | * |
| 828 | * Apart from the access refcount, uprobe_register() takes a creation | 831 | * Apart from the access refcount, uprobe_register() takes a creation |
| 829 | * refcount (thro alloc_uprobe) if and only if this @uprobe is getting | 832 | * refcount (thro alloc_uprobe) if and only if this @uprobe is getting |
| 830 | * inserted into the rbtree (i.e first consumer for a @inode:@offset | 833 | * inserted into the rbtree (i.e first consumer for a @inode:@offset |
| 831 | * tuple). Creation refcount stops uprobe_unregister from freeing the | 834 | * tuple). Creation refcount stops uprobe_unregister from freeing the |
| 832 | * @uprobe even before the register operation is complete. Creation | 835 | * @uprobe even before the register operation is complete. Creation |
| 833 | * refcount is released when the last @consumer for the @uprobe | 836 | * refcount is released when the last @uc for the @uprobe |
| 834 | * unregisters. | 837 | * unregisters. |
| 835 | * | 838 | * |
| 836 | * Return errno if it cannot successully install probes | 839 | * Return errno if it cannot successully install probes |
| 837 | * else return 0 (success) | 840 | * else return 0 (success) |
| 838 | */ | 841 | */ |
| 839 | int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer) | 842 | int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc) |
| 840 | { | 843 | { |
| 841 | struct uprobe *uprobe; | 844 | struct uprobe *uprobe; |
| 842 | int ret; | 845 | int ret; |
| 843 | 846 | ||
| 844 | if (!inode || !consumer || consumer->next) | 847 | if (!inode || !uc || uc->next) |
| 845 | return -EINVAL; | 848 | return -EINVAL; |
| 846 | 849 | ||
| 847 | if (offset > i_size_read(inode)) | 850 | if (offset > i_size_read(inode)) |
| @@ -851,7 +854,7 @@ int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer * | |||
| 851 | mutex_lock(uprobes_hash(inode)); | 854 | mutex_lock(uprobes_hash(inode)); |
| 852 | uprobe = alloc_uprobe(inode, offset); | 855 | uprobe = alloc_uprobe(inode, offset); |
| 853 | 856 | ||
| 854 | if (uprobe && !consumer_add(uprobe, consumer)) { | 857 | if (uprobe && !consumer_add(uprobe, uc)) { |
| 855 | ret = __uprobe_register(uprobe); | 858 | ret = __uprobe_register(uprobe); |
| 856 | if (ret) { | 859 | if (ret) { |
| 857 | uprobe->consumers = NULL; | 860 | uprobe->consumers = NULL; |
| @@ -871,13 +874,13 @@ int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer * | |||
| 871 | * uprobe_unregister - unregister a already registered probe. | 874 | * uprobe_unregister - unregister a already registered probe. |
| 872 | * @inode: the file in which the probe has to be removed. | 875 | * @inode: the file in which the probe has to be removed. |
| 873 | * @offset: offset from the start of the file. | 876 | * @offset: offset from the start of the file. |
| 874 | * @consumer: identify which probe if multiple probes are colocated. | 877 | * @uc: identify which probe if multiple probes are colocated. |
| 875 | */ | 878 | */ |
| 876 | void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer) | 879 | void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc) |
| 877 | { | 880 | { |
| 878 | struct uprobe *uprobe; | 881 | struct uprobe *uprobe; |
| 879 | 882 | ||
| 880 | if (!inode || !consumer) | 883 | if (!inode || !uc) |
| 881 | return; | 884 | return; |
| 882 | 885 | ||
| 883 | uprobe = find_uprobe(inode, offset); | 886 | uprobe = find_uprobe(inode, offset); |
| @@ -886,7 +889,7 @@ void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consume | |||
| 886 | 889 | ||
| 887 | mutex_lock(uprobes_hash(inode)); | 890 | mutex_lock(uprobes_hash(inode)); |
| 888 | 891 | ||
| 889 | if (consumer_del(uprobe, consumer)) { | 892 | if (consumer_del(uprobe, uc)) { |
| 890 | if (!uprobe->consumers) { | 893 | if (!uprobe->consumers) { |
| 891 | __uprobe_unregister(uprobe); | 894 | __uprobe_unregister(uprobe); |
| 892 | uprobe->flags &= ~UPROBE_RUN_HANDLER; | 895 | uprobe->flags &= ~UPROBE_RUN_HANDLER; |
| @@ -993,7 +996,7 @@ int uprobe_mmap(struct vm_area_struct *vma) | |||
| 993 | if (!ret) { | 996 | if (!ret) { |
| 994 | vaddr = vma_address(vma, uprobe->offset); | 997 | vaddr = vma_address(vma, uprobe->offset); |
| 995 | if (vaddr >= vma->vm_start && vaddr < vma->vm_end) { | 998 | if (vaddr >= vma->vm_start && vaddr < vma->vm_end) { |
| 996 | ret = install_breakpoint(vma->vm_mm, uprobe, vma, vaddr); | 999 | ret = install_breakpoint(uprobe, vma->vm_mm, vma, vaddr); |
| 997 | /* Ignore double add: */ | 1000 | /* Ignore double add: */ |
| 998 | if (ret == -EEXIST) | 1001 | if (ret == -EEXIST) |
| 999 | ret = 0; | 1002 | ret = 0; |
