Log gpu usage (#21404)

* Log gpu usage

* 100 total

* bump cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/21440/head
Willem Melching 2021-06-29 22:55:18 +02:00 committed by GitHub
parent 325cabd4da
commit ad7f0207ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 1 deletions

2
cereal

@ -1 +1 @@
Subproject commit 232e28c2bb049fa8b7c2da0a2add27645b5a6bc2
Subproject commit e1793a1854eb5f76a304b30ee96dee5a0f0b2cc4

View File

@ -113,3 +113,7 @@ class HardwareBase:
@abstractmethod
def set_power_save(self, enabled):
pass
@abstractmethod
def get_gpu_usage_percent(self):
pass

View File

@ -377,3 +377,6 @@ class Android(HardwareBase):
def set_power_save(self, enabled):
pass
def get_gpu_usage_percent(self):
return 0

View File

@ -85,3 +85,6 @@ class Pc(HardwareBase):
def set_power_save(self, enabled):
pass
def get_gpu_usage_percent(self):
return 0

View File

@ -262,3 +262,10 @@ class Tici(HardwareBase):
# TODO: fix permissions with udev
val = "0" if enabled else "1"
os.system(f"sudo su -c 'echo {val} > /sys/devices/system/cpu/cpu{i}/online'")
def get_gpu_usage_percent(self):
try:
used, total = open('/sys/class/kgsl/kgsl-3d0/gpubusy').read().strip().split()
return 100.0 * int(used) / int(total)
except Exception:
return 0

View File

@ -265,6 +265,7 @@ def thermald_thread():
msg.deviceState.freeSpacePercent = get_available_percent(default=100.0)
msg.deviceState.memoryUsagePercent = int(round(psutil.virtual_memory().percent))
msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent()))
msg.deviceState.gpuUsagePercent = int(round(HARDWARE.get_gpu_usage_percent()))
msg.deviceState.networkType = network_type
msg.deviceState.networkStrength = network_strength
if network_info is not None: