From dfe70d9ea7599e2aa057bacc2fed3098fbacd799 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 8 Aug 2023 17:48:44 +0700 Subject: [PATCH] Fixed huge pages availability info on Linux. --- src/crypto/common/VirtualMemory_unix.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/crypto/common/VirtualMemory_unix.cpp b/src/crypto/common/VirtualMemory_unix.cpp index 99b961317..003b92e45 100644 --- a/src/crypto/common/VirtualMemory_unix.cpp +++ b/src/crypto/common/VirtualMemory_unix.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018-2020 tevador - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "crypto/common/VirtualMemory.h" #include "backend/cpu/Cpu.h" #include "crypto/common/portable/mm_malloc.h" @@ -25,6 +24,7 @@ #include #include +#include #include @@ -84,7 +84,9 @@ static inline int hugePagesFlag(size_t size) bool xmrig::VirtualMemory::isHugepagesAvailable() { -# if defined(XMRIG_OS_MACOS) && defined(XMRIG_ARM) +# ifdef XMRIG_OS_LINUX + return std::ifstream("/proc/sys/vm/nr_hugepages").good() || std::ifstream("/sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages").good(); +# elif defined(XMRIG_OS_MACOS) && defined(XMRIG_ARM) return false; # else return true;