rtla: Set /dev/cpu_dma_latency to avoid exit from idle latencies
PATCH 1/1 rtla: Set /dev/cpu_dma_latency to avoid exit from idle latencies
Set /dev/cpu_dma_latency to 0 to avoid having exit from idle states latencies influencing in the analysis.
Cc Daniel Bristot de Oliveira <[email protected]>
Cc Steven Rostedt <[email protected]>
Signed-off-by Daniel Bristot de Oliveira <[email protected]>
--- tools/tracing/rtla/src/timerlat_hist.c | 10 ++++++++ tools/tracing/rtla/src/timerlat_top.c | 10 ++++++++ tools/tracing/rtla/src/utils.c | 33 ++++++++++++++++++++++++++ tools/tracing/rtla/src/utils.h | 1 + 4 files changed, 54 insertions(+)
tools/tracing/rtla/src/timerlat_hist.c +10 -0
@@ -732,6 +732,7 @@ int timerlat_hist_main(int argc, char *argv[])struct osnoise_tool *record =NULL ;struct osnoise_tool *tool =NULL ;struct trace_instance *trace; +int dma_latency_fd =-1 ;int return_value =1 ;int retval;
@@ -767,6 +768,13 @@ int timerlat_hist_main(int argc, char *argv[]) } } +/* +* Avoid going into deep idle states. +*/ + dma_latency_fd =set_cpu_dma_latency (0 ); +if (dma_latency_fd <0 ) +err_msg ("Could not set /dev/cpu_dma_latency to 0. Long IRQ latencies expected\n" ); +trace_instance_start (trace);if (params->trace_output) {
@@ -812,6 +820,8 @@ int timerlat_hist_main(int argc, char *argv[]) } out_hist: +if (dma_latency_fd >=0 ) +close (dma_latency_fd);timerlat_free_histogram (tool->data);osnoise_destroy_tool (record);osnoise_destroy_tool (tool);
tools/tracing/rtla/src/timerlat_top.c +10 -0
@@ -524,6 +524,7 @@ int timerlat_top_main(int argc, char *argv[])struct osnoise_tool *record =NULL ;struct osnoise_tool *top =NULL ;struct trace_instance *trace; +int dma_latency_fd =-1 ;int return_value =1 ;int retval;
@@ -559,6 +560,13 @@ int timerlat_top_main(int argc, char *argv[]) } } +/* +* Avoid going into deep idle states. +*/ + dma_latency_fd =set_cpu_dma_latency (0 ); +if (dma_latency_fd <0 ) +err_msg ("Could not set /dev/cpu_dma_latency. Long IRQ latencies expected.\n" ); +trace_instance_start (trace);if (params->trace_output) {
@@ -608,6 +616,8 @@ int timerlat_top_main(int argc, char *argv[]) } out_top: +if (dma_latency_fd >=0 ) +close (dma_latency_fd);timerlat_free_top (top->data);osnoise_destroy_tool (record);osnoise_destroy_tool (top);
tools/tracing/rtla/src/utils.c +33 -0
@@ -10,6 +10,7 @@#include <unistd.h> #include <ctype.h> #include <errno.h> +#include <fcntl.h> #include <sched.h> #include <stdio.h>
@@ -431,3 +432,35 @@ int parse_prio(char *arg, struct sched_attr *sched_param) }return 0 ; } + +/* +* set_cpu_dma_latency - set the /dev/cpu_dma_latecy +* +* This is used to reduce the exit from idle latency. The value +* will be reset once the file descriptor of /dev/cpu_dma_latecy +* is closed. +* +* Return: the /dev/cpu_dma_latecy file descriptor +*/ +int set_cpu_dma_latency (int32_t latency) +{ +int retval; +int fd; + + fd =open ("/dev/cpu_dma_latency" ,O_RDWR ); +if (fd <0 ) { +err_msg ("Error opening /dev/cpu_dma_latency\n" ); +return -1 ; + } + + retval =write (fd, &latency,4 ); +if (retval <1 ) { +err_msg ("Error setting /dev/cpu_dma_latency\n" ); +close (fd); +return -1 ; + } + +debug_msg ("Set /dev/cpu_dma_latency to %d\n" , latency); + +return fd; +}
tools/tracing/rtla/src/utils.h +1 -0
@@ -54,3 +54,4 @@ struct sched_attr {int parse_prio (char *arg,struct sched_attr *sched_param);int set_comm_sched_attr (const char *comm,struct sched_attr *attr); +int set_cpu_dma_latency (int32_t latency);
Signature · 1 line
2.34.1
Quoted 3 lines · Daniel Bristot de Oliveira
Set
/dev/cpu_dma_latencyto 0 to avoid having exit from idle states latencies influencing in the analysis.
Sending a v2 of this patch together with a new version of rtla features patch series.
-- Daniel