* [PATCH] mm/hugetlb: avoid looping to the same hugepage if !pages and
@ 2019-08-29 4:32 tonnylu(陆志刚)
0 siblings, 0 replies; only message in thread
From: tonnylu(陆志刚) @ 2019-08-29 4:32 UTC (permalink / raw)
To: mike.kravetz, linux-mm, linux-kernel
Cc: hzhongzhang(张昊中),
knightzhang(张宗明),
tonnylu(陆志刚)
[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]
This change greatly decrease the time of mmaping a file in hugetlbfs.
With MAP_POPULATE flag, it takes about 50 milliseconds to mmap an
existing 128GB file in hugetlbfs. With this change, it takes less
then 1 millisecond.
Signed-off-by: Zhigang Lu <tonnylu@tencent.com>
Reviewed-by: Haozhong Zhang <hzhongzhang@tencent.com>
Reviewed-by: Zongming Zhang <knightzhang@tencent.com>
---
mm/hugetlb.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 6d7296d..2df941a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4391,6 +4391,17 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
break;
}
}
+
+ if (!pages && !vmas && !pfn_offset &&
+ (vaddr + huge_page_size(h) < vma->vm_end) &&
+ (remainder >= pages_per_huge_page(h))) {
+ vaddr += huge_page_size(h);
+ remainder -= pages_per_huge_page(h);
+ i += pages_per_huge_page(h);
+ spin_unlock(ptl);
+ continue;
+ }
+
same_page:
if (pages) {
pages[i] = mem_map_offset(page, pfn_offset);
--
1.8.3.1
[-- Attachment #2: Type: text/html, Size: 6643 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-29 4:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29 4:32 [PATCH] mm/hugetlb: avoid looping to the same hugepage if !pages and tonnylu(陆志刚)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox