Skip to content

Commit 417bd0d

Browse files
tools/rtla: Fix --on-threshold always triggering
Commit 8d933d5 ("rtla/timerlat: Add continue action") moved the code performing on-threshold actions (enabled through --on-threshold option) to inside the RTLA main loop. The condition in the loop does not check whether the threshold was actually exceeded or if stop tracing was requested by the user through SIGINT or duration. This leads to a bug where on-threshold actions are always performed, even when the threshold was not hit. (BPF mode is not affected, since it uses a different condition in the while loop.) Add a condition that checks for !stop_tracing before executing the actions. Also, fix incorrect brackets in hist_main_loop to match the semantics of top_main_loop. Fixes: 8d933d5 ("rtla/timerlat: Add continue action") Fixes: 2f3172f ("tools/rtla: Consolidate code between osnoise/timerlat and hist/top") Reviewed-by: Crystal Wood <crwood@redhat.com> Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20251007095341.186923-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent e4240db commit 417bd0d

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

tools/tracing/rtla/src/common.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ int top_main_loop(struct osnoise_tool *tool)
268268
tool->ops->print_stats(tool);
269269

270270
if (osnoise_trace_is_off(tool, record)) {
271+
if (stop_tracing)
272+
/* stop tracing requested, do not perform actions */
273+
return 0;
274+
271275
actions_perform(&params->threshold_actions);
272276

273277
if (!params->threshold_actions.continue_flag)
@@ -315,20 +319,22 @@ int hist_main_loop(struct osnoise_tool *tool)
315319
}
316320

317321
if (osnoise_trace_is_off(tool, tool->record)) {
322+
if (stop_tracing)
323+
/* stop tracing requested, do not perform actions */
324+
break;
325+
318326
actions_perform(&params->threshold_actions);
319327

320-
if (!params->threshold_actions.continue_flag) {
328+
if (!params->threshold_actions.continue_flag)
321329
/* continue flag not set, break */
322330
break;
323331

324-
/* continue action reached, re-enable tracing */
325-
if (tool->record)
326-
trace_instance_start(&tool->record->trace);
327-
if (tool->aa)
328-
trace_instance_start(&tool->aa->trace);
329-
trace_instance_start(&tool->trace);
330-
}
331-
break;
332+
/* continue action reached, re-enable tracing */
333+
if (tool->record)
334+
trace_instance_start(&tool->record->trace);
335+
if (tool->aa)
336+
trace_instance_start(&tool->aa->trace);
337+
trace_instance_start(&tool->trace);
332338
}
333339

334340
/* is there still any user-threads ? */

0 commit comments

Comments
 (0)