From 5a686c8c2ada4a0d3b76c788ab966df9fa7af2f0 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Dec 2012 16:39:49 +0100 Subject: [PATCH] --- yaml --- r: 350091 b: refs/heads/master c: 9b545df809644912552360054c7bbe8b8a9e01fa h: refs/heads/master i: 350089: e9d028325555b9c54af0cb9d963074ca6f0d65ef 350087: fdc4f80ede8da5fd1777df4591c428856b7caa35 v: v3 --- [refs] | 2 +- trunk/kernel/events/uprobes.c | 38 +++++++++++++++-------------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/[refs] b/[refs] index 3a968db186af..214f5e69ad28 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c8a82538001e1a68f4a319d5a75de90d1f284731 +refs/heads/master: 9b545df809644912552360054c7bbe8b8a9e01fa diff --git a/trunk/kernel/events/uprobes.c b/trunk/kernel/events/uprobes.c index ea2e2a85479a..7e3e5c5b0d88 100644 --- a/trunk/kernel/events/uprobes.c +++ b/trunk/kernel/events/uprobes.c @@ -1070,27 +1070,21 @@ static int xol_add_vma(struct xol_area *area) 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. - * This area will be used for storing instructions for execution out of - * line. + * get_xol_area - Allocate process's xol_area if necessary. + * This area will be used for storing instructions for execution out of line. * * 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; + area = mm->uprobes_state.xol_area; + if (area) + goto ret; + area = kzalloc(sizeof(*area), GFP_KERNEL); if (unlikely(!area)) goto out; @@ -1113,7 +1107,10 @@ static struct xol_area *xol_alloc_area(void) free_area: kfree(area); 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 unsigned long offset; void *vaddr; - area = get_xol_area(current->mm); - if (!area) { - area = xol_alloc_area(); - if (!area) - return 0; - } - current->utask->xol_vaddr = xol_take_insn_slot(area); + area = get_xol_area(); + if (!area) + return 0; + current->utask->xol_vaddr = xol_take_insn_slot(area); /* * Initialize the slot if xol_vaddr points to valid * instruction slot.