Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: chromeos/hugepage_text/hugepage_text.cc

Issue 1687033002: Revert of Make text section 2MB aligned for hugepages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/hugepage_text/hugepage_text.cc
diff --git a/chromeos/hugepage_text/hugepage_text.cc b/chromeos/hugepage_text/hugepage_text.cc
index 4856660fb44d0ffbdf9fb0ec3225fb1c18709946..ccae53f723fdbd9e181f5421fd82c2fdc851062b 100644
--- a/chromeos/hugepage_text/hugepage_text.cc
+++ b/chromeos/hugepage_text/hugepage_text.cc
@@ -35,6 +35,11 @@
const int kMmapFlags = (MAP_ANONYMOUS | MAP_SHARED);
const int kMmapHtlbFlags = (kMmapFlags | MAP_HUGETLB);
const int kMremapFlags = (MREMAP_MAYMOVE | MREMAP_FIXED);
+
+// The number of hugepages we want to use to map chrome text section
+// to hugepages. With the help of AutoFDO, the hot functions are grouped
+// in to a small area of the binary.
+const int kNumHugePages = 15;
// mremap syscall is always supported for small page segment on all kernels.
// However, it is not the case for hugepage.
@@ -124,9 +129,10 @@
// Effect: physical backing page changed from small page to hugepage. If there
// are error condition, the remapping operation is aborted.
static void MremapHugetlbText(void* vaddr, const size_t hsize) {
- DCHECK_EQ(0ul, reinterpret_cast<uintptr_t>(vaddr) & ~kHpageMask);
void* haddr = MAP_FAILED;
- if (HugetlbMremapSupported()) {
+
+ if ((reinterpret_cast<intptr_t>(vaddr) & ~kHpageMask) == 0 &&
+ HugetlbMremapSupported()) {
// Try anon hugepage from static hugepage pool only if the source address
// is hugepage aligned, otherwise, mremap below has non-recoverable error.
haddr = mmap(NULL, hsize, kProtection, kMmapHtlbFlags, 0, 0);
@@ -166,18 +172,15 @@
// Effect: physical backing page changed from small page to hugepage. If there
// are error condition, the remaping operation is aborted.
static void RemapHugetlbText(void* vaddr, const size_t segsize) {
- // remove unaligned head regions
- size_t head_gap = (kHpageSize - reinterpret_cast<size_t>(vaddr) % kHpageSize)
- % kHpageSize;
- size_t addr = reinterpret_cast<size_t>(vaddr) + head_gap;
-
- int hsize = segsize - head_gap;
+ int hsize = segsize;
+ if (segsize > kHpageSize * kNumHugePages)
+ hsize = kHpageSize * kNumHugePages;
hsize = hsize & kHpageMask;
if (hsize == 0)
return;
- MremapHugetlbText(reinterpret_cast<void *>(addr), hsize);
+ MremapHugetlbText(vaddr, hsize);
}
// For a given ELF program header descriptor, iterates over all segments within
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698