diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-12-31 10:39:49 -0500 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2013-02-08 11:47:11 -0500 |
commit | 9b545df809644912552360054c7bbe8b8a9e01fa (patch) | |
tree | ca558fdf71d30ec0bc5ef2f821b06b45b13ff5b0 /kernel/events | |
parent | c8a82538001e1a68f4a319d5a75de90d1f284731 (diff) |
uprobes: Fold xol_alloc_area() into get_xol_area()
Currently only xol_get_insn_slot() does get_xol_area() + xol_alloc_area(),
but this will have more users and we do not want to copy-and-paste this
code. This patch simply moves xol_alloc_area() into get_xol_area() to
simplify the current and future code.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Anton Arapov <anton@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/uprobes.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index ea2e2a85479a..7e3e5c5b0d88 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -1070,27 +1070,21 @@ static int xol_add_vma(struct xol_area *area) | |||
1070 | return ret; | 1070 | return ret; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static struct xol_area *get_xol_area(struct mm_struct *mm) | ||
1074 | { | ||
1075 | struct xol_area *area; | ||
1076 | |||
1077 | area = mm->uprobes_state.xol_area; | ||
1078 | smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */ | ||
1079 | |||
1080 | return area; | ||
1081 | } | ||
1082 | |||
1083 | /* | 1073 | /* |
1084 | * xol_alloc_area - Allocate process's xol_area. | 1074 | * get_xol_area - Allocate process's xol_area if necessary. |
1085 | * This area will be used for storing instructions for execution out of | 1075 | * This area will be used for storing instructions for execution out of line. |
1086 | * line. | ||
1087 | * | 1076 | * |
1088 | * Returns the allocated area or NULL. | 1077 | * Returns the allocated area or NULL. |
1089 | */ | 1078 | */ |
1090 | static struct xol_area *xol_alloc_area(void) | 1079 | static struct xol_area *get_xol_area(void) |
1091 | { | 1080 | { |
1081 | struct mm_struct *mm = current->mm; | ||
1092 | struct xol_area *area; | 1082 | struct xol_area *area; |
1093 | 1083 | ||
1084 | area = mm->uprobes_state.xol_area; | ||
1085 | if (area) | ||
1086 | goto ret; | ||
1087 | |||
1094 | area = kzalloc(sizeof(*area), GFP_KERNEL); | 1088 | area = kzalloc(sizeof(*area), GFP_KERNEL); |
1095 | if (unlikely(!area)) | 1089 | if (unlikely(!area)) |
1096 | goto out; | 1090 | goto out; |
@@ -1113,7 +1107,10 @@ static struct xol_area *xol_alloc_area(void) | |||
1113 | free_area: | 1107 | free_area: |
1114 | kfree(area); | 1108 | kfree(area); |
1115 | out: | 1109 | out: |
1116 | return get_xol_area(current->mm); | 1110 | area = mm->uprobes_state.xol_area; |
1111 | ret: | ||
1112 | smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */ | ||
1113 | return area; | ||
1117 | } | 1114 | } |
1118 | 1115 | ||
1119 | /* | 1116 | /* |
@@ -1189,14 +1186,11 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe, unsigned long slot | |||
1189 | unsigned long offset; | 1186 | unsigned long offset; |
1190 | void *vaddr; | 1187 | void *vaddr; |
1191 | 1188 | ||
1192 | area = get_xol_area(current->mm); | 1189 | area = get_xol_area(); |
1193 | if (!area) { | 1190 | if (!area) |
1194 | area = xol_alloc_area(); | 1191 | return 0; |
1195 | if (!area) | ||
1196 | return 0; | ||
1197 | } | ||
1198 | current->utask->xol_vaddr = xol_take_insn_slot(area); | ||
1199 | 1192 | ||
1193 | current->utask->xol_vaddr = xol_take_insn_slot(area); | ||
1200 | /* | 1194 | /* |
1201 | * Initialize the slot if xol_vaddr points to valid | 1195 | * Initialize the slot if xol_vaddr points to valid |
1202 | * instruction slot. | 1196 | * instruction slot. |