diff options
author | stevenjb <stevenjb@chromium.org> | 2016-02-10 10:08:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-10 18:10:07 +0000 |
commit | f0aab631c727924fb1ae2ff9e6ba5878c073b717 (patch) | |
tree | ea432b74b9342cf3c459f7e17b4ce16f9fae5310 /chromeos/hugepage_text | |
parent | 26511aef79e6b23a92c8956976588786f09a2e42 (diff) | |
download | chromium_src-f0aab631c727924fb1ae2ff9e6ba5878c073b717.zip chromium_src-f0aab631c727924fb1ae2ff9e6ba5878c073b717.tar.gz chromium_src-f0aab631c727924fb1ae2ff9e6ba5878c073b717.tar.bz2 |
Revert of Make text section 2MB aligned for hugepages. (patchset #7 id:120001 of https://codereview.chromium.org/1619713007/ )
Reason for revert:
Causing failures on x86-alex, peach_pit, and daisy_skate (render process crash in login screen).
Original issue's description:
> Make text section 2MB aligned for hugepages.
>
> If we do not use the option '-Wl,--section-start=.text=2001000' at
> link time, the performance gain on hugepages is gone. This is probably
> because the original text section is not 2MB aligned and the after
> mremap, the hugepage is not preserved.
>
> BUG=chromium:569963
> TEST=The performance gain is back on micro benchmarks.
>
> Committed: https://crrev.com/1384534a94e6324d74906f0cbc1e707606c063f2
> Cr-Commit-Position: refs/heads/master@{#373673}
TBR=rickyz@chromium.org,cmtice@chromium.org,kenchen@google.com,llozano@chromium.org,shenhan@chromium.org,yunlian@chromium.org,yunlian@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=chromium:569963
Review URL: https://codereview.chromium.org/1687033002
Cr-Commit-Position: refs/heads/master@{#374687}
Diffstat (limited to 'chromeos/hugepage_text')
-rw-r--r-- | chromeos/hugepage_text/hugepage_text.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/chromeos/hugepage_text/hugepage_text.cc b/chromeos/hugepage_text/hugepage_text.cc index 4856660..ccae53f 100644 --- a/chromeos/hugepage_text/hugepage_text.cc +++ b/chromeos/hugepage_text/hugepage_text.cc @@ -36,6 +36,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. // If not used carefully, mremap() a hugepage segment directly onto small page @@ -124,9 +129,10 @@ static void NoAsanAlignedMemcpy(void* dst, void* src, size_t size) { // 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 @@ static void MremapHugetlbText(void* vaddr, const size_t hsize) { // 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 |