Commit 9b545df8 authored by Oleg Nesterov's avatar Oleg Nesterov

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: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarAnton Arapov <anton@redhat.com>
Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
parent c8a82538
...@@ -1070,27 +1070,21 @@ static int xol_add_vma(struct xol_area *area) ...@@ -1070,27 +1070,21 @@ static int xol_add_vma(struct xol_area *area)
return ret; return ret;
} }
static struct xol_area *get_xol_area(struct mm_struct *mm)
{
struct xol_area *area;
area = mm->uprobes_state.xol_area;
smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */
return area;
}
/* /*
* xol_alloc_area - Allocate process's xol_area. * get_xol_area - Allocate process's xol_area if necessary.
* This area will be used for storing instructions for execution out of * This area will be used for storing instructions for execution out of line.
* line.
* *
* Returns the allocated area or NULL. * Returns the allocated area or NULL.
*/ */
static struct xol_area *xol_alloc_area(void) static struct xol_area *get_xol_area(void)
{ {
struct mm_struct *mm = current->mm;
struct xol_area *area; struct xol_area *area;
area = mm->uprobes_state.xol_area;
if (area)
goto ret;
area = kzalloc(sizeof(*area), GFP_KERNEL); area = kzalloc(sizeof(*area), GFP_KERNEL);
if (unlikely(!area)) if (unlikely(!area))
goto out; goto out;
...@@ -1113,7 +1107,10 @@ static struct xol_area *xol_alloc_area(void) ...@@ -1113,7 +1107,10 @@ static struct xol_area *xol_alloc_area(void)
free_area: free_area:
kfree(area); kfree(area);
out: out:
return get_xol_area(current->mm); area = mm->uprobes_state.xol_area;
ret:
smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */
return area;
} }
/* /*
...@@ -1189,14 +1186,11 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe, unsigned long slot ...@@ -1189,14 +1186,11 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe, unsigned long slot
unsigned long offset; unsigned long offset;
void *vaddr; void *vaddr;
area = get_xol_area(current->mm); area = get_xol_area();
if (!area) { if (!area)
area = xol_alloc_area(); return 0;
if (!area)
return 0;
}
current->utask->xol_vaddr = xol_take_insn_slot(area);
current->utask->xol_vaddr = xol_take_insn_slot(area);
/* /*
* Initialize the slot if xol_vaddr points to valid * Initialize the slot if xol_vaddr points to valid
* instruction slot. * instruction slot.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment