1
0
mirror of https://github.com/xmrig/xmrig.git synced 2026-06-29 06:01:37 -04:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Tony Butler 5c2405f841 Merge 14128cbdb4 into a7be8cb80c 2024-06-05 03:56:53 +07:00
XMRig a7be8cb80c Remove chdir call after fork. 2024-06-05 03:45:37 +07:00
XMRig 2ce16df423 Create signal handles after fork() call, replace #3492. 2024-06-05 03:23:58 +07:00
Tony Butler 14128cbdb4 hwloc: Clarify reason for failed binding ("can't bind memory") 2024-05-30 08:20:56 -06:00
XMRig 5eaa6c152e v6.21.4-dev 2024-04-23 16:51:58 +07:00
XMRig 6972f727c1 Merge branch 'master' into dev 2024-04-23 16:50:58 +07:00
8 changed files with 54 additions and 34 deletions
+4 -5
View File
@@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com> * Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd> * Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <cstdlib> #include <cstdlib>
#include <uv.h> #include <uv.h>
@@ -61,13 +60,13 @@ int xmrig::App::exec()
return 2; return 2;
} }
m_signals = std::make_shared<Signals>(this);
int rc = 0; int rc = 0;
if (background(rc)) { if (background(rc)) {
return rc; return rc;
} }
m_signals = std::make_shared<Signals>(this);
rc = m_controller->init(); rc = m_controller->init();
if (rc != 0) { if (rc != 0) {
return rc; return rc;
+3 -11
View File
@@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com> * Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -22,7 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <cstdlib> #include <cstdlib>
#include <csignal> #include <csignal>
#include <cerrno> #include <cerrno>
@@ -53,16 +52,9 @@ bool xmrig::App::background(int &rc)
return true; return true;
} }
i = setsid(); if (setsid() < 0) {
if (i < 0) {
LOG_ERR("setsid() failed (errno = %d)", errno); LOG_ERR("setsid() failed (errno = %d)", errno);
} }
i = chdir("/");
if (i < 0) {
LOG_ERR("chdir() failed (errno = %d)", errno);
}
return false; return false;
} }
+5 -1
View File
@@ -29,6 +29,10 @@
#ifdef XMRIG_FEATURE_HWLOC #ifdef XMRIG_FEATURE_HWLOC
using hwloc_const_bitmap_t = const struct hwloc_bitmap_s *; using hwloc_const_bitmap_t = const struct hwloc_bitmap_s *;
using hwloc_topology_t = struct hwloc_topology *; using hwloc_topology_t = struct hwloc_topology *;
#define MEMBIND_SUCCESS 1
#define MEMBIND_FAIL_SUPP -1
#define MEMBIND_FAIL_NODE -2
#define MEMBIND_FAIL_BIND -3
#endif #endif
@@ -124,7 +128,7 @@ public:
virtual uint32_t model() const = 0; virtual uint32_t model() const = 0;
# ifdef XMRIG_FEATURE_HWLOC # ifdef XMRIG_FEATURE_HWLOC
virtual bool membind(hwloc_const_bitmap_t nodeset) = 0; virtual int8_t membind(hwloc_const_bitmap_t nodeset) = 0;
virtual const std::vector<uint32_t> &nodeset() const = 0; virtual const std::vector<uint32_t> &nodeset() const = 0;
virtual hwloc_topology_t topology() const = 0; virtual hwloc_topology_t topology() const = 0;
# endif # endif
+14 -4
View File
@@ -23,6 +23,7 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <errno.h>
#include <hwloc.h> #include <hwloc.h>
@@ -191,16 +192,25 @@ xmrig::HwlocCpuInfo::~HwlocCpuInfo()
} }
bool xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset) int8_t xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset)
{ {
if (!hwloc_topology_get_support(m_topology)->membind->set_thisthread_membind) { if (!hwloc_topology_get_support(m_topology)->membind->set_thisthread_membind) {
return false; return MEMBIND_FAIL_SUPP;
} }
# if HWLOC_API_VERSION >= 0x20000 # if HWLOC_API_VERSION >= 0x20000
return hwloc_set_membind(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD | HWLOC_MEMBIND_BYNODESET) >= 0; int rv = hwloc_set_membind(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD | HWLOC_MEMBIND_BYNODESET);
int error = errno;
if (rv < 0) {
LOG_WARN("hwloc_set_membind() error: \"%s\"\n", strerror(error));
return MEMBIND_FAIL_BIND;
}
return MEMBIND_SUCCESS;
# else # else
return hwloc_set_membind_nodeset(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD) >= 0; return (hwloc_set_membind_nodeset(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD) >= 0)
? MEMBIND_SUCCESS : MEMBIND_FAIL_BIND;
# endif # endif
} }
+1 -1
View File
@@ -38,7 +38,7 @@ public:
~HwlocCpuInfo() override; ~HwlocCpuInfo() override;
protected: protected:
bool membind(hwloc_const_bitmap_t nodeset) override; int8_t membind(hwloc_const_bitmap_t nodeset) override;
CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const override; CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const override;
inline const char *backend() const override { return m_backend; } inline const char *backend() const override { return m_backend; }
+7 -2
View File
@@ -34,8 +34,13 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t affinity)
auto pu = hwloc_get_pu_obj_by_os_index(Cpu::info()->topology(), static_cast<unsigned>(affinity)); auto pu = hwloc_get_pu_obj_by_os_index(Cpu::info()->topology(), static_cast<unsigned>(affinity));
if (pu == nullptr || !Cpu::info()->membind(pu->nodeset)) { if (pu == nullptr) {
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory\"", affinity); LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory: hwloc_get_pu_obj_by_os_index() failed\"", affinity);
return 0;
}
if (Cpu::info()->membind(pu->nodeset) < 0) {
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory: Cpu::info()->membind() failed\"", affinity);
return 0; return 0;
} }
+18 -8
View File
@@ -42,20 +42,20 @@ constexpr size_t oneMiB = 1024 * 1024;
static std::mutex mutex; static std::mutex mutex;
static bool bindToNUMANode(uint32_t nodeId) static int8_t bindToNUMANode(uint32_t nodeId)
{ {
auto node = hwloc_get_numanode_obj_by_os_index(Cpu::info()->topology(), nodeId); auto node = hwloc_get_numanode_obj_by_os_index(Cpu::info()->topology(), nodeId);
if (!node) { if (!node) {
return false; return MEMBIND_FAIL_NODE;
} }
if (Cpu::info()->membind(node->nodeset)) { if (Cpu::info()->membind(node->nodeset) > 0) {
Platform::setThreadAffinity(static_cast<uint64_t>(hwloc_bitmap_first(node->cpuset))); Platform::setThreadAffinity(static_cast<uint64_t>(hwloc_bitmap_first(node->cpuset)));
return true; return MEMBIND_SUCCESS;
} }
return false; return MEMBIND_FAIL_BIND;
} }
@@ -210,10 +210,20 @@ private:
static void allocate(RxNUMAStoragePrivate *d_ptr, uint32_t nodeId, bool hugePages, bool oneGbPages) static void allocate(RxNUMAStoragePrivate *d_ptr, uint32_t nodeId, bool hugePages, bool oneGbPages)
{ {
const uint64_t ts = Chrono::steadyMSecs(); const uint64_t ts = Chrono::steadyMSecs();
const int8_t br = bindToNUMANode(nodeId);
if (!bindToNUMANode(nodeId)) { if (br < 0) {
printSkipped(nodeId, "can't bind memory"); switch (br) {
case MEMBIND_FAIL_SUPP:
printSkipped(nodeId, "can't bind memory: hwloc_topology_get_support() failed");
break;
case MEMBIND_FAIL_NODE:
printSkipped(nodeId, "can't bind memory: hwloc_get_numanode_obj_by_os_index() failed");
break;
case MEMBIND_FAIL_BIND:
printSkipped(nodeId, "can't bind memory: Cpu::info()->membind() failed");
break;
}
return; return;
} }
+2 -2
View File
@@ -22,7 +22,7 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "XMRig miner" #define APP_DESC "XMRig miner"
#define APP_VERSION "6.21.3" #define APP_VERSION "6.21.4-dev"
#define APP_DOMAIN "xmrig.com" #define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com" #define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com"
@@ -30,7 +30,7 @@
#define APP_VER_MAJOR 6 #define APP_VER_MAJOR 6
#define APP_VER_MINOR 21 #define APP_VER_MINOR 21
#define APP_VER_PATCH 3 #define APP_VER_PATCH 4
#ifdef _MSC_VER #ifdef _MSC_VER
# if (_MSC_VER >= 1930) # if (_MSC_VER >= 1930)