Skip to content

Commit

Permalink
overlay: rework misleading gpu_busy_percent check
Browse files Browse the repository at this point in the history
Above all, we really don't need the gpu_busy_percent node, if the GPU
exposes a gpu_metrics node,

Although looking closer, the gpu_busy_percent check is meant for
something else - to distinguish between the card node (cardX) and the
card output node (cardX-output-foo).

To top it all up, the check at the very end implies that we can get a
case where gpu_metrics and gpu_busy_perfect is missing ... that's not
possible.

So instead, drop the early gpu_busy_perfect check and properly mandate
it later on.

Signed-off-by: Emil Velikov <[email protected]>
  • Loading branch information
evelikov committed Mar 12, 2022
1 parent 9c6de02 commit 816d9f6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_para
fclose(fp);
}

if (!file_exists(path + "/device/gpu_busy_percent"))
continue;

if (pci_bus_parsed && pci_dev) {
string pci_device = read_symlink((path + "/device").c_str());
SPDLOG_DEBUG("PCI device symlink: '{}'", pci_device);
Expand All @@ -647,8 +644,12 @@ void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_para
if (!metrics_path.empty())
break;

// The card output nodes - cardX-output, will point to the card node
// As such the actual metrics nodes will be missing.
amdgpu.busy = fopen((path + "/gpu_busy_percent").c_str(), "r");
if (!amdgpu.busy)
amdgpu.busy = fopen((path + "/gpu_busy_percent").c_str(), "r");
continue;

path += "/hwmon/";
auto dirs = ls(path.c_str(), "hwmon", LS_DIRS);
for (auto& dir : dirs) {
Expand All @@ -665,7 +666,7 @@ void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_para
}

// don't bother then
if (metrics_path.empty() && !amdgpu.busy && !amdgpu.temp && !amdgpu.vram_total && !amdgpu.vram_used) {
if (metrics_path.empty() && !amdgpu.busy) {
params.enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false;
}
}
Expand Down

0 comments on commit 816d9f6

Please sign in to comment.