From patchwork Wed Jan 9 01:28:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 1950271 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 7A5913FED4 for ; Wed, 9 Jan 2013 01:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756702Ab3AIBa5 (ORCPT ); Tue, 8 Jan 2013 20:30:57 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:34239 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756193Ab3AIB23 (ORCPT ); Tue, 8 Jan 2013 20:28:29 -0500 Received: by mail-pb0-f53.google.com with SMTP id jt11so593824pbb.40 for ; Tue, 08 Jan 2013 17:28:29 -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=hJMXIlRXm4UDRvUmdOePVuFKoXSG6cPBUXOaAtDTo7E=; b=p1LX+BoSOKAcaZJSeMXN3Gnbph/8jOiG1DOzMWZKGZcFfhVusng82xzgcN0ujR9P7H AL3p99ppjwQNkCNLz8bqPRJsRlnONkJ53K5tFmCkEGiXdZ4Lf6Ifut4U89uL1ogsgOzX Ox37GGOiNNp7Q1Miv2amskJFYRtsSHJokZxZ6y8YTBZSQf2G9VWBqWwDLFRI+xFDw9PQ rkHvyHnptUqCjTXbAjf3mPhtdpi0buwcmnjwc4mTDMTzylxLio3w91tnPKZiUbuQV4y+ cyOfTEb9giOO/8gnpQafIpcSrnA4w+RdcuiRfdYg+tNjcyhOVQ2lYg5ioOoWd/76kXnl UlyQ== 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=hJMXIlRXm4UDRvUmdOePVuFKoXSG6cPBUXOaAtDTo7E=; b=i9zGQTWC9NBCdhvCOHXgIPefgY89YdRvNLLeKV3qOGfopXSqlg6x1Ggij2CXxcnjpA Yr3kb0IbthT8XQEba+oDUUxoOz4RQT0UCsx7sJYn1XyjJn+nHmMn9KEc7+FFHwZV3P6j hKK+eGslwmuKXpIbz4FUBXWDrPV4FECvQIJ6dWwClLDpKEENy/Ux1ueij59Z14ODQ1e1 fTU88A4Owgv4FVZ6MZfh8VGikdE0HithDI6ugX11kd9ICkXRfKhT6YgKIOvEhVQpWls/ Ghty8fQGMg52ll0qDy1SFJ3fmco81Ji+FfasR5ETYhhe4+3zRxUQoQVTvKwMHuHrCVQg GaaA== X-Received: by 10.68.238.106 with SMTP id vj10mr207918820pbc.40.1357694909370; Tue, 08 Jan 2013 17:28:29 -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.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 17:28:28 -0800 (PST) From: Michel Lespinasse To: Rik van Riel , Benjamin Herrenschmidt , "James E.J. Bottomley" , Matt Turner , David Howells , Tony Luck Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-parisc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org Subject: [PATCH 1/8] mm: use vm_unmapped_area() on parisc architecture Date: Tue, 8 Jan 2013 17:28:08 -0800 Message-Id: <1357694895-520-2-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: ALoCoQn7f2tU25QBLPe5Ch/CASOBKdI6PvEh0/BpNnoOEmSc7Yp5B6FGPJnhUTJi7D2AxKkYq9mLX3uOr4vXZQv5SpbacFlhrJTskX8u8/9SxGJRUbB3ADNXt36cVKCIHK2Gqm4J6g3iH+150w/0yJCrYzaNcz2PmIw5J06TIfSkHC6zmZC2pgsNdIDK2O3iOMhp2srcOki7BSUBywpahoXYBPP3NTfybg== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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 --- arch/parisc/kernel/sys_parisc.c | 46 ++++++++++++++------------------------ 1 files changed, 17 insertions(+), 29 deletions(-) diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index f76c10863c62..6ab138088076 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/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(unsigned long addr, unsigned long len) */ 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,