From patchwork Wed Jan 9 01:28:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 210590 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 25EDB2C066D for ; Wed, 9 Jan 2013 12:31:02 +1100 (EST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B51872C00FB for ; Wed, 9 Jan 2013 12:28:34 +1100 (EST) Received: by mail-pa0-f49.google.com with SMTP id bi1so679166pad.22 for ; Tue, 08 Jan 2013 17:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=X/fqiYxeGhEl06mlYA6GxTFnIGMeNLRlgZN+4rCnRDw=; b=Q0QHo2ucT24vJKQu3pFZxSOy6qXjdph6zZlRUrAJI1Lv/XFlKK/Ry5wZ1rGZgHE25e l2XR6ZoEnj2iArHX1qDt/NWDBVc/CZ5a1ZGza0/YsjICF5jkPi9Izl6boLshztnHKlw3 8JT9zYHIuCmr5C4tVCQKcrMAV+udRASa3IV1gZTax1V29F8ng1XltnnblnA0IA36txI1 9nx6zXqCw953mU8X+EHS6tgrgkzeI4/SW4ZjnDODcJ0uBD21zSJR+2NvymLVrxqC8Jlj CzDsXUJIY606KIF+J16t6CPAEdrGs/814VD0X9XclQNYVgyoWu7SP74xzADuMmljaPai CvPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=X/fqiYxeGhEl06mlYA6GxTFnIGMeNLRlgZN+4rCnRDw=; b=Ts0sfmUawzNp71bv0cAxmhfls7r1IRVB340a1roPH20MVzfF/DVLeGZH+aoSvhwqNH QIjM+8FuVWXzH99rudl0gvy+Il23FiX8wcDf3eVW36dJOtuJi0xPGIqqebjMqzwE6EcE OABZEzEpDXfJ+h8E6W28g3q/mxRslGAUsIiZ+Ou92vHZ/kN95Bs1g77nS5ek/xYsgbEV w9d6IvJFQwklMwXEzPY7UHC6BYH9Ul2K30/IOahnohwx+lH//YutI6UTgYrFTjgI3Wv4 TKbPy6gokb+MlCOr3DPbvh5lF2V6fOM+UJNcS+VmizVUmOPMiosFt1hws0g4GqYZsFeU JxPw== X-Received: by 10.68.227.33 with SMTP id rx1mr163657410pbc.67.1357694912431; Tue, 08 Jan 2013 17:28:32 -0800 (PST) Received: from studio.mtv.corp.google.com (studio.mtv.corp.google.com [172.17.131.106]) by mx.google.com with ESMTPS id p10sm41711168pax.27.2013.01.08.17.28.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 17:28:31 -0800 (PST) From: Michel Lespinasse To: Rik van Riel , Benjamin Herrenschmidt , "James E.J. Bottomley" , Matt Turner , David Howells , Tony Luck Subject: [PATCH 3/8] mm: use vm_unmapped_area() on frv architecture Date: Tue, 8 Jan 2013 17:28:10 -0800 Message-Id: <1357694895-520-4-git-send-email-walken@google.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1357694895-520-1-git-send-email-walken@google.com> References: <1357694895-520-1-git-send-email-walken@google.com> X-Gm-Message-State: ALoCoQmno4RAXJO3uSzahNX7w714u/F8l8z9SjtmNE1zxmCsHJ4SAvL5jn9Q8ACu7DdYG1N/zHuDHZCPgw5M8QEj8rhNbH8w9ez7QtSQYhc8l3Ko2WRruhWJnd/MkXsCWwgyIbPjQGbXLBBD4NuSAKXIOkoOJkLYh39Rzx7QkmDXlPt4+Tt94wEbb4tJNfOgbDIv9917YLlB4tZIEh9z9TiPwTqV1l0KGw== Cc: linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Update the frv arch_get_unmapped_area function to make use of vm_unmapped_area() instead of implementing a brute force search. Signed-off-by: Michel Lespinasse Acked-by: Rik van Riel --- arch/frv/mm/elf-fdpic.c | 49 ++++++++++++++++------------------------------ 1 files changed, 17 insertions(+), 32 deletions(-) diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c index 385fd30b142f..836f14707a62 100644 --- a/arch/frv/mm/elf-fdpic.c +++ b/arch/frv/mm/elf-fdpic.c @@ -60,7 +60,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi unsigned long pgoff, unsigned long flags) { struct vm_area_struct *vma; - unsigned long limit; + struct vm_unmapped_area_info info; if (len > TASK_SIZE) return -ENOMEM; @@ -79,39 +79,24 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi } /* search between the bottom of user VM and the stack grow area */ - addr = PAGE_SIZE; - limit = (current->mm->start_stack - 0x00200000); - if (addr + len <= limit) { - limit -= len; - - if (addr <= limit) { - vma = find_vma(current->mm, PAGE_SIZE); - for (; vma; vma = vma->vm_next) { - if (addr > limit) - break; - if (addr + len <= vma->vm_start) - goto success; - addr = vma->vm_end; - } - } - } + info.flags = 0; + info.length = len; + info.low_limit = PAGE_SIZE; + info.high_limit = (current->mm->start_stack - 0x00200000); + info.align_mask = 0; + info.align_offset = 0; + addr = vm_unmapped_area(&info); + if (!(addr & ~PAGE_MASK)) + goto success; + VM_BUG_ON(addr != -ENOMEM); /* search from just above the WorkRAM area to the top of memory */ - addr = PAGE_ALIGN(0x80000000); - limit = TASK_SIZE - len; - if (addr <= limit) { - vma = find_vma(current->mm, addr); - for (; vma; vma = vma->vm_next) { - if (addr > limit) - break; - if (addr + len <= vma->vm_start) - goto success; - addr = vma->vm_end; - } - - if (!vma && addr <= limit) - goto success; - } + info.low_limit = PAGE_ALIGN(0x80000000); + info.high_limit = TASK_SIZE; + addr = vm_unmapped_area(&info); + if (!(addr & ~PAGE_MASK)) + goto success; + VM_BUG_ON(addr != -ENOMEM); #if 0 printk("[area] l=%lx (ENOMEM) f='%s'\n",