mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-19 09:15:10 +00:00
#1106 Fixed hugepages field in API.
This commit is contained in:
parent
647cbef43c
commit
7a6790d0f6
3 changed files with 52 additions and 17 deletions
|
@ -109,6 +109,14 @@ public:
|
|||
}
|
||||
|
||||
|
||||
size_t ways()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
return status.ways;
|
||||
}
|
||||
|
||||
|
||||
Algorithm algo;
|
||||
Controller *controller;
|
||||
LaunchStatus status;
|
||||
|
@ -135,6 +143,25 @@ xmrig::CpuBackend::~CpuBackend()
|
|||
}
|
||||
|
||||
|
||||
std::pair<size_t, size_t> xmrig::CpuBackend::hugePages() const
|
||||
{
|
||||
std::pair<size_t, size_t> pages(0, 0);
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (d_ptr->algo.family() == Algorithm::RANDOM_X) {
|
||||
pages = Rx::hugePages();
|
||||
}
|
||||
# endif
|
||||
|
||||
std::lock_guard<std::mutex> lock(d_ptr->mutex);
|
||||
|
||||
pages.first += d_ptr->status.hugePages;
|
||||
pages.second += d_ptr->status.pages;
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CpuBackend::isEnabled() const
|
||||
{
|
||||
return d_ptr->controller->config()->cpu().isEnabled();
|
||||
|
@ -292,25 +319,14 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember("asm", false, allocator);
|
||||
# endif
|
||||
|
||||
d_ptr->mutex.lock();
|
||||
uint64_t pages[2] = { d_ptr->status.hugePages, d_ptr->status.pages };
|
||||
const size_t ways = d_ptr->status.ways;
|
||||
d_ptr->mutex.unlock();
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (d_ptr->algo.family() == Algorithm::RANDOM_X) {
|
||||
const auto rxPages = Rx::hugePages();
|
||||
pages[0] += rxPages.first;
|
||||
pages[1] += rxPages.second;
|
||||
}
|
||||
# endif
|
||||
const auto pages = hugePages();
|
||||
|
||||
rapidjson::Value hugepages(rapidjson::kArrayType);
|
||||
hugepages.PushBack(pages[0], allocator);
|
||||
hugepages.PushBack(pages[1], allocator);
|
||||
hugepages.PushBack(pages.first, allocator);
|
||||
hugepages.PushBack(pages.second, allocator);
|
||||
|
||||
out.AddMember("hugepages", hugepages, allocator);
|
||||
out.AddMember("memory", static_cast<uint64_t>(d_ptr->algo.isValid() ? (ways * d_ptr->algo.l3()) : 0), allocator);
|
||||
out.AddMember("memory", static_cast<uint64_t>(d_ptr->algo.isValid() ? (d_ptr->ways() * d_ptr->algo.l3()) : 0), allocator);
|
||||
|
||||
if (d_ptr->threads.empty() || !hashrate()) {
|
||||
return out;
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#define XMRIG_CPUBACKEND_H
|
||||
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
|
||||
|
||||
|
@ -43,6 +46,8 @@ public:
|
|||
CpuBackend(Controller *controller);
|
||||
~CpuBackend() override;
|
||||
|
||||
std::pair<size_t, size_t> hugePages() const;
|
||||
|
||||
protected:
|
||||
bool isEnabled() const override;
|
||||
bool isEnabled(const Algorithm &algorithm) const override;
|
||||
|
|
|
@ -145,10 +145,24 @@ public:
|
|||
reply.AddMember("ua", StringRef(Platform::userAgent()), allocator);
|
||||
reply.AddMember("cpu", Cpu::toJSON(doc), allocator);
|
||||
|
||||
if (version == 1) {
|
||||
reply.AddMember("hugepages", false, allocator);
|
||||
Value hugepages;
|
||||
|
||||
if (!backends.empty() && backends.front()->type() == "cpu") {
|
||||
const auto pages = static_cast<CpuBackend *>(backends.front())->hugePages();
|
||||
if (version > 1) {
|
||||
hugepages.SetArray();
|
||||
hugepages.PushBack(pages.first, allocator);
|
||||
hugepages.PushBack(pages.second, allocator);
|
||||
}
|
||||
else {
|
||||
hugepages = pages.first == pages.second;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hugepages = false;
|
||||
}
|
||||
|
||||
reply.AddMember("hugepages", hugepages, allocator);
|
||||
reply.AddMember("donate_level", controller->config()->pools().donateLevel(), allocator);
|
||||
|
||||
Value algo(kArrayType);
|
||||
|
|
Loading…
Reference in a new issue