diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-07-29 14:22:42 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-07-30 05:27:24 -0400 |
commit | cb113b47d098185f3f1f67e8300d05ddce842b66 (patch) | |
tree | 86601eb6728a4142e94e4cc3e45697840f6b0768 /kernel | |
parent | 891c39708144bbe401b4aa151bffd0fe41b1dafd (diff) |
uprobes: Introduce vaddr_to_offset(vma, vaddr)
Add the new helper, vaddr_to_offset(vma, vaddr) which returns
the offset in vma->vm_file this vaddr is mapped at.
Change build_probe_list() and find_active_uprobe() to use the
new helper, the next patch adds another user.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar.vnet.ibm.com>
Cc: Anton Arapov <anton@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20120729182242.GA20355@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/uprobes.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 2ef123306183..b03256cced52 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -122,6 +122,11 @@ static loff_t vma_address(struct vm_area_struct *vma, loff_t offset) | |||
122 | return vaddr; | 122 | return vaddr; |
123 | } | 123 | } |
124 | 124 | ||
125 | static loff_t vaddr_to_offset(struct vm_area_struct *vma, unsigned long vaddr) | ||
126 | { | ||
127 | return ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + (vaddr - vma->vm_start); | ||
128 | } | ||
129 | |||
125 | /** | 130 | /** |
126 | * __replace_page - replace page in vma by new page. | 131 | * __replace_page - replace page in vma by new page. |
127 | * based on replace_page in mm/ksm.c | 132 | * based on replace_page in mm/ksm.c |
@@ -978,7 +983,7 @@ static void build_probe_list(struct inode *inode, | |||
978 | struct uprobe *u; | 983 | struct uprobe *u; |
979 | 984 | ||
980 | INIT_LIST_HEAD(head); | 985 | INIT_LIST_HEAD(head); |
981 | min = ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + start - vma->vm_start; | 986 | min = vaddr_to_offset(vma, start); |
982 | max = min + (end - start) - 1; | 987 | max = min + (end - start) - 1; |
983 | 988 | ||
984 | spin_lock_irqsave(&uprobes_treelock, flags); | 989 | spin_lock_irqsave(&uprobes_treelock, flags); |
@@ -1442,12 +1447,9 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp) | |||
1442 | vma = find_vma(mm, bp_vaddr); | 1447 | vma = find_vma(mm, bp_vaddr); |
1443 | if (vma && vma->vm_start <= bp_vaddr) { | 1448 | if (vma && vma->vm_start <= bp_vaddr) { |
1444 | if (valid_vma(vma, false)) { | 1449 | if (valid_vma(vma, false)) { |
1445 | struct inode *inode; | 1450 | struct inode *inode = vma->vm_file->f_mapping->host; |
1446 | loff_t offset; | 1451 | loff_t offset = vaddr_to_offset(vma, bp_vaddr); |
1447 | 1452 | ||
1448 | inode = vma->vm_file->f_mapping->host; | ||
1449 | offset = bp_vaddr - vma->vm_start; | ||
1450 | offset += (loff_t)vma->vm_pgoff << PAGE_SHIFT; | ||
1451 | uprobe = find_uprobe(inode, offset); | 1453 | uprobe = find_uprobe(inode, offset); |
1452 | } | 1454 | } |
1453 | 1455 | ||