From: zhigang lu <luzhigang001@gmail.com>
To: mike.kravetz@oracle.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: tonnylu@tencent.com, hzhongzhang@tencent.com, knightzhang@tencent.com
Subject: [PATCH] mm/hugetlb: avoid looping to the same hugepage if !pages and !vmas
Date: Thu, 29 Aug 2019 19:37:22 +0800 [thread overview]
Message-ID: <CABNBeK+6C9ToJcjhGBJQm5dDaddA0USOoRFmRckZ27PhLGUfQg@mail.gmail.com> (raw)
From: Zhigang Lu <tonnylu@tencent.com>
This change greatly decrease the time of mmaping a file in hugetlbfs.
With MAP_POPULATE flag, it takes about 50 milliseconds to mmap a
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
next reply other threads:[~2019-08-29 11:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 11:37 zhigang lu [this message]
2019-08-29 11:54 ` Matthew Wilcox
2019-08-29 12:36 ` 答复: [PATCH] mm/hugetlb: avoid looping to the same hugepage if !pages and !vmas(Internet mail) tonnylu(陆志刚)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABNBeK+6C9ToJcjhGBJQm5dDaddA0USOoRFmRckZ27PhLGUfQg@mail.gmail.com \
--to=luzhigang001@gmail.com \
--cc=hzhongzhang@tencent.com \
--cc=knightzhang@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=tonnylu@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox