Skip to content

Commit

Permalink
Add AUTO_HUGEPAGE feature to disable writing to nr_hugepages
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudz76 committed Dec 17, 2022
1 parent 4d0b8c9 commit f32dc65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ option(WITH_VAES "Enable VAES instructions for Cryptonight" ON)
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF)
option(WITH_DMI "Enable DMI/SMBIOS reader" ON)
option(WITH_AUTO_HUGEPAGE "Enable Automatic setting of nr_hugepages (Linux Only)" ON)

option(BUILD_STATIC "Build static binary" OFF)
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
Expand Down Expand Up @@ -180,6 +181,10 @@ else()
if (XMRIG_OS_ANDROID)
set(EXTRA_LIBS pthread rt dl log)
elseif (XMRIG_OS_LINUX)
if (WITH_AUTO_HUGEPAGE)
add_definitions(/DXMRIG_FEATURE_AUTO_HUGEPAGE)
endif()

list(APPEND SOURCES_OS
src/crypto/common/LinuxMemory.h
src/crypto/common/LinuxMemory.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/crypto/common/LinuxMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ bool xmrig::LinuxMemory::reserve(size_t size, uint32_t node, size_t hugePageSize
return false;
}

# ifdef XMRIG_FEATURE_AUTO_HUGEPAGE
return write_nr_hugepages(node, hugePageSize, std::max<size_t>(nr_hugepages(node, hugePageSize), 0) + (required - available));
# else
return false;
# endif
}


Expand Down

0 comments on commit f32dc65

Please sign in to comment.