Merge pull request #31033 from azat/remap-log

Log size of remapped memory (remap_executable)
This commit is contained in:
Nikolai Kochetov 2021-11-08 17:12:04 +03:00 committed by GitHub
commit 14a3988f8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -595,8 +595,8 @@ if (ThreadFuzzer::instance().isEffective())
if (config().getBool("remap_executable", false))
{
LOG_DEBUG(log, "Will remap executable in memory.");
remapExecutable();
LOG_DEBUG(log, "The code in memory has been successfully remapped.");
size_t size = remapExecutable();
LOG_DEBUG(log, "The code ({}) in memory has been successfully remapped.", ReadableSize(size));
}
if (config().getBool("mlock_executable", false))

View File

@ -1,3 +1,5 @@
#include "remapExecutable.h"
#if defined(__linux__) && defined(__amd64__) && defined(__SSE2__) && !defined(SANITIZER) && defined(NDEBUG) && !defined(SPLIT_SHARED_LIBRARIES)
#include <sys/mman.h>
@ -11,8 +13,6 @@
#include <Common/Exception.h>
#include <fmt/format.h>
#include "remapExecutable.h"
namespace DB
{
@ -136,10 +136,11 @@ __attribute__((__noinline__)) void remapToHugeStep1(void * begin, size_t size)
}
void remapExecutable()
size_t remapExecutable()
{
auto [begin, size] = getMappedArea(reinterpret_cast<void *>(remapExecutable));
remapToHugeStep1(begin, size);
return size;
}
}
@ -149,7 +150,7 @@ void remapExecutable()
namespace DB
{
void remapExecutable() {}
size_t remapExecutable() { return 0; }
}

View File

@ -1,8 +1,12 @@
#pragma once
#include <cstdlib>
namespace DB
{
/// This function tries to reallocate the code of the running program in a more efficient way.
void remapExecutable();
/// @return size of remapped area.
size_t remapExecutable();
}