feat: add special case for invalid throttle mask

This commit is contained in:
Ilya Zlobintsev 2024-11-08 10:13:23 +02:00
parent 4a567c3345
commit 5f95a4dc12

View File

@ -20,7 +20,7 @@ use lact_schema::{
ClocksInfo, ClockspeedStats, DeviceInfo, DeviceStats, DrmInfo, FanStats, GpuPciInfo, LinkInfo,
PciInfo, PmfwInfo, PowerState, PowerStates, PowerStats, VoltageStats, VramStats,
};
use libdrm_amdgpu_sys::AMDGPU::ThrottlerBit;
use libdrm_amdgpu_sys::AMDGPU::{ThrottleStatus, ThrottlerBit};
use pciid_parser::Database;
use std::{
cell::RefCell,
@ -466,10 +466,18 @@ impl AmdGpuController {
self.drm_handle
.as_ref()
.and_then(|drm_handle| drm_handle.get_gpu_metrics().ok())
.and_then(|metrics| metrics.get_throttle_status_info())
.map(|throttle| {
.and_then(|metrics| metrics.get_indep_throttle_status())
.map(|throttle_value| {
let mut grouped_bits: HashMap<ThrottlerType, HashSet<u8>> = HashMap::new();
if throttle_value == u64::MAX {
return [("Everything".to_owned(), vec!["Yes".to_owned()])]
.into_iter()
.collect();
}
let throttle = ThrottleStatus::new(throttle_value);
for bit in throttle.get_all_throttler() {
let throttle_type = ThrottlerType::from(bit);
grouped_bits