Skip to contentSkip to conversation

rtla/timerlat_top: Trigger actions with --aa-only in BPF mode

PATCH New Tomas Glozar 1 participant 2 messages Nov 27

Subsystems (2)
lore
Share & tools
lore

Tomas Glozar

author maintainer
#0 lore raw

PATCH 1/2 rtla/timerlat_top: Trigger actions with --aa-only in BPF mode

The implementation of timerlat_top_bpf_main_loop() for aa-only mode is reduced to one call of timerlat_bpf_wait(), after which the function returns. This does not allow for any actions to be performed, including trace output and continuation of tracing.

Modify the implementation so that --aa-only uses the same code path as --quiet, with the exception of not calling timerlat_top_bpf_pull_data(), as rtla does not collect any aggregated data in that mode.

This fixes a discrepancy with regards the tool's behavior in tracefs mode, where actions are handled by the shared top_main_loop() function.

The discrepancy appeared back when actions were moved to the main loop to allow the implementation of --on-threshold continue; --aa-only was not taken into consideration.

Fixes 8d933d5c89e8 ("rtla/timerlat: Add continue action")
---
 tools/tracing/rtla/src/timerlat_top.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
tools/tracing/rtla/src/timerlat_top.c +13 -11
index 2afd619c16059..f9221c71dd1ed 100644
@@ -515,23 +515,25 @@ static int
 timerlat_top_bpf_main_loop(struct osnoise_tool *tool)
 {
 	const struct common_params *params = tool->params;
-	int retval, wait_retval;
+	int sleep_time, retval, wait_retval;
 
-	if (params->aa_only) {
-		/* Auto-analysis only, just wait for stop tracing */
-		timerlat_bpf_wait(-1);
-		return 0;
+	if (params->quiet || params->aa_only) {
+		/* There is no data to periodically refresh */
+		sleep_time = -1;
+	} else {
+		sleep_time = params->sleep_time;
 	}
 
 	/* Pull and display data in a loop */
 	while (!stop_tracing) {
-		wait_retval = timerlat_bpf_wait(params->quiet ? -1 :
-						params->sleep_time);
+		wait_retval = timerlat_bpf_wait(sleep_time);
 
-		retval = timerlat_top_bpf_pull_data(tool);
-		if (retval) {
-			err_msg("Error pulling BPF data\n");
-			return retval;
+		if (!params->aa_only) {
+			retval = timerlat_top_bpf_pull_data(tool);
+			if (retval) {
+				err_msg("Error pulling BPF data\n");
+				return retval;
+			}
 		}
 
 		if (!params->quiet)
Signature · 1 line
2.56.1
author maintainer
#1 lore raw

PATCH 2/2 rtla/tests: Test --aa-only with actions

Add a runtime test that verifies that actions trigger with rtla timerlat top --aa-only in both BPF and tracefs mode.

---
 tools/tracing/rtla/tests/timerlat.t | 2 ++
 1 file changed, 2 insertions(+)
tools/tracing/rtla/tests/timerlat.t +2 -0
index 1d317c851a0fa..aab026ead6c55 100644
@@ -138,6 +138,8 @@ check_top_hist "with trace output at end" \
 	"timerlat TOOL -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
 check_top_q_hist "action with no threshold" \
 	"timerlat TOOL -d 1s --on-threshold shell,command='echo BAD'" 0 "" "BAD"
+check "action with --aa-only" \
+	"timerlat top --aa-only 1 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
 
 # BPF action program tests
 if [ "$option" -eq 0 ]
Signature · 1 line
2.56.1