diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-12 15:09:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-12 15:09:08 +0000 |
commit | 3b0a4bdf343495d8d9531b3eb5d81e2519e65dde (patch) | |
tree | 00990ab6613143165a7e5f6a00f3f3e920aa004f /vespalib | |
parent | 5548085972dd960994152d02f8a5e4322fbc0188 (diff) |
Add some more information when madvise/munmap fails, and allow madvise to fail as it might depending on how huge pages are set up.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 0f453111c72..c79db622901 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -411,10 +411,21 @@ void MMapAllocator::free(PtrAndSize alloc) const { void MMapAllocator::sfree(PtrAndSize alloc) { if (alloc.first != nullptr) { - int retval = madvise(alloc.first, alloc.second, MADV_DONTNEED); - assert(retval == 0); - retval = munmap(alloc.first, alloc.second); - assert(retval == 0); + int madvise_retval = madvise(alloc.first, alloc.second, MADV_DONTNEED); + if (madvise_retval != 0) { + std::error_code ec(errno, std::system_category()); + if (errno == EINVAL) { + LOG(debug, "madvise(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, madvise_retval, ec.message().c_str()); + } else { + LOG(warning, "madvise(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, madvise_retval, ec.message().c_str()); + } + } + int munmap_retval = munmap(alloc.first, alloc.second); + if (munmap_retval != 0) { + std::error_code ec(errno, std::system_category()); + LOG(warning, "munmap(%p, %lx)=%d, errno=%s", alloc.first, alloc.second, munmap_retval, ec.message().c_str()); + abort(); + } if (alloc.second >= _G_MMapLogLimit) { std::lock_guard guard(_G_lock); MMapInfo info = _G_HugeMappings[alloc.first]; |