@@ -517,6 +517,7 @@ static void timerlat_top_usage(char *usage)
517
517
" --trace-buffer-size kB: set the per-cpu trace buffer size in kB" ,
518
518
" --deepest-idle-state n: only go down to idle state n on cpus used by timerlat to reduce exit from idle latency" ,
519
519
" --on-threshold <action>: define action to be executed at latency threshold, multiple are allowed" ,
520
+ " --on-end: define action to be executed at measurement end, multiple are allowed" ,
520
521
NULL ,
521
522
};
522
523
@@ -552,7 +553,8 @@ static struct timerlat_params
552
553
if (!params )
553
554
exit (1 );
554
555
555
- actions_init (& params -> actions );
556
+ actions_init (& params -> threshold_actions );
557
+ actions_init (& params -> end_actions );
556
558
557
559
/* disabled by default */
558
560
params -> dma_latency = -1 ;
@@ -597,6 +599,7 @@ static struct timerlat_params
597
599
{"trace-buffer-size" , required_argument , 0 , '7' },
598
600
{"deepest-idle-state" , required_argument , 0 , '8' },
599
601
{"on-threshold" , required_argument , 0 , '9' },
602
+ {"on-end" , required_argument , 0 , '\1' },
600
603
{0 , 0 , 0 , 0 }
601
604
};
602
605
@@ -623,6 +626,7 @@ static struct timerlat_params
623
626
624
627
/* set trace */
625
628
trace_output = "timerlat_trace.txt" ;
629
+
626
630
break ;
627
631
case '5' :
628
632
/* it is here because it is similar to -a */
@@ -776,7 +780,14 @@ static struct timerlat_params
776
780
params -> deepest_idle_state = get_llong_from_str (optarg );
777
781
break ;
778
782
case '9' :
779
- retval = actions_parse (& params -> actions , optarg );
783
+ retval = actions_parse (& params -> threshold_actions , optarg );
784
+ if (retval ) {
785
+ err_msg ("Invalid action %s\n" , optarg );
786
+ exit (EXIT_FAILURE );
787
+ }
788
+ break ;
789
+ case '\1' :
790
+ retval = actions_parse (& params -> end_actions , optarg );
780
791
if (retval ) {
781
792
err_msg ("Invalid action %s\n" , optarg );
782
793
exit (EXIT_FAILURE );
@@ -788,7 +799,7 @@ static struct timerlat_params
788
799
}
789
800
790
801
if (trace_output )
791
- actions_add_trace_output (& params -> actions , trace_output );
802
+ actions_add_trace_output (& params -> threshold_actions , trace_output );
792
803
793
804
if (geteuid ()) {
794
805
err_msg ("rtla needs root permission\n" );
@@ -812,7 +823,8 @@ static struct timerlat_params
812
823
* mixed mode
813
824
*/
814
825
if (params -> mode == TRACING_MODE_BPF &&
815
- (params -> actions .present [ACTION_TRACE_OUTPUT ] || !params -> no_aa ))
826
+ (params -> threshold_actions .present [ACTION_TRACE_OUTPUT ] ||
827
+ params -> end_actions .present [ACTION_TRACE_OUTPUT ] || !params -> no_aa ))
816
828
params -> mode = TRACING_MODE_MIXED ;
817
829
818
830
return params ;
@@ -934,14 +946,14 @@ timerlat_top_main_loop(struct osnoise_tool *top,
934
946
timerlat_print_stats (params , top );
935
947
936
948
if (osnoise_trace_is_off (top , record )) {
937
- actions_perform (& params -> actions );
949
+ actions_perform (& params -> threshold_actions );
938
950
939
- if (!params -> actions .continue_flag )
951
+ if (!params -> threshold_actions .continue_flag )
940
952
/* continue flag not set, break */
941
953
break ;
942
954
943
955
/* continue action reached, re-enable tracing */
944
- if (params -> actions . present [ ACTION_TRACE_OUTPUT ] )
956
+ if (record )
945
957
trace_instance_start (& record -> trace );
946
958
if (!params -> no_aa )
947
959
trace_instance_start (& aa -> trace );
@@ -993,14 +1005,14 @@ timerlat_top_bpf_main_loop(struct osnoise_tool *top,
993
1005
994
1006
if (wait_retval == 1 ) {
995
1007
/* Stopping requested by tracer */
996
- actions_perform (& params -> actions );
1008
+ actions_perform (& params -> threshold_actions );
997
1009
998
- if (!params -> actions .continue_flag )
1010
+ if (!params -> threshold_actions .continue_flag )
999
1011
/* continue flag not set, break */
1000
1012
break ;
1001
1013
1002
1014
/* continue action reached, re-enable tracing */
1003
- if (params -> actions . present [ ACTION_TRACE_OUTPUT ] )
1015
+ if (record )
1004
1016
trace_instance_start (& record -> trace );
1005
1017
if (!params -> no_aa )
1006
1018
trace_instance_start (& aa -> trace );
@@ -1128,13 +1140,15 @@ int timerlat_top_main(int argc, char *argv[])
1128
1140
}
1129
1141
}
1130
1142
1131
- if (params -> actions .present [ACTION_TRACE_OUTPUT ]) {
1143
+ if (params -> threshold_actions .present [ACTION_TRACE_OUTPUT ] ||
1144
+ params -> end_actions .present [ACTION_TRACE_OUTPUT ]) {
1132
1145
record = osnoise_init_trace_tool ("timerlat" );
1133
1146
if (!record ) {
1134
1147
err_msg ("Failed to enable the trace instance\n" );
1135
1148
goto out_free ;
1136
1149
}
1137
- params -> actions .trace_output_inst = record -> trace .inst ;
1150
+ params -> threshold_actions .trace_output_inst = record -> trace .inst ;
1151
+ params -> end_actions .trace_output_inst = record -> trace .inst ;
1138
1152
1139
1153
if (params -> events ) {
1140
1154
retval = trace_events_enable (& record -> trace , params -> events );
@@ -1201,7 +1215,7 @@ int timerlat_top_main(int argc, char *argv[])
1201
1215
* tracing while enabling other instances. The trace instance is the
1202
1216
* one with most valuable information.
1203
1217
*/
1204
- if (params -> actions . present [ ACTION_TRACE_OUTPUT ] )
1218
+ if (record )
1205
1219
trace_instance_start (& record -> trace );
1206
1220
if (!params -> no_aa )
1207
1221
trace_instance_start (& aa -> trace );
@@ -1236,6 +1250,8 @@ int timerlat_top_main(int argc, char *argv[])
1236
1250
1237
1251
timerlat_print_stats (params , top );
1238
1252
1253
+ actions_perform (& params -> end_actions );
1254
+
1239
1255
return_value = PASSED ;
1240
1256
1241
1257
if (osnoise_trace_is_off (top , record ) && !stop_tracing ) {
@@ -1276,7 +1292,8 @@ int timerlat_top_main(int argc, char *argv[])
1276
1292
osnoise_destroy_tool (aa );
1277
1293
osnoise_destroy_tool (record );
1278
1294
osnoise_destroy_tool (top );
1279
- actions_destroy (& params -> actions );
1295
+ actions_destroy (& params -> threshold_actions );
1296
+ actions_destroy (& params -> end_actions );
1280
1297
if (params -> mode != TRACING_MODE_TRACEFS )
1281
1298
timerlat_bpf_destroy ();
1282
1299
free (params );
0 commit comments