From 816d9f6b98434a8a38d77687a39a0803b7a342b2 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Sat, 12 Mar 2022 18:17:29 +0000 Subject: [PATCH] overlay: rework misleading gpu_busy_percent check 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 --- src/overlay.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/overlay.cpp b/src/overlay.cpp index 80d28297..cdeae521 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -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); @@ -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) { @@ -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; } }