summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-11 07:44:24 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-05-11 07:44:24 +0000
commite7a5599c2fda0ed779d5c9a11dd8d1f2f2e47567 (patch)
treeeb5b2b1aa044fd3455ccadd8c65978e3bef96a75 /vespalib
parent631c539a74a1500b7956071e1ccf375e45ceca7b (diff)
Add madvise(buf, len, MADV_HUGEPAGE) call to signal that you strongly prefer huge pages.
This will make a difference if /sys/kernel/mm/transparent_hugepage/enabled has been set to [madvise], and not [always].
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp
index 3f49fc4b427..0f453111c72 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.cpp
+++ b/vespalib/src/vespa/vespalib/util/alloc.cpp
@@ -353,6 +353,9 @@ MMapAllocator::salloc(size_t sz, void * wantedAddress)
store_relaxed(_G_hasHugePageFailureJustHappened, false);
}
#ifdef __linux__
+ if (madvise(buf, sz, MADV_HUGEPAGE) != 0) {
+ // Just an advise, not everyone will listen...
+ }
if (sz >= _G_MMapNoCoreLimit) {
if (madvise(buf, sz, MADV_DONTDUMP) != 0) {
LOG(warning, "Failed madvise(%p, %ld, MADV_DONTDUMP) = '%s'", buf, sz, FastOS_FileInterface::getLastErrorString().c_str());