New summary information about 1GB pages.
This commit is contained in:
parent
91b50f1ac8
commit
86e25a13e3
4 changed files with 46 additions and 22 deletions
|
@ -60,26 +60,28 @@ inline static const char *asmName(Assembly::Id assembly)
|
|||
|
||||
|
||||
static void print_memory(Config *config) {
|
||||
# ifdef _WIN32
|
||||
# ifdef XMRIG_OS_WIN
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s",
|
||||
"HUGE PAGES", config->cpu().isHugePages() ? (VirtualMemory::isHugepagesAvailable() ? GREEN_BOLD("permission granted") : RED_BOLD("unavailable")) : RED_BOLD("disabled"));
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "1GB PAGES", YELLOW_BOLD("unavailable"));
|
||||
# else
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "HUGE PAGES", config->cpu().isHugePages() ? GREEN_BOLD("supported") : RED_BOLD("disabled"));
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s",
|
||||
"1GB PAGES", Cpu::info()->hasOneGbPages() ? GREEN_BOLD("available on Linux") : RED_BOLD("unavailable"));
|
||||
"1GB PAGES", config->cpu().isOneGbPages() ? (VirtualMemory::isOneGbPagesAvailable() ? GREEN_BOLD("supported") : YELLOW_BOLD("unavailable")) : YELLOW_BOLD("disabled"));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static void print_cpu(Config *)
|
||||
{
|
||||
const ICpuInfo *info = Cpu::info();
|
||||
const auto info = Cpu::info();
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%zu)") " %sx64 %sAES %sPDPE1GB",
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%zu)") " %sx64 %sAES",
|
||||
"CPU",
|
||||
info->brand(),
|
||||
info->packages(),
|
||||
info->isX64() ? GREEN_BOLD_S : RED_BOLD_S "-",
|
||||
info->hasAES() ? GREEN_BOLD_S : RED_BOLD_S "-",
|
||||
info->hasOneGbPages() ? GREEN_BOLD_S : RED_BOLD_S "-"
|
||||
info->hasAES() ? GREEN_BOLD_S : RED_BOLD_S "-"
|
||||
);
|
||||
# if defined(XMRIG_FEATURE_LIBCPUID) || defined (XMRIG_FEATURE_HWLOC)
|
||||
Log::print(WHITE_BOLD(" %-13s") BLACK_BOLD("L2:") WHITE_BOLD("%.1f MB") BLACK_BOLD(" L3:") WHITE_BOLD("%.1f MB")
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
}
|
||||
|
||||
static bool isHugepagesAvailable();
|
||||
static bool isOneGbPagesAvailable();
|
||||
static uint32_t bindToNUMANode(int64_t affinity);
|
||||
static void *allocateExecutableMemory(size_t size);
|
||||
static void *allocateLargePagesMemory(size_t size);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <sys/mman.h>
|
||||
|
||||
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "crypto/common/portable/mm_malloc.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
|
||||
|
@ -38,12 +39,27 @@
|
|||
#endif
|
||||
|
||||
|
||||
#if defined (XMRIG_OS_LINUX) && (defined(MAP_HUGE_1GB) || defined(MAP_HUGE_SHIFT))
|
||||
# define XMRIG_HAS_1GB_PAGES
|
||||
#endif
|
||||
|
||||
|
||||
bool xmrig::VirtualMemory::isHugepagesAvailable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::VirtualMemory::isOneGbPagesAvailable()
|
||||
{
|
||||
# ifdef XMRIG_HAS_1GB_PAGES
|
||||
return Cpu::info()->hasOneGbPages();
|
||||
# else
|
||||
return false;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
|
@ -72,24 +88,23 @@ void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size)
|
|||
|
||||
void *xmrig::VirtualMemory::allocateOneGbPagesMemory(size_t size)
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
void *mem = MAP_FAILED;
|
||||
# elif defined(__FreeBSD__)
|
||||
void *mem = MAP_FAILED;
|
||||
# else
|
||||
# ifdef XMRIG_HAS_1GB_PAGES
|
||||
if (isOneGbPagesAvailable()) {
|
||||
# if defined(MAP_HUGE_1GB)
|
||||
constexpr int flag_1gb = MAP_HUGE_1GB;
|
||||
# elif defined(MAP_HUGE_SHIFT)
|
||||
constexpr int flag_1gb = (30 << MAP_HUGE_SHIFT);
|
||||
# else
|
||||
constexpr int flag_1gb = 0;
|
||||
# endif
|
||||
|
||||
# if defined(MAP_HUGE_1GB)
|
||||
constexpr int flag_1gb = MAP_HUGE_1GB;
|
||||
# elif defined(MAP_HUGE_SHIFT)
|
||||
constexpr int flag_1gb = (30 << MAP_HUGE_SHIFT);
|
||||
# else
|
||||
constexpr int flag_1gb = 0;
|
||||
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE | flag_1gb, 0, 0);
|
||||
|
||||
return mem == MAP_FAILED ? nullptr : mem;
|
||||
}
|
||||
# endif
|
||||
|
||||
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE | flag_1gb, 0, 0);
|
||||
# endif
|
||||
|
||||
return mem == MAP_FAILED ? nullptr : mem;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,6 +156,12 @@ bool xmrig::VirtualMemory::isHugepagesAvailable()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::VirtualMemory::isOneGbPagesAvailable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
return VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
|
@ -175,7 +181,7 @@ void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size)
|
|||
}
|
||||
|
||||
|
||||
void *xmrig::VirtualMemory::allocateOneGbPagesMemory(size_t size)
|
||||
void *xmrig::VirtualMemory::allocateOneGbPagesMemory(size_t)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue