Commit 9829511e authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

Merge remote-tracking branch 'origin/fix-affinity' into develop

parents 05dc3202 09a93c86
......@@ -61,6 +61,8 @@ public:
*/
CpuSet(const std::string &str);
CpuSet(const char *str);
/** Convert integer to cpu_set_t.
*
* @param set An integer number which is used as the mask
......
......@@ -43,7 +43,7 @@ public:
};
protected:
int _width; /**< The real width of this column. Calculated by table_header() */
int _width; /**< The real width of this column. Calculated by Table::resize() */
int width; /**< Width of the column. */
......@@ -95,4 +95,4 @@ public:
}
};
/** @} */
\ No newline at end of file
/** @} */
......@@ -87,6 +87,10 @@ CpuSet::CpuSet(const std::string &str) :
}
}
CpuSet::CpuSet(const char *str)
: CpuSet(std::string(str))
{ }
CpuSet::operator std::string ()
{
std::stringstream ss;
......
......@@ -172,7 +172,7 @@ void hist_plot(const struct hist *h)
std::vector<TableColumn> cols = {
{ -9, TableColumn::align::RIGHT, "Value", "%+9.3g" },
{ -6, TableColumn::align::RIGHT, "Count", "%6ju" },
{ 0, TableColumn::align::LEFT, "Plot", "%s", "occurences" }
{ 0, TableColumn::align::LEFT, "Plot", "%s", "occurences" }
};
Table table = Table(cols);
......@@ -189,7 +189,7 @@ void hist_plot(const struct hist *h)
for (int i = 0; i < bar; i++)
buf = strcatf(&buf, "\u2588");
table.row(value, cnt, buf);
table.row(3, value, cnt, buf);
free(buf);
}
......
......@@ -81,29 +81,24 @@ void setAffinity(int affinity)
Logger logger = logging.get("kernel:rt");
/* Pin threads to CPUs by setting the affinity */
CpuSet cset_pin, cset_isol, cset_non_isol;
cset_pin = CpuSet(affinity);
CpuSet cset_pin(affinity);
is_isol = kernel_get_cmdline_param("isolcpus", isolcpus, sizeof(isolcpus));
if (is_isol) {
if (is_isol)
logger->warn("You should reserve some cores for " PROJECT_NAME " (see 'isolcpus')");
cset_isol.zero();
}
else {
cset_isol = CpuSet(isolcpus);
cset_non_isol = cset_isol ^ cset_pin;
CpuSet cset_isol(isolcpus);
CpuSet cset_non_isol = ~cset_isol & cset_pin;
if (cset_non_isol.count() > 0)
logger->warn("Affinity setting includes cores which are not isolated: affinity={} isolcpus={}", (std::string) cset_pin, (std::string) cset_isol);
logger->warn("Affinity setting includes cores which are not isolated: affinity={}, isolcpus={}, non_isolated={}", (std::string) cset_pin, (std::string) cset_isol, (std::string) cset_non_isol);
}
ret = sched_setaffinity(0, cset_pin.size(), cset_pin);
if (ret)
throw SystemError("Failed to set CPU affinity to {}", (std::string) cset_pin);
throw SystemError("Failed to set CPU affinity to cores: {}", (std::string) cset_pin);
logger->debug("Set affinity to {}", (std::string) cset_pin);
logger->debug("Set affinity to cores: {}", (std::string) cset_pin);
}
void setPriority(int priority)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment