diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-19 23:14:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 23:14:31 +0200 |
commit | 7b20fc61bb697779b9c8ee6faf2cacc3710dc387 (patch) | |
tree | 0545a35c9e673c9da48d95b2bebbe63e259630c0 /vespalib | |
parent | 007d059c1f57b689e0e1501977aecccfaee75c43 (diff) | |
parent | df42452e68161a8a12ced132910fe63379b71309 (diff) |
Merge pull request #12977 from vespa-engine/toregge/huge-pages-and-dontdump-flags-are-linux-specific
MAP_HUGETLB and MADV_DONTDUMP are linux specific.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 6aa96992254..4c0675198bb 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -66,7 +66,11 @@ readOptionalEnvironmentVar(const char * name, size_t defaultValue) { void initializeEnvironment() { +#ifdef __linux__ _G_HugeFlags = (getenv("VESPA_USE_HUGEPAGES") != nullptr) ? MAP_HUGETLB : 0; +#else + _G_HugeFlags = 0; +#endif _G_SilenceCoreOnOOM = (getenv("VESPA_SILENCE_CORE_ON_OOM") != nullptr) ? true : false; _G_MMapLogLimit = readOptionalEnvironmentVar("VESPA_MMAP_LOG_LIMIT", std::numeric_limits<size_t>::max()); _G_MMapNoCoreLimit = readOptionalEnvironmentVar("VESPA_MMAP_NOCORE_LIMIT", std::numeric_limits<size_t>::max()); @@ -350,11 +354,13 @@ MMapAllocator::salloc(size_t sz, void * wantedAddress) _G_hasHugePageFailureJustHappened = false; } } +#ifdef __linux__ 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()); } } +#endif if (sz >= _G_MMapLogLimit) { LockGuard guard(_G_lock); _G_HugeMappings[buf] = MMapInfo(mmapId, sz, stackTrace); |