From patchwork Thu Feb 21 23:12:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 2173631 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 172C53FCA4 for ; Thu, 21 Feb 2013 23:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754763Ab3BUXUH (ORCPT ); Thu, 21 Feb 2013 18:20:07 -0500 Received: from mail-vb0-f74.google.com ([209.85.212.74]:43307 "EHLO mail-vb0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753789Ab3BUXUG (ORCPT ); Thu, 21 Feb 2013 18:20:06 -0500 Received: by mail-vb0-f74.google.com with SMTP id r6so10448vbi.3 for ; Thu, 21 Feb 2013 15:20:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:subject:to:cc:from:date:mime-version:content-type :content-transfer-encoding:message-id:x-gm-message-state; bh=3mqKnX2Zr8RiNWDrc0brlgkUWhWApUoSRO3uHesYHQg=; b=GYDow8lIgFhpXVOH+X3Ka36iRjIFsmmIPw7dn/PagYjkJkEpFrMp5BEYbytZINVkZl CuFR7NeQVkxzbWk9JedW2aOWcnqd00dzwEo/fK9kKAosovob1CqQ+dkjqJm03cGPeKvU X0/GwtDukgCz9Jr9JUxfpfcvEqKroYzrByrkNb7SFp5vGndAtDk5dinaFuBbrLrYWNVY cEB3WjmkrHZBkGPvjNHgo0Ok/HlhdCkKSSpAT2kIU2nPDQg3PNFYy4f3hsVqg/IXB2JU l3wrpU4HtQuFIWv3eG/7FZJDlWMCtIsIkS/RNrzIeYLPHWbIy1WpGuzTNesbTsiQyaOv 6Ywg== X-Received: by 10.101.116.13 with SMTP id t13mr3170643anm.12.1361488353688; Thu, 21 Feb 2013 15:12:33 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id e21si18801anp.1.2013.02.21.15.12.33 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2013 15:12:33 -0800 (PST) Received: from localhost.localdomain (akpm.mtv.corp.google.com [172.17.130.154]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 1155D5A4174; Thu, 21 Feb 2013 15:12:33 -0800 (PST) Subject: [patch 1/1] mm: use vm_unmapped_area() on parisc architecture To: jejb@parisc-linux.org Cc: deller@gmx.de, linux-parisc@vger.kernel.org, akpm@linux-foundation.org, walken@google.com, riel@redhat.com From: akpm@linux-foundation.org Date: Thu, 21 Feb 2013 15:12:32 -0800 MIME-Version: 1.0 Message-Id: <20130221231233.1155D5A4174@corp2gmr1-2.hot.corp.google.com> X-Gm-Message-State: ALoCoQnOuUNTQPTTn4yhr60XC4FpHSonSi4Gd8V802IiU64ApW9chLk8fDmeDmXO2MYdZ+Wf7GP5 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org From: Michel Lespinasse Subject: mm: use vm_unmapped_area() on parisc architecture Update the parisc 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 Cc: "James E.J. Bottomley" Cc: Helge Deller Signed-off-by: Andrew Morton Acked-by: Helge Deller --- arch/parisc/kernel/sys_parisc.c | 46 +++++++++++------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff -puN arch/parisc/kernel/sys_parisc.c~mm-use-vm_unmapped_area-on-parisc-architecture arch/parisc/kernel/sys_parisc.c --- a/arch/parisc/kernel/sys_parisc.c~mm-use-vm_unmapped_area-on-parisc-architecture +++ a/arch/parisc/kernel/sys_parisc.c @@ -35,18 +35,15 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len) { - struct vm_area_struct *vma; + struct vm_unmapped_area_info info; - addr = PAGE_ALIGN(addr); - - for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { - /* At this point: (!vma || addr < vma->vm_end). */ - if (TASK_SIZE - len < addr) - return -ENOMEM; - if (!vma || addr + len <= vma->vm_start) - return addr; - addr = vma->vm_end; - } + info.flags = 0; + info.length = len; + info.low_limit = PAGE_ALIGN(addr); + info.high_limit = TASK_SIZE; + info.align_mask = 0; + info.align_offset = 0; + return vm_unmapped_area(&info); } #define DCACHE_ALIGN(addr) (((addr) + (SHMLBA - 1)) &~ (SHMLBA - 1)) @@ -63,30 +60,21 @@ static unsigned long get_unshared_area(u */ static int get_offset(struct address_space *mapping) { - int offset = (unsigned long) mapping << (PAGE_SHIFT - 8); - return offset & 0x3FF000; + return (unsigned long) mapping >> 8; } static unsigned long get_shared_area(struct address_space *mapping, unsigned long addr, unsigned long len, unsigned long pgoff) { - struct vm_area_struct *vma; - int offset = mapping ? get_offset(mapping) : 0; - - offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000; + struct vm_unmapped_area_info info; - addr = DCACHE_ALIGN(addr - offset) + offset; - - for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { - /* At this point: (!vma || addr < vma->vm_end). */ - if (TASK_SIZE - len < addr) - return -ENOMEM; - if (!vma || addr + len <= vma->vm_start) - return addr; - addr = DCACHE_ALIGN(vma->vm_end - offset) + offset; - if (addr < vma->vm_end) /* handle wraparound */ - return -ENOMEM; - } + info.flags = 0; + info.length = len; + info.low_limit = PAGE_ALIGN(addr); + info.high_limit = TASK_SIZE; + info.align_mask = PAGE_MASK & (SHMLBA - 1); + info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT; + return vm_unmapped_area(&info); } unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,