Archived
- Qwen3.8-Flash-Next on one card: the heat engine moves 64 experts a step (was 8), its copies and the prefill's expert staging run on the card's DMA engines instead of as copy kernels, and at decode the next layer's likeliest experts are copied onto the card ahead of its GEMMs. Against 1.3.0 at --tp 1: prefill +17-20% from 8K tokens up, throughput under load +16-20% - deploy/compose/flashnext-tp1.yaml: Qwen3.8-Flash-Next on one card and 64 GB of host RAM (4096-token prefill steps, 4 sequences, a 301K-token cache) - #61: --busy-prefill-chunk (default auto): a long prefill leaves the rest of the step to the requests decoding beside it and to new arrivals, instead of taking all of it (baKon) - LiquidAI's LFM2 and LFM2-VL, and d1's /v1/systemone (after zivius's PR #50) - a startup report: every option with its value and where it came from, the hardware, and what on it costs speed with the fix; /diagnostics serves it (behind the API key; without one, only to the same machine) - #69: a GPU memory fault names the buffer and kernel argument behind it and ends the server at once (exit status 70), instead of hanging or writing a core of tens of gigabytes - #64: a card without Resizable BAR is refused at startup, naming what to turn on, instead of crashing at the first launch - the image is built with ROCm 10.1 (the host's amdgpu driver must support it), with ROCm's libLLVM rebuilt so the same source compiles to the same kernels every time; a source build takes ROCm 10.1 or 7.2 - #71: the image ships curl, jq and a CA bundle, so --model <HF repo id> works in the container, and hfget.sh runs under its busybox (baKon) - --profile-ops shows how long each op's lane sat idle before it; cardclock.py skips an integrated GPU instead of stopping
474 lines
20 KiB
C++
474 lines
20 KiB
C++
/* sysinfo.cpp -- the machine, as /proc and /sys describe it.
|
|
*
|
|
* EVERY READ IS A FILE UNDER A ROOT. No tool is run and no library beyond the C++ runtime is
|
|
* asked: the production image is built FROM scratch and has no shell, no lspci and no rocm-smi,
|
|
* and a test hands the collector a directory tree of its own to stand for a machine with two cards
|
|
* behind a switch, a parked link, or an IOMMU that translates. What a file does not say is left
|
|
* unknown, never guessed.
|
|
*/
|
|
#include "diag/diag.h"
|
|
#include "rad_internal.h"
|
|
|
|
#include <cerrno>
|
|
#include <cctype>
|
|
|
|
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <map>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <sys/resource.h>
|
|
#include <sys/syscall.h>
|
|
#include <unistd.h>
|
|
|
|
namespace rad {
|
|
namespace diag {
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
namespace {
|
|
|
|
std::string slurp(const std::string& path) {
|
|
std::ifstream f(path);
|
|
if (!f) return std::string();
|
|
std::stringstream ss;
|
|
ss << f.rdbuf();
|
|
return ss.str();
|
|
}
|
|
|
|
std::string trim(std::string s) {
|
|
while (!s.empty() && (s.back() == '\n' || s.back() == ' ' || s.back() == '\t' || s.back() == '\r'))
|
|
s.pop_back();
|
|
size_t i = 0;
|
|
while (i < s.size() && (s[i] == ' ' || s[i] == '\t')) ++i;
|
|
return s.substr(i);
|
|
}
|
|
|
|
/* The first line of a sysfs attribute, trimmed; "" when it cannot be read. */
|
|
std::string line(const std::string& path) {
|
|
const std::string s = slurp(path);
|
|
const size_t nl = s.find('\n');
|
|
return trim(nl == std::string::npos ? s : s.substr(0, nl));
|
|
}
|
|
|
|
int64_t num(const std::string& path, int64_t dflt = -1) {
|
|
const std::string s = line(path);
|
|
if (s.empty()) return dflt;
|
|
char* end = nullptr;
|
|
const long long v = std::strtoll(s.c_str(), &end, 0);
|
|
return end && end != s.c_str() ? (int64_t)v : dflt;
|
|
}
|
|
|
|
/* The bracketed word of a sysfs choice list: "always [madvise] never" -> "madvise". */
|
|
std::string selected(const std::string& path) {
|
|
const std::string s = line(path);
|
|
const size_t a = s.find('['), b = s.find(']');
|
|
if (a == std::string::npos || b == std::string::npos || b < a) return s;
|
|
return s.substr(a + 1, b - a - 1);
|
|
}
|
|
|
|
bool exists(const std::string& p) {
|
|
std::error_code ec;
|
|
return fs::exists(p, ec);
|
|
}
|
|
|
|
std::vector<std::string> list(const std::string& dir) {
|
|
std::vector<std::string> out;
|
|
std::error_code ec;
|
|
for (fs::directory_iterator it(dir, ec), end; !ec && it != end; it.increment(ec))
|
|
out.push_back(it->path().filename().string());
|
|
std::sort(out.begin(), out.end());
|
|
return out;
|
|
}
|
|
|
|
bool is_bdf(const std::string& s) {
|
|
unsigned d, b, dv, f;
|
|
char tail;
|
|
return s.size() == 12 && std::sscanf(s.c_str(), "%4x:%2x:%2x.%1x%c", &d, &b, &dv, &f, &tail) == 4;
|
|
}
|
|
|
|
/* "0x7551" from a sysfs id file, which the kernel writes with its prefix. */
|
|
std::string hexid(const std::string& path) { return line(path); }
|
|
|
|
/* The lowest and highest level of a pp_dpm_* table, "500-2350 MHz"; the levels are listed in
|
|
* order, one a line, as "N: 2350Mhz *". */
|
|
std::string dpm_range(const std::string& path) {
|
|
std::istringstream in(slurp(path));
|
|
std::string l;
|
|
long lo = -1, hi = -1;
|
|
while (std::getline(in, l)) {
|
|
const size_t c = l.find(':');
|
|
const char* p = l.c_str() + (c == std::string::npos ? 0 : c + 1);
|
|
long v = std::strtol(p, nullptr, 10);
|
|
if (v <= 0) continue;
|
|
if (lo < 0 || v < lo) lo = v;
|
|
if (v > hi) hi = v;
|
|
}
|
|
if (lo < 0) return std::string();
|
|
return fmt("%ld-%ld MHz", lo, hi);
|
|
}
|
|
|
|
/* `pm`: whether the power-management files are read as well (collect's `managed`). */
|
|
void read_card(const std::string& root, const std::string& bdf, bool pm, CardFacts* c) {
|
|
const std::string dev = root + "/sys/bus/pci/devices/" + bdf;
|
|
c->bdf = bdf;
|
|
c->vendor = hexid(dev + "/vendor");
|
|
c->pci_device = hexid(dev + "/device");
|
|
{
|
|
std::error_code ec;
|
|
const fs::path drv = fs::read_symlink(dev + "/driver", ec);
|
|
if (!ec) c->driver = drv.filename().string();
|
|
}
|
|
c->numa_node = (int)num(dev + "/numa_node", -1);
|
|
c->runtime_status = line(dev + "/power/runtime_status");
|
|
c->runtime_control = line(dev + "/power/control");
|
|
c->iommu_type = line(dev + "/iommu_group/type");
|
|
for (const std::string& d : list(dev + "/drm"))
|
|
if (d.rfind("card", 0) == 0 && d.size() > 4 && std::isdigit((unsigned char)d[4])) c->drm = d;
|
|
|
|
/* THE WHOLE PATH TO THE ROOT PORT, not the card's own link alone. A card with a switch on it
|
|
* reports its own endpoint link at full speed whatever the slot does upstream: a root port
|
|
* parked one speed down shows only at the root port (and in the card's DPM table). */
|
|
std::error_code ec;
|
|
const fs::path real = fs::canonical(dev, ec);
|
|
if (!ec) {
|
|
for (const fs::path& part : real) {
|
|
const std::string p = part.string();
|
|
if (!is_bdf(p)) continue;
|
|
const std::string hd = root + "/sys/bus/pci/devices/" + p;
|
|
PciHop h;
|
|
h.bdf = p;
|
|
h.cur_speed = line(hd + "/current_link_speed");
|
|
h.max_speed = line(hd + "/max_link_speed");
|
|
h.cur_width = (int)num(hd + "/current_link_width", -1);
|
|
h.max_width = (int)num(hd + "/max_link_width", -1);
|
|
c->chain.push_back(h);
|
|
}
|
|
}
|
|
if (c->chain.empty()) {
|
|
PciHop h;
|
|
h.bdf = bdf;
|
|
h.cur_speed = line(dev + "/current_link_speed");
|
|
h.max_speed = line(dev + "/max_link_speed");
|
|
h.cur_width = (int)num(dev + "/current_link_width", -1);
|
|
h.max_width = (int)num(dev + "/max_link_width", -1);
|
|
c->chain.push_back(h);
|
|
}
|
|
|
|
c->vram_total = num(dev + "/mem_info_vram_total", -1);
|
|
c->vram_visible = num(dev + "/mem_info_vis_vram_total", -1);
|
|
if (!pm) return;
|
|
c->busy_percent = (int)num(dev + "/gpu_busy_percent", -1);
|
|
{
|
|
std::istringstream in(slurp(dev + "/pp_dpm_pcie"));
|
|
std::string l;
|
|
while (std::getline(in, l)) {
|
|
l = trim(l);
|
|
if (l.empty()) continue;
|
|
if (l.find('*') != std::string::npos) c->dpm_pcie_cur = (int)c->dpm_pcie.size();
|
|
l.erase(std::remove(l.begin(), l.end(), '*'), l.end());
|
|
c->dpm_pcie.push_back(trim(l));
|
|
}
|
|
}
|
|
c->sclk = dpm_range(dev + "/pp_dpm_sclk");
|
|
c->mclk = dpm_range(dev + "/pp_dpm_mclk");
|
|
for (const std::string& h : list(dev + "/hwmon")) {
|
|
const std::string hp = dev + "/hwmon/" + h;
|
|
if (!exists(hp + "/power1_cap")) continue;
|
|
c->power_cap_uw = num(hp + "/power1_cap", -1);
|
|
c->power_cap_default_uw = num(hp + "/power1_cap_default", -1);
|
|
c->power_cap_max_uw = num(hp + "/power1_cap_max", -1);
|
|
break;
|
|
}
|
|
{
|
|
/* "OD_VDDGFX_OFFSET:\n-75mV": the offset the driver holds for the card, which is the one
|
|
* it uploads; whether the firmware took it is not in this file. */
|
|
const std::string od = slurp(dev + "/pp_od_clk_voltage");
|
|
const size_t at = od.find("OD_VDDGFX_OFFSET:");
|
|
if (at != std::string::npos) {
|
|
const char* p = od.c_str() + at + std::strlen("OD_VDDGFX_OFFSET:");
|
|
char* end = nullptr;
|
|
const long v = std::strtol(p, &end, 10);
|
|
if (end && end != p) c->vddgfx_offset = fmt("%ld mV", v);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* The KFD topology knows what the PCI files do not: each GPU node's target and SIMD count, keyed
|
|
* by its PCI location -- `location_id` is (bus << 8) | (device << 3) | function. */
|
|
void read_kfd(const std::string& root, std::vector<CardFacts>* cards) {
|
|
const std::string nodes = root + "/sys/class/kfd/kfd/topology/nodes";
|
|
for (const std::string& n : list(nodes)) {
|
|
/* A LINE AT A TIME, and only the four keys this needs parsed: the file holds values no
|
|
* signed 64-bit integer takes (unique_id is a full 64-bit hash), and a stream extraction
|
|
* that meets one fails and stops reading every key after it. */
|
|
std::istringstream in(slurp(nodes + "/" + n + "/properties"));
|
|
std::string l;
|
|
long long loc = -1, dom = 0, gfx = 0, simd = -1;
|
|
while (std::getline(in, l)) {
|
|
const size_t sp = l.find_first_of(" \t");
|
|
if (sp == std::string::npos) continue;
|
|
const std::string k = l.substr(0, sp);
|
|
long long* into = k == "location_id" ? &loc
|
|
: k == "domain" ? &dom
|
|
: k == "gfx_target_version" ? &gfx
|
|
: k == "simd_count" ? &simd
|
|
: nullptr;
|
|
if (!into) continue;
|
|
const char* p = l.c_str() + sp + 1;
|
|
char* end = nullptr;
|
|
errno = 0;
|
|
const long long v = std::strtoll(p, &end, 10);
|
|
if (end != p && errno == 0) *into = v;
|
|
}
|
|
if (gfx <= 0 || loc < 0) continue;
|
|
const std::string bdf = fmt("%04llx:%02llx:%02llx.%llx", dom, (loc >> 8) & 0xff,
|
|
(loc >> 3) & 0x1f, loc & 7);
|
|
for (CardFacts& c : *cards) {
|
|
if (c.bdf != bdf) continue;
|
|
c.gfx = fmt("gfx%lld%llx%llx", gfx / 10000, (gfx / 100) % 100, gfx % 100);
|
|
c.simd = (int)simd;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Of two memory limits in HostFacts' encoding (bytes, -2 unlimited, -1 unknown), the one that
|
|
* binds: the smaller number, else unlimited over unknown. */
|
|
int64_t tighter(int64_t a, int64_t b) {
|
|
if (a >= 0 && b >= 0) return std::min(a, b);
|
|
if (a >= 0 || b >= 0) return std::max(a, b);
|
|
return a == -2 || b == -2 ? -2 : -1;
|
|
}
|
|
|
|
/* THE TIGHTEST MEMORY LIMIT FROM A CGROUP UP TO THE MOUNT'S ROOT. A limit binds every cgroup
|
|
* below it, so the process's own group can say "max" while the systemd slice or the container's
|
|
* group above it holds the limit that counts. `rel` is the path /proc/self/cgroup names, under
|
|
* `mount`; every level on the way up is read, the mount's root included -- inside a container's
|
|
* cgroup namespace that root is the container's own group. */
|
|
int64_t cgroup_limit(const std::string& mount, std::string rel, const char* file) {
|
|
int64_t lim = -1;
|
|
while (!rel.empty() && rel.back() == '/') rel.pop_back();
|
|
for (;;) {
|
|
const std::string v = line(mount + rel + "/" + file);
|
|
if (v == "max") {
|
|
lim = tighter(lim, -2);
|
|
} else if (!v.empty()) {
|
|
char* end = nullptr;
|
|
errno = 0;
|
|
const long long n = std::strtoll(v.c_str(), &end, 10);
|
|
/* Version 1 writes "no limit" as the largest page-aligned number below 2^63. */
|
|
if (end != v.c_str() && errno == 0 && n >= 0)
|
|
lim = tighter(lim, n >= ((long long)1 << 62) ? -2 : (int64_t)n);
|
|
}
|
|
if (rel.empty()) break;
|
|
const size_t up = rel.rfind('/');
|
|
rel.erase(up == std::string::npos ? 0 : up);
|
|
}
|
|
return lim;
|
|
}
|
|
|
|
void read_host(const std::string& root, HostFacts* h) {
|
|
{
|
|
std::istringstream in(slurp(root + "/proc/cpuinfo"));
|
|
std::string l;
|
|
std::set<std::pair<std::string, std::string>> cores;
|
|
std::string phys;
|
|
int threads = 0;
|
|
while (std::getline(in, l)) {
|
|
const size_t c = l.find(':');
|
|
if (c == std::string::npos) continue;
|
|
const std::string k = trim(l.substr(0, c)), v = trim(l.substr(c + 1));
|
|
if (k == "processor") ++threads;
|
|
else if (k == "model name" && h->cpu_model.empty()) h->cpu_model = v;
|
|
else if (k == "physical id") phys = v;
|
|
else if (k == "core id") cores.insert({ phys, v });
|
|
}
|
|
if (threads > 0) h->threads = threads;
|
|
if (!cores.empty()) h->cores = (int)cores.size();
|
|
}
|
|
{
|
|
std::istringstream in(slurp(root + "/proc/meminfo"));
|
|
std::string k;
|
|
long long v;
|
|
std::string unit;
|
|
while (in >> k >> v) {
|
|
std::getline(in, unit);
|
|
const int64_t b = (int64_t)v * 1024;
|
|
if (k == "MemTotal:") h->mem_total = b;
|
|
else if (k == "MemAvailable:") h->mem_available = b;
|
|
else if (k == "SwapTotal:") h->swap_total = b;
|
|
else if (k == "SwapFree:") h->swap_free = b;
|
|
}
|
|
}
|
|
h->kernel = line(root + "/proc/sys/kernel/osrelease");
|
|
{
|
|
std::istringstream in(slurp(root + "/etc/os-release"));
|
|
std::string l;
|
|
while (std::getline(in, l))
|
|
if (l.rfind("PRETTY_NAME=", 0) == 0) {
|
|
h->distro = l.substr(12);
|
|
if (h->distro.size() >= 2 && h->distro.front() == '"') h->distro = h->distro.substr(1, h->distro.size() - 2);
|
|
}
|
|
}
|
|
if (exists(root + "/.dockerenv")) h->container = "docker";
|
|
else if (exists(root + "/run/.containerenv")) h->container = "podman";
|
|
else {
|
|
const std::string cg = slurp(root + "/proc/1/cgroup");
|
|
if (cg.find("docker") != std::string::npos) h->container = "docker";
|
|
else if (cg.find("kubepods") != std::string::npos) h->container = "kubernetes";
|
|
else if (cg.find("containerd") != std::string::npos) h->container = "containerd";
|
|
}
|
|
{
|
|
/* THE PROCESS'S OWN CGROUP, which inside a container is "/" under its namespace, and
|
|
* every one above it: cgroup_limit says why. Version 2 is the "0::" line; version 1's
|
|
* memory controller is the ":memory:" one, where "unlimited" is a number near 2^63. */
|
|
std::istringstream in(slurp(root + "/proc/self/cgroup"));
|
|
std::string l;
|
|
int64_t lim = -1;
|
|
while (std::getline(in, l)) {
|
|
int64_t v = -1;
|
|
if (l.rfind("0::", 0) == 0)
|
|
v = cgroup_limit(root + "/sys/fs/cgroup", l.substr(3), "memory.max");
|
|
else if (l.find(":memory:") != std::string::npos)
|
|
v = cgroup_limit(root + "/sys/fs/cgroup/memory", l.substr(l.find(":memory:") + 8),
|
|
"memory.limit_in_bytes");
|
|
lim = tighter(lim, v);
|
|
}
|
|
h->cgroup_mem_limit = lim;
|
|
}
|
|
const std::string thp = root + "/sys/kernel/mm/transparent_hugepage";
|
|
h->thp_enabled = selected(thp + "/enabled");
|
|
h->thp_defrag = selected(thp + "/defrag");
|
|
h->thp_shmem = selected(thp + "/shmem_enabled");
|
|
{
|
|
std::istringstream in(line(root + "/proc/cmdline"));
|
|
std::string t;
|
|
static const char* const kKeep[] = { "iommu", "amd_iommu", "intel_iommu", "amdgpu.", "ttm.",
|
|
"transparent_hugepage", "hugepages", "pcie_aspm",
|
|
"pci=", "default_hugepagesz" };
|
|
while (in >> t)
|
|
for (const char* k : kKeep)
|
|
if (t.rfind(k, 0) == 0) { h->cmdline += (h->cmdline.empty() ? "" : " ") + t; break; }
|
|
}
|
|
{
|
|
/* PASSTHROUGH OR TRANSLATED, from what decides it for the cards: their IOMMU groups' type
|
|
* (identity is passthrough) is the kernel's own answer; the boot parameters and the
|
|
* presence of an IOMMU are what is left when a card has no group. */
|
|
const bool any_iommu = !list(root + "/sys/class/iommu").empty();
|
|
const bool groups = !list(root + "/sys/kernel/iommu_groups").empty();
|
|
const std::string cl = " " + h->cmdline + " ";
|
|
if (!any_iommu && !groups) {
|
|
h->iommu = "off";
|
|
h->iommu_why = "no IOMMU is registered (/sys/class/iommu is empty)";
|
|
} else if (cl.find(" iommu=pt ") != std::string::npos ||
|
|
cl.find(" amd_iommu=pt ") != std::string::npos ||
|
|
cl.find(" intel_iommu=pt ") != std::string::npos) {
|
|
h->iommu = "passthrough";
|
|
h->iommu_why = "iommu=pt on the kernel command line";
|
|
} else if (cl.find("iommu=off") != std::string::npos) {
|
|
h->iommu = "off";
|
|
h->iommu_why = "the kernel command line turns it off";
|
|
} else {
|
|
h->iommu = "unknown";
|
|
h->iommu_why = "an IOMMU is present; its mode is read from the cards' groups below";
|
|
}
|
|
}
|
|
{
|
|
int64_t lim = num(root + "/sys/module/ttm/parameters/pages_limit", -1);
|
|
/* 0 IS THE DRIVER'S DEFAULT, which is half of RAM. */
|
|
if (lim == 0 && h->mem_total > 0) lim = h->mem_total / 2 / h->page_size;
|
|
h->ttm_pages_limit = lim;
|
|
}
|
|
h->cwsr_enable = (int)num(root + "/sys/module/amdgpu/parameters/cwsr_enable", -1);
|
|
{
|
|
const int64_t d = num(root + "/proc/sys/kernel/io_uring_disabled", -1);
|
|
h->io_uring = d == 0 ? "available" : d == 1 ? "restricted to a group (io_uring_disabled 1)"
|
|
: d == 2 ? "refused (io_uring_disabled 2)" : "unknown";
|
|
}
|
|
const std::string cpu = root + "/sys/devices/system/cpu/cpu0/cpufreq";
|
|
h->cpu_governor = line(cpu + "/scaling_governor");
|
|
h->cpu_epp = line(cpu + "/energy_performance_preference");
|
|
h->cpu_driver = line(cpu + "/scaling_driver");
|
|
}
|
|
|
|
} /* namespace */
|
|
|
|
Facts collect(const std::string& root, const std::vector<std::string>* managed) {
|
|
Facts f;
|
|
if (root.empty()) {
|
|
const long ps = sysconf(_SC_PAGE_SIZE);
|
|
if (ps > 0) f.host.page_size = ps;
|
|
}
|
|
read_host(root, &f.host);
|
|
/* EVERY DISPLAY-CLASS DEVICE, the engine's or not: an integrated GPU beside the cards, or a
|
|
* card the engine was told not to use, is part of the answer to "what is in this machine". */
|
|
for (const std::string& d : list(root + "/sys/bus/pci/devices")) {
|
|
const std::string cls = line(root + "/sys/bus/pci/devices/" + d + "/class");
|
|
if (cls.rfind("0x03", 0) != 0) continue;
|
|
const bool pm =
|
|
!managed || std::find(managed->begin(), managed->end(), d) != managed->end();
|
|
CardFacts c;
|
|
read_card(root, d, pm, &c);
|
|
f.cards.push_back(std::move(c));
|
|
}
|
|
read_kfd(root, &f.cards);
|
|
/* THE IOMMU'S MODE AS THE CARDS SEE IT, which beats the command line where both exist: each
|
|
* card's group says identity (passthrough) or DMA / DMA-FQ (translated), and a machine can
|
|
* hold both -- an integrated GPU left identity-mapped beside a translated discrete card. */
|
|
if (f.host.iommu == "unknown") {
|
|
std::map<std::string, std::string> by;
|
|
for (const CardFacts& c : f.cards)
|
|
if (!c.iommu_type.empty()) by[c.iommu_type] += (by[c.iommu_type].empty() ? "" : ", ") + c.bdf;
|
|
if (by.size() == 1) {
|
|
const bool id = by.begin()->first == "identity";
|
|
f.host.iommu = id ? "passthrough" : "translated";
|
|
f.host.iommu_why = "the display devices' IOMMU groups are of type " + by.begin()->first;
|
|
} else if (by.size() > 1) {
|
|
f.host.iommu = "mixed";
|
|
f.host.iommu_why.clear();
|
|
for (const auto& [t, bdfs] : by)
|
|
f.host.iommu_why += (f.host.iommu_why.empty() ? "" : "; ") + t + " for " + bdfs;
|
|
}
|
|
}
|
|
return f;
|
|
}
|
|
|
|
void probe_process(HostFacts* h) {
|
|
struct rlimit rl{};
|
|
if (getrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
|
h->memlock_soft = rl.rlim_cur == RLIM_INFINITY ? -2 : (int64_t)rl.rlim_cur;
|
|
#ifdef SYS_io_uring_setup
|
|
/* ASKED, NOT INFERRED: a seccomp profile (Docker's default) refuses the call whatever the
|
|
* sysctl says, and the answer is the error the call returns. One entry, closed at once. */
|
|
struct { uint32_t sq_entries, cq_entries, flags, sq_thread_cpu, sq_thread_idle, features,
|
|
wq_fd, resv[3]; uint64_t sq_off[5]; uint64_t cq_off[5]; } p{};
|
|
static_assert(sizeof(p) == 120, "io_uring_params is 120 bytes");
|
|
const long fd = syscall(SYS_io_uring_setup, 1, &p);
|
|
if (fd >= 0) {
|
|
close((int)fd);
|
|
h->io_uring = "available";
|
|
} else {
|
|
h->io_uring = fmt("refused (%s)", std::strerror(errno));
|
|
}
|
|
#endif
|
|
}
|
|
|
|
std::vector<std::string> env_names(char* const* env, const char* prefix) {
|
|
std::vector<std::string> out;
|
|
const size_t n = std::strlen(prefix);
|
|
for (char* const* e = env; e && *e; ++e) {
|
|
if (std::strncmp(*e, prefix, n) != 0) continue;
|
|
const char* eq = std::strchr(*e, '=');
|
|
out.emplace_back(*e, eq ? (size_t)(eq - *e) : std::strlen(*e));
|
|
}
|
|
std::sort(out.begin(), out.end());
|
|
return out;
|
|
}
|
|
|
|
} /* namespace diag */
|
|
} /* namespace rad */
|