Return correct hugePages count if NUMA mode used.

This commit is contained in:
XMRig 2019-07-27 21:31:11 +07:00
parent 828fc065b0
commit 9df9275120
4 changed files with 27 additions and 9 deletions

View file

@ -295,13 +295,10 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
# ifdef XMRIG_ALGO_RANDOMX # ifdef XMRIG_ALGO_RANDOMX
if (d_ptr->algo.family() == Algorithm::RANDOM_X) { if (d_ptr->algo.family() == Algorithm::RANDOM_X) {
RxDataset *dataset = Rx::dataset(0); // FIXME const auto rxPages = Rx::hugePages();
if (dataset) {
const auto rxPages = dataset->hugePages();
pages[0] += rxPages.first; pages[0] += rxPages.first;
pages[1] += rxPages.second; pages[1] += rxPages.second;
} }
}
# endif # endif
rapidjson::Value hugepages(rapidjson::kArrayType); rapidjson::Value hugepages(rapidjson::kArrayType);

View file

@ -146,7 +146,6 @@ static RxPrivate *d_ptr = new RxPrivate();
} // namespace xmrig } // namespace xmrig
bool xmrig::Rx::isReady(const Job &job, uint32_t nodeId) bool xmrig::Rx::isReady(const Job &job, uint32_t nodeId)
{ {
d_ptr->lock(); d_ptr->lock();
@ -157,7 +156,6 @@ bool xmrig::Rx::isReady(const Job &job, uint32_t nodeId)
} }
xmrig::RxDataset *xmrig::Rx::dataset(uint32_t nodeId) xmrig::RxDataset *xmrig::Rx::dataset(uint32_t nodeId)
{ {
d_ptr->lock(); d_ptr->lock();
@ -168,6 +166,27 @@ xmrig::RxDataset *xmrig::Rx::dataset(uint32_t nodeId)
} }
std::pair<size_t, size_t> xmrig::Rx::hugePages()
{
std::pair<size_t, size_t> pages(0, 0);
d_ptr->lock();
for (auto const &item : d_ptr->datasets) {
if (!item.second) {
continue;
}
const auto p = item.second->hugePages();
pages.first += p.first;
pages.second += p.second;
}
d_ptr->unlock();
return pages;
}
void xmrig::Rx::init(const Job &job, int initThreads, bool hugePages, bool numa) void xmrig::Rx::init(const Job &job, int initThreads, bool hugePages, bool numa)
{ {
if (job.algorithm().family() != Algorithm::RANDOM_X) { if (job.algorithm().family() != Algorithm::RANDOM_X) {

View file

@ -29,6 +29,7 @@
#include <stdint.h> #include <stdint.h>
#include <utility>
namespace xmrig namespace xmrig
@ -45,6 +46,7 @@ class Rx
public: public:
static bool isReady(const Job &job, uint32_t nodeId); static bool isReady(const Job &job, uint32_t nodeId);
static RxDataset *dataset(uint32_t nodeId); static RxDataset *dataset(uint32_t nodeId);
static std::pair<size_t, size_t> hugePages();
static void init(const Job &job, int initThreads, bool hugePages, bool numa); static void init(const Job &job, int initThreads, bool hugePages, bool numa);
static void stop(); static void stop();