Prevent reading sensors far too quickly.
PATCH 1/1 Prevent reading sensors far too quickly.
On platforms without GPU_POWER sensors the thread reading sensors would proceed far too quickly. So it is now rate limited to 50Hz to be consistent.
Signed-off-by Tom St Denis <[email protected]>
--- src/app/top.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
src/app/top.c +11 -1
@@ -293,18 +293,24 @@ static volatile struct umr_bitfield *sensor_bits = NULL;static void *gpu_sensor_thread (void *data) {struct umr_asic asic = *((struct umr_asic *)data); -int size, rem, off, x; +int size, rem, off, x, power;char fname[128 ]; +struct timespec ts; + + ts.tv_sec =0 ; + ts.tv_nsec =1000000000UL /50 ;// limit to 50Hz snprintf (fname,sizeof (fname)-1 ,"/sys/kernel/debug/dri/%d/amdgpu_sensors" , asic.instance); asic.fd.sensors =open (fname,O_RDWR );while (!sensor_thread_quit) { rem =sizeof gpu_power_data; off =0 ; + power =0 ;for (x =0 ; sensor_bits[x].regname; ) {switch (sensor_bits[x].start) {case AMDGPU_PP_SENSOR_GPU_POWER : size =16 ; + power =1 ;break ;default : size =4 ;
@@ -316,6 +322,10 @@ static void *gpu_sensor_thread(void *data) rem -= size; x += size /4 ; } + +// sleep for 20ms if no GPU power sensor to rate limit things a bit +if (!power) +nanosleep (&ts,NULL ); }close (asic.fd.sensors);return NULL ;
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Edward O'Callaghan
Reviewed-byReviewed-by Edward O'Callaghan <[email protected]>
Quoted 40 lines · Tom St Denis
On platforms without
GPU_POWERsensors the thread reading sensors would proceed far too quickly. So it is now rate limited to 50Hz to be consistent.Signed-off-by Tom St Denis <[email protected]>--- src/app/top.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)src/app/top.c +7
-1@@ -293,18 +293,24 @@ static volatile struct umr_bitfield *sensor_bits = NULL;static void *gpu_sensor_thread (void *data) {struct umr_asic asic = *((struct umr_asic *)data); -int size, rem, off, x; +int size, rem, off, x, power;char fname[128 ]; +struct timespec ts; + + ts.tv_sec =0 ; + ts.tv_nsec =1000000000UL /50 ;// limit to 50Hz snprintf (fname,sizeof (fname)-1 ,"/sys/kernel/debug/dri/%d/amdgpu_sensors" , asic.instance); asic.fd.sensors =open (fname,O_RDWR );while (!sensor_thread_quit) { rem =sizeof gpu_power_data; off =0 ; + power =0 ;for (x =0 ; sensor_bits[x].regname; ) {switch (sensor_bits[x].start) {case AMDGPU_PP_SENSOR_GPU_POWER : size =16 ; + power =1 ;break ;default : size =4 ;
src/app/top.c static void *gpu_sensor_thread(void *data) · line 331
Quoted 10 lines
src/app/top.c +4
-0@@ -316,6 +322,10 @@ static void *gpu_sensor_thread(void *data) rem -= size; x += size /4 ; } + +// sleep for 20ms if no GPU power sensor to rate limit things a bit +if (!power) +nanosleep (&ts,NULL ); }close (asic.fd.sensors);return NULL ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx