linux-mips
[Top] [All Lists]

[PATCH 15/16] mm: use vm_unmapped_area() on sparc32 architecture

To: Andrew Morton <akpm@linux-foundation.org>, Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>, linux-kernel@vger.kernel.org, Russell King <linux@arm.linux.org.uk>, Ralf Baechle <ralf@linux-mips.org>, Paul Mundt <lethal@linux-sh.org>, "David S. Miller" <davem@davemloft.net>, Chris Metcalf <cmetcalf@tilera.com>, x86@kernel.org, William Irwin <wli@holomorphy.com>
Subject: [PATCH 15/16] mm: use vm_unmapped_area() on sparc32 architecture
From: Michel Lespinasse <walken@google.com>
Date: Mon, 5 Nov 2012 14:47:12 -0800
Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=1bdZJOJFyYYe3TNi395CJvw+NxzxEeeJWLV7JAFL6Og=; b=AIjPq8XYet9dz58VUHqEj8ODrvi2kBJdwDm82I+kl5Op6Z5XoxIHFhhjVjERTM/fmZ NHemXX1nz7aDbEmv8TpswcOVQ9FvnlTn32JxPDBG23A2ArdZwJiQdhUKuM6riTse8vq1 LJUPU7mfigQbkCjzPnEZf4EADOo2OGXJ4dnRbQLH3t+A8nHBbtCOr4YZ/eBgfuEeAAFc DevtFLiCw+KlzGbTZ7IQnwO+gwGX1J0+n75aQw/B7MX337dy8TLBw03RhFezM8PurhcY sspM+kO0FddD0VZxIwh/wS3A9nKyjcGt1FAfLWQ64b5B9Sx0sgmeeth/li/oG3HX3jaW HpzA==
In-reply-to: <1352155633-8648-1-git-send-email-walken@google.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1352155633-8648-1-git-send-email-walken@google.com>
Sender: linux-mips-bounce@linux-mips.org
Update the sparc32 arch_get_unmapped_area function to make use of
vm_unmapped_area() instead of implementing a brute force search.

Signed-off-by: Michel Lespinasse <walken@google.com>

---
 arch/sparc/kernel/sys_sparc_32.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
index 0c9b31b22e07..653899849b27 100644
--- a/arch/sparc/kernel/sys_sparc_32.c
+++ b/arch/sparc/kernel/sys_sparc_32.c
@@ -39,6 +39,7 @@ asmlinkage unsigned long sys_getpagesize(void)
 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, 
unsigned long len, unsigned long pgoff, unsigned long flags)
 {
        struct vm_area_struct * vmm;
+       struct vm_unmapped_area_info info;
 
        if (flags & MAP_FIXED) {
                /* We do not accept a shared mapping if it would violate
@@ -56,21 +57,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr, unsi
        if (!addr)
                addr = TASK_UNMAPPED_BASE;
 
-       if (flags & MAP_SHARED)
-               addr = COLOUR_ALIGN(addr);
-       else
-               addr = PAGE_ALIGN(addr);
-
-       for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
-               /* At this point:  (!vmm || addr < vmm->vm_end). */
-               if (TASK_SIZE - PAGE_SIZE - len < addr)
-                       return -ENOMEM;
-               if (!vmm || addr + len <= vmm->vm_start)
-                       return addr;
-               addr = vmm->vm_end;
-               if (flags & MAP_SHARED)
-                       addr = COLOUR_ALIGN(addr);
-       }
+       info.flags = 0;
+       info.length = len;
+       info.low_limit = addr;
+       info.high_limit = TASK_SIZE;
+       info.align_mask = (flags & MAP_SHARED) ?
+               (PAGE_MASK & (SHMLBA - 1)) : 0;
+       info.align_offset = pgoff << PAGE_SHIFT;
+       return vm_unmapped_area(&info);
 }
 
 /*
-- 
1.7.7.3

<Prev in Thread] Current Thread [Next in Thread>