diff --git a/common/lib/cpuset.cpp b/common/lib/cpuset.cpp index b35ab96e1..951bb917e 100644 --- a/common/lib/cpuset.cpp +++ b/common/lib/cpuset.cpp @@ -28,18 +28,6 @@ using namespace villas::utils; #ifdef __linux__ -CpuSet::operator uintmax_t() -{ - uintmax_t iset = 0; - - for (size_t i = 0; i < num_cpus; i++) { - if (isset(i)) - iset |= 1ULL << i; - } - - return iset; -} - CpuSet::CpuSet(uintmax_t iset) : CpuSet() { @@ -91,6 +79,18 @@ CpuSet::CpuSet(const char *str) : CpuSet(std::string(str)) { } +CpuSet::operator uintmax_t() +{ + uintmax_t iset = 0; + + for (size_t i = 0; i < num_cpus; i++) { + if (isset(i)) + iset |= 1ULL << i; + } + + return iset; +} + CpuSet::operator std::string () { std::stringstream ss; diff --git a/common/lib/kernel/rt.cpp b/common/lib/kernel/rt.cpp index 13fe2fa25..9f8deda4b 100644 --- a/common/lib/kernel/rt.cpp +++ b/common/lib/kernel/rt.cpp @@ -91,6 +91,8 @@ void setProcessAffinity(int affinity) { int ret; + assert(affinity != 0); + Logger logger = logging.get("kernel:rt"); /* Pin threads to CPUs by setting the affinity */ @@ -98,24 +100,26 @@ void setProcessAffinity(int affinity) ret = sched_setaffinity(0, cset_pin.size(), cset_pin); if (ret) - throw SystemError("Failed to set CPU affinity to cores: {}", (std::string) cset_pin); + throw SystemError("Failed to set CPU affinity of process"); - logger->debug("Set affinity to cores: {}", (std::string) cset_pin); + logger->debug("Set affinity to {} {}", cset_pin.count() == 1 ? "core" : "cores", (std::string) cset_pin); } void setThreadAffinity(pthread_t thread, int affinity) { int ret; + assert(affinity != 0); + Logger logger = logging.get("kernel:rt"); CpuSet cset_pin(affinity); ret = pthread_setaffinity_np(thread, cset_pin.size(), cset_pin); if (ret) - throw SystemError("Failed to set CPU affinity to cores: {}", (std::string) cset_pin); + throw SystemError("Failed to set CPU affinity of thread"); - logger->debug("Set affinity of thread {} to cores: {}", (long unsigned) thread, (std::string) cset_pin); + logger->debug("Set affinity of thread {} to {} {}", (long unsigned) thread, cset_pin.count() == 1 ? "core" : "cores", (std::string) cset_pin); } void setPriority(int priority) diff --git a/common/lib/kernel/vfio.cpp b/common/lib/kernel/vfio.cpp index c677f4eb1..0b0e33ac7 100644 --- a/common/lib/kernel/vfio.cpp +++ b/common/lib/kernel/vfio.cpp @@ -76,7 +76,7 @@ namespace villas { Container::Container() - : iova_next(0) + : iova_next(0) { Logger logger = logging.get("kernel:vfio");