Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755938Ab2FTMbI (ORCPT ); Wed, 20 Jun 2012 08:31:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33441 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753365Ab2FTMbG (ORCPT ); Wed, 20 Jun 2012 08:31:06 -0400 Date: Wed, 20 Jun 2012 14:29:39 +0200 From: Anton Arapov To: Oleg Nesterov Cc: Ingo Molnar , Peter Zijlstra , Srikar Dronamraju , Ananth N Mavinakayanahalli , Hugh Dickins , linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] uprobes: write_opcode: alloc the new page outside of "retry" loop Message-ID: <20120620122939.GA4018@bandura.brq.redhat.com> References: <20120619194636.GA30137@redhat.com> <20120619194759.GE30146@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120619194759.GE30146@redhat.com> X-PGP-Key: http://people.redhat.com/aarapov/gpg User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1553 Lines: 48 On Tue, Jun 19, 2012 at 09:47:59PM +0200, Oleg Nesterov wrote: > It is ugly to free and re-alloc new_page if write_opcode() needs to > retry. Move alloc_page_vma/page_cache_release outside of "retry" loop. > > Signed-off-by: Oleg Nesterov > --- > kernel/events/uprobes.c | 26 +++++++++++--------------- > 1 files changed, 11 insertions(+), 15 deletions(-) > > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > index 442064d..3fd7bdf 100644 > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c > @@ -214,19 +214,18 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, > struct vm_area_struct *vma; > int ret; > > -retry: > - /* Read the page with vaddr into memory */ > - ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &old_page, &vma); > - if (ret <= 0) > - return ret; > - > - ret = -ENOMEM; > new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr); Should we want NULL instead of vma in alloc_page_vma()? Or initialize vma with NULL... > if (!new_page) > - goto put_old; > + return -ENOMEM; > > __SetPageUptodate(new_page); > > + retry: > + /* Read the page with vaddr into memory */ > + ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &old_page, &vma); > + if (ret <= 0) > + goto out; > + [cut] Anton. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/