| 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 08/16] mm: use vm_unmapped_area() in hugetlbfs |
| From: | Michel Lespinasse <walken@google.com> |
| Date: | Mon, 5 Nov 2012 14:47:05 -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=42IS+hQRw1ADfOLftQzPl7PxMg4IQjJkQMFWMKDSP6c=; b=BTWWcGITnt10w9ODDwzgVyd4fvZLIhoOhGhassjJtWC3ep5kwz47pCPaaIoLUk/Ur5 ixwrhWYgkYixMKf5MBFXzRLMEnpnjtUzCGgg2ndY7QYADYIE6r8tIzOnOP6K0K1vzc5M uE/Es2Df5i+72RiMVMrC6X3XAINjM+0HtJ9K0RPE0Mt4XolV0OKT02DlyAAer8hJCrlk XSdkRECfbXvnRVKXNca5RHFA0tTq4aoA00jhNElKODpOwlu8g8Jd9A1Y2O0TXfjw+oBK +T3ulyXwuveJEMwYrN/POaEgPFgBsMJGZsYmx+3NHhMQKfPQz44JHt86G7SiRU0t1y7s hhxw== |
| 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 hugetlb_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>
---
fs/hugetlbfs/inode.c | 42 ++++++++----------------------------------
1 files changed, 8 insertions(+), 34 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c5bc355d8243..14bc0c1fb4fb 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -151,8 +151,8 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long
addr,
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
- unsigned long start_addr;
struct hstate *h = hstate_file(file);
+ struct vm_unmapped_area_info info;
if (len & ~huge_page_mask(h))
return -EINVAL;
@@ -173,39 +173,13 @@ hugetlb_get_unmapped_area(struct file *file, unsigned
long addr,
return addr;
}
- if (len > mm->cached_hole_size)
- start_addr = mm->free_area_cache;
- else {
- start_addr = TASK_UNMAPPED_BASE;
- mm->cached_hole_size = 0;
- }
-
-full_search:
- addr = ALIGN(start_addr, huge_page_size(h));
-
- for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
- /* At this point: (!vma || addr < vma->vm_end). */
- if (TASK_SIZE - len < addr) {
- /*
- * Start a new search - just in case we missed
- * some holes.
- */
- if (start_addr != TASK_UNMAPPED_BASE) {
- start_addr = TASK_UNMAPPED_BASE;
- mm->cached_hole_size = 0;
- goto full_search;
- }
- return -ENOMEM;
- }
-
- if (!vma || addr + len <= vma->vm_start) {
- mm->free_area_cache = addr + len;
- return addr;
- }
- if (addr + mm->cached_hole_size < vma->vm_start)
- mm->cached_hole_size = vma->vm_start - addr;
- addr = ALIGN(vma->vm_end, huge_page_size(h));
- }
+ info.flags = 0;
+ info.length = len;
+ info.low_limit = TASK_UNMAPPED_BASE;
+ info.high_limit = TASK_SIZE;
+ info.align_mask = PAGE_MASK & ~huge_page_mask(h);
+ info.align_offset = 0;
+ return vm_unmapped_area(&info);
}
#endif
--
1.7.7.3
|
| Previous by Date: | [PATCH 04/16] mm: rearrange vm_area_struct for fewer cache misses, Michel Lespinasse |
|---|---|
| Next by Date: | [PATCH 09/16] mm: use vm_unmapped_area() in hugetlbfs on i386 architecture, Michel Lespinasse |
| Previous by Thread: | [PATCH 04/16] mm: rearrange vm_area_struct for fewer cache misses, Michel Lespinasse |
| Next by Thread: | Re: [PATCH 08/16] mm: use vm_unmapped_area() in hugetlbfs, Rik van Riel |
| Indexes: | [Date] [Thread] [Top] [All Lists] |