From nobody Mon Oct 6 13:35:28 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BA01245000 for ; Mon, 21 Jul 2025 23:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753139512; cv=none; b=Y+9CerWhITD4oSAsZfmx+t/rY8iSYeH5AW+fGgDpQCyXzIxDqxghFiaUo2SRALwBBIwNFF7N108kIdPR6VHXbBnHEI3yZpjCIJaS+luQhNw2WMRlpKFQYigHeTIsjzsEsAdSBMN2zRWcTSxAz2dRx/kP1uawoaONj76Mhp4Jq4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753139512; c=relaxed/simple; bh=jcjCtNAcQO3+9YMjnkp8D57fNpuPEJInwxLCLjQDjwg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=HU8+Uv0qWPuQhUx4wcgDTjhyhnJK143ROtZAwL3v2DI8fTKW+zaOGU6e+d2Xi6GEdryHGbkDH6EjXagyv0GuJk4uhXvo1dWAx33GfAW/6f+nfoohoSObT3MhSLv34KCOetXh9J7mCYI6bOYjvQ5WrLFRpdj4E3/1agdS3bzlBWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WTKYDY6W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WTKYDY6W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7A2DC4CEED; Mon, 21 Jul 2025 23:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753139511; bh=jcjCtNAcQO3+9YMjnkp8D57fNpuPEJInwxLCLjQDjwg=; h=Date:From:To:Cc:Subject:References:From; b=WTKYDY6WAN7rcLlwOS/mUMFsHz7HuFXHQo1g0+HflCU3dy9+UawLjHiWU/OIDPF3r 0BYxp+NyoSBa+U5N1ntypXjlkLCNYvw1gbDQw225LvyAfY2LIiaK17wz+K5s5kpsxQ lcmz539/N/OrMajmsP8e6lGHWyv5y1TFQdOJPEP15jkrL6uv5dR11zWwzgx9SezSzW t/lr6hILhy3yw3bwENP0D90hk0CCmMzCZH8y0xr4lwHBr69mWIkbOE7faf5RBZA01H PVV6plNpB9QsBW7I4SlQBroMDQwUMMYphKnRXG25mI0aJGzM/sKayzd3W8W9VLGd9F nOqf4tJLoW+KQ== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1udzgE-00000009vIs-3xNT; Mon, 21 Jul 2025 19:12:22 -0400 Message-ID: <20250721231222.797319180@kernel.org> User-Agent: quilt/0.68 Date: Mon, 21 Jul 2025 19:12:08 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur , Luis Goncalves , Arnaldo Carvalho de Melo , Chang Yin , Costa Shulyupin , Crystal Wood , Gabriele Monaco Subject: [for-next][PATCH 4/9] rtla/timerlat: Add continue action References: <20250721231204.100737734@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tomas Glozar Introduce option to resume tracing after a latency threshold overflow. The option is implemented as an action named "continue". Example: $ rtla timerlat top -q -T 200 -d 1s --on-threshold \ exec,command=3D"echo Threshold" --on-threshold continue Threshold Threshold Threshold Timer Latency ... The feature is supported for both hist and top. After the continue action is executed, processing of the list of actions is stopped and tracing is resumed. Cc: John Kacur Cc: Luis Goncalves Cc: Arnaldo Carvalho de Melo Cc: Chang Yin Cc: Costa Shulyupin Cc: Crystal Wood Cc: Gabriele Monaco Link: https://lore.kernel.org/20250626123405.1496931-5-tglozar@redhat.com Signed-off-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/src/actions.c | 27 +++++++++++- tools/tracing/rtla/src/actions.h | 5 ++- tools/tracing/rtla/src/timerlat_hist.c | 40 +++++++++++++++--- tools/tracing/rtla/src/timerlat_top.c | 57 ++++++++++++++++---------- 4 files changed, 100 insertions(+), 29 deletions(-) diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/acti= ons.c index 63bee5bdabfd..aaf0808125d7 100644 --- a/tools/tracing/rtla/src/actions.c +++ b/tools/tracing/rtla/src/actions.c @@ -17,6 +17,7 @@ actions_init(struct actions *self) self->size =3D action_default_size; self->list =3D calloc(self->size, sizeof(struct action)); self->len =3D 0; + self->continue_flag =3D false; =20 memset(&self->present, 0, sizeof(self->present)); =20 @@ -108,6 +109,20 @@ actions_add_shell(struct actions *self, const char *co= mmand) return 0; } =20 +/* + * actions_add_continue - add an action to resume measurement + */ +int +actions_add_continue(struct actions *self) +{ + struct action *action =3D actions_new(self); + + self->present[ACTION_CONTINUE] =3D true; + action->type =3D ACTION_CONTINUE; + + return 0; +} + /* * actions_parse - add an action based on text specification */ @@ -133,6 +148,8 @@ actions_parse(struct actions *self, const char *trigger) type =3D ACTION_SIGNAL; else if (strcmp(token, "shell") =3D=3D 0) type =3D ACTION_SHELL; + else if (strcmp(token, "continue") =3D=3D 0) + type =3D ACTION_CONTINUE; else /* Invalid trigger type */ return -1; @@ -187,6 +204,11 @@ actions_parse(struct actions *self, const char *trigge= r) if (strlen(token) > 8 && strncmp(token, "command=3D", 8) =3D=3D 0) return actions_add_shell(self, token + 8); return -1; + case ACTION_CONTINUE: + /* Takes no argument */ + if (token !=3D NULL) + return -1; + return actions_add_continue(self); default: return -1; } @@ -196,7 +218,7 @@ actions_parse(struct actions *self, const char *trigger) * actions_perform - perform all actions */ int -actions_perform(const struct actions *self) +actions_perform(struct actions *self) { int pid, retval; const struct action *action; @@ -226,6 +248,9 @@ actions_perform(const struct actions *self) if (retval) return retval; break; + case ACTION_CONTINUE: + self->continue_flag =3D true; + return 0; default: break; } diff --git a/tools/tracing/rtla/src/actions.h b/tools/tracing/rtla/src/acti= ons.h index 076bbff8519e..b10a19d55c49 100644 --- a/tools/tracing/rtla/src/actions.h +++ b/tools/tracing/rtla/src/actions.h @@ -7,6 +7,7 @@ enum action_type { ACTION_TRACE_OUTPUT, ACTION_SIGNAL, ACTION_SHELL, + ACTION_CONTINUE, ACTION_FIELD_N }; =20 @@ -35,6 +36,7 @@ struct actions { struct action *list; int len, size; bool present[ACTION_FIELD_N]; + bool continue_flag; =20 /* External dependencies */ struct tracefs_instance *trace_output_inst; @@ -45,5 +47,6 @@ void actions_destroy(struct actions *self); int actions_add_trace_output(struct actions *self, const char *trace_outpu= t); int actions_add_signal(struct actions *self, int signal, int pid); int actions_add_shell(struct actions *self, const char *command); +int actions_add_continue(struct actions *self); int actions_parse(struct actions *self, const char *trigger); -int actions_perform(const struct actions *self); +int actions_perform(struct actions *self); diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index d975d2cd6604..4f13a8f92711 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -1374,8 +1374,20 @@ int timerlat_hist_main(int argc, char *argv[]) goto out_hist; } =20 - if (osnoise_trace_is_off(tool, record)) - break; + if (osnoise_trace_is_off(tool, record)) { + actions_perform(¶ms->actions); + + if (!params->actions.continue_flag) + /* continue flag not set, break */ + break; + + /* continue action reached, re-enable tracing */ + if (params->actions.present[ACTION_TRACE_OUTPUT]) + trace_instance_start(&record->trace); + if (!params->no_aa) + trace_instance_start(&aa->trace); + trace_instance_start(trace); + } =20 /* is there still any user-threads ? */ if (params->user_workload) { @@ -1385,8 +1397,27 @@ int timerlat_hist_main(int argc, char *argv[]) } } } - } else - timerlat_bpf_wait(-1); + } else { + while (!stop_tracing) { + timerlat_bpf_wait(-1); + + if (!stop_tracing) { + /* Threshold overflow, perform actions on threshold */ + actions_perform(¶ms->actions); + + if (!params->actions.continue_flag) + /* continue flag not set, break */ + break; + + /* continue action reached, re-enable tracing */ + if (params->actions.present[ACTION_TRACE_OUTPUT]) + trace_instance_start(&record->trace); + if (!params->no_aa) + trace_instance_start(&aa->trace); + timerlat_bpf_restart_tracing(); + } + } + } =20 if (params->mode !=3D TRACING_MODE_TRACEFS) { timerlat_bpf_detach(); @@ -1412,7 +1443,6 @@ int timerlat_hist_main(int argc, char *argv[]) if (!params->no_aa) timerlat_auto_analysis(params->stop_us, params->stop_total_us); =20 - actions_perform(¶ms->actions); return_value =3D FAILED; } =20 diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index cdbfda009974..60f9c78cb272 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -906,6 +906,7 @@ timerlat_top_set_signals(struct timerlat_params *params) static int timerlat_top_main_loop(struct osnoise_tool *top, struct osnoise_tool *record, + struct osnoise_tool *aa, struct timerlat_params *params, struct timerlat_u_params *params_u) { @@ -932,8 +933,20 @@ timerlat_top_main_loop(struct osnoise_tool *top, if (!params->quiet) timerlat_print_stats(params, top); =20 - if (osnoise_trace_is_off(top, record)) - break; + if (osnoise_trace_is_off(top, record)) { + actions_perform(¶ms->actions); + + if (!params->actions.continue_flag) + /* continue flag not set, break */ + break; + + /* continue action reached, re-enable tracing */ + if (params->actions.present[ACTION_TRACE_OUTPUT]) + trace_instance_start(&record->trace); + if (!params->no_aa) + trace_instance_start(&aa->trace); + trace_instance_start(trace); + } =20 /* is there still any user-threads ? */ if (params->user_workload) { @@ -953,6 +966,7 @@ timerlat_top_main_loop(struct osnoise_tool *top, static int timerlat_top_bpf_main_loop(struct osnoise_tool *top, struct osnoise_tool *record, + struct osnoise_tool *aa, struct timerlat_params *params, struct timerlat_u_params *params_u) { @@ -964,22 +978,9 @@ timerlat_top_bpf_main_loop(struct osnoise_tool *top, return 0; } =20 - if (params->quiet) { - /* Quiet mode: wait for stop and then, print results */ - timerlat_bpf_wait(-1); - - retval =3D timerlat_top_bpf_pull_data(top); - if (retval) { - err_msg("Error pulling BPF data\n"); - return retval; - } - - return 0; - } - /* Pull and display data in a loop */ while (!stop_tracing) { - wait_retval =3D timerlat_bpf_wait(params->sleep_time); + wait_retval =3D timerlat_bpf_wait(params->quiet ? -1 : params->sleep_tim= e); =20 retval =3D timerlat_top_bpf_pull_data(top); if (retval) { @@ -987,11 +988,24 @@ timerlat_top_bpf_main_loop(struct osnoise_tool *top, return retval; } =20 - timerlat_print_stats(params, top); + if (!params->quiet) + timerlat_print_stats(params, top); =20 - if (wait_retval =3D=3D 1) + if (wait_retval =3D=3D 1) { /* Stopping requested by tracer */ - break; + actions_perform(¶ms->actions); + + if (!params->actions.continue_flag) + /* continue flag not set, break */ + break; + + /* continue action reached, re-enable tracing */ + if (params->actions.present[ACTION_TRACE_OUTPUT]) + trace_instance_start(&record->trace); + if (!params->no_aa) + trace_instance_start(&aa->trace); + timerlat_bpf_restart_tracing(); + } =20 /* is there still any user-threads ? */ if (params->user_workload) { @@ -1205,9 +1219,9 @@ int timerlat_top_main(int argc, char *argv[]) timerlat_top_set_signals(params); =20 if (params->mode =3D=3D TRACING_MODE_TRACEFS) - retval =3D timerlat_top_main_loop(top, record, params, ¶ms_u); + retval =3D timerlat_top_main_loop(top, record, aa, params, ¶ms_u); else - retval =3D timerlat_top_bpf_main_loop(top, record, params, ¶ms_u); + retval =3D timerlat_top_bpf_main_loop(top, record, aa, params, ¶ms_u= ); =20 if (retval) goto out_top; @@ -1230,7 +1244,6 @@ int timerlat_top_main(int argc, char *argv[]) if (!params->no_aa) timerlat_auto_analysis(params->stop_us, params->stop_total_us); =20 - actions_perform(¶ms->actions); return_value =3D FAILED; } else if (params->aa_only) { /* --=20 2.47.2