From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755823Ab3AHL4L (ORCPT ); Tue, 8 Jan 2013 06:56:11 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:57764 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754962Ab3AHL4I (ORCPT ); Tue, 8 Jan 2013 06:56:08 -0500 Date: Tue, 8 Jan 2013 17:25:41 +0530 From: Srikar Dronamraju To: Oleg Nesterov Cc: Ingo Molnar , Peter Zijlstra , Ananth N Mavinakayanahalli , Anton Arapov , Frank Eigler , Josh Stone , "Suzuki K. Poulose" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/7] uprobes: Fold xol_alloc_area() into get_xol_area() Message-ID: <20130108115541.GE1325@linux.vnet.ibm.com> Reply-To: Srikar Dronamraju References: <20121231175150.GA32066@redhat.com> <20121231175216.GA32091@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20121231175216.GA32091@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13010811-3620-0000-0000-000000D6BA05 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Oleg Nesterov [2012-12-31 18:52:16]: > 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 Acked-by: Srikar Dronamraju > --- > 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 1456f7d..ef81162 100644 > --- a/kernel/events/uprobes.c > +++ b/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_alloc_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. > -- > 1.5.5.1 >