提交 4bfc130d 编写于 作者: X Xiao Guangrong 提交者: Linus Torvalds

hugetlbfs: fix hugetlb_get_unmapped_area()

Use/update cached_hole_size and free_area_cache properly to speedup
finding of a free region.
Signed-off-by: NXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hillf Danton <dhillf@gmail.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 aad6ec37
...@@ -154,10 +154,12 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, ...@@ -154,10 +154,12 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
return addr; return addr;
} }
if (len > mm->cached_hole_size)
start_addr = mm->free_area_cache; start_addr = mm->free_area_cache;
else {
if (len <= mm->cached_hole_size)
start_addr = TASK_UNMAPPED_BASE; start_addr = TASK_UNMAPPED_BASE;
mm->cached_hole_size = 0;
}
full_search: full_search:
addr = ALIGN(start_addr, huge_page_size(h)); addr = ALIGN(start_addr, huge_page_size(h));
...@@ -171,13 +173,18 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, ...@@ -171,13 +173,18 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
*/ */
if (start_addr != TASK_UNMAPPED_BASE) { if (start_addr != TASK_UNMAPPED_BASE) {
start_addr = TASK_UNMAPPED_BASE; start_addr = TASK_UNMAPPED_BASE;
mm->cached_hole_size = 0;
goto full_search; goto full_search;
} }
return -ENOMEM; return -ENOMEM;
} }
if (!vma || addr + len <= vma->vm_start) if (!vma || addr + len <= vma->vm_start) {
mm->free_area_cache = addr + len;
return addr; 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)); addr = ALIGN(vma->vm_end, huge_page_size(h));
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册