summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-22 13:53:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-22 13:53:53 +0000
commita85da00270ae35bef3bf560e64bf822e0be062f4 (patch)
tree486243d0441420e9fa8e063067d3f1e1997f5975
parent14c095ede55284f23dcd0b1f60344f8460c2dbfa (diff)
Ensure all mmaped files are marked so they will not be part of any coredump.
-rw-r--r--searchlib/src/vespa/searchlib/util/fileutil.cpp1
-rw-r--r--vespalib/src/vespa/fastos/unix_file.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/io/mapped_file_input.cpp4
3 files changed, 7 insertions, 2 deletions
diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp
index cdeca9ce95c..c2f86224312 100644
--- a/searchlib/src/vespa/searchlib/util/fileutil.cpp
+++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp
@@ -36,6 +36,7 @@ LoadedMmap::LoadedMmap(const vespalib::string &fileName)
if (sz) {
void *tmpBuffer = mmap(nullptr, sz, PROT_READ, MAP_PRIVATE, fd.fd(), 0);
if (tmpBuffer != MAP_FAILED) {
+ madvise(tmpBuffer, sz, MADV_DONTDUMP);
_mapSize = sz;
_mapBuffer = tmpBuffer;
uint32_t hl = GenericHeader::getMinSize();
diff --git a/vespalib/src/vespa/fastos/unix_file.cpp b/vespalib/src/vespa/fastos/unix_file.cpp
index 692674b95bd..6d10338aec1 100644
--- a/vespalib/src/vespa/fastos/unix_file.cpp
+++ b/vespalib/src/vespa/fastos/unix_file.cpp
@@ -213,6 +213,10 @@ FastOS_UNIX_File::Open(unsigned int openFlags, const char *filename)
if (eCode != 0) {
fprintf(stderr, "Failed: posix_madvise(%p, %ld, %d) = %d\n", mbase, mlen, fadviseOptions, eCode);
}
+ eCode = madvise(mbase, mlen, MADV_DONTDUMP);
+ if (eCode != 0) {
+ fprintf(stderr, "Failed: madvise(%p, %ld, MADV_DONTDUMP) = %d\n", mbase, mlen, eCode);
+ }
#endif
_mmapbase = mbase;
_mmaplen = mlen;
diff --git a/vespalib/src/vespa/vespalib/io/mapped_file_input.cpp b/vespalib/src/vespa/vespalib/io/mapped_file_input.cpp
index 854ca29c66a..7f1f0d003b7 100644
--- a/vespalib/src/vespa/vespalib/io/mapped_file_input.cpp
+++ b/vespalib/src/vespa/vespalib/io/mapped_file_input.cpp
@@ -16,11 +16,11 @@ MappedFileInput::MappedFileInput(const vespalib::string &file_name)
{
struct stat info;
if ((_fd != -1) && fstat(_fd, &info) == 0) {
- _data = static_cast<char*>(mmap(0, info.st_size,
- PROT_READ, MAP_SHARED, _fd, 0));
+ _data = static_cast<char*>(mmap(0, info.st_size, PROT_READ, MAP_SHARED, _fd, 0));
if (_data != MAP_FAILED) {
_size = info.st_size;
madvise(_data, _size, MADV_SEQUENTIAL);
+ madvise(_data, _size, MADV_DONTDUMP);
}
}
}