]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtla: Set stop threshold after all instances are enabled
authorCrystal Wood <crwood@redhat.com>
Wed, 12 Nov 2025 15:25:29 +0000 (09:25 -0600)
committerTomas Glozar <tglozar@redhat.com>
Wed, 7 Jan 2026 14:57:15 +0000 (15:57 +0100)
This avoids startup races where one of the instances hit a threshold
before all instances were enabled, and thus tracing stops without
the relevant event.  In particular, this is not uncommon with the
tests that set a very tight threshold and then complain if there's
no analysis.

This also ensures that we don't stop tracing during a warmup.

The downside is a small chance of having an event over the threshold
early in the output, without stopping on it, which could cause user
confusion.  This should be less likely if the warmup feature is used, but
that doesn't eliminate the race window, just the odds of an unusual spike
right at that moment.

Signed-off-by: Crystal Wood <crwood@redhat.com>
Link: https://lore.kernel.org/r/20251112152529.956778-6-crwood@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/common.h
tools/tracing/rtla/src/osnoise.c
tools/tracing/rtla/src/osnoise.h
tools/tracing/rtla/src/timerlat.c

index b197037fc58b37554c59fbfbfbfbb31d105cd727..46e0263d6ae8e921ee63dafcbc4fa654fd6972ed 100644 (file)
@@ -348,3 +348,23 @@ int hist_main_loop(struct osnoise_tool *tool)
 
        return retval;
 }
+
+int osn_set_stop(struct osnoise_tool *tool)
+{
+       struct common_params *params = tool->params;
+       int retval;
+
+       retval = osnoise_set_stop_us(tool->context, params->stop_us);
+       if (retval) {
+               err_msg("Failed to set stop us\n");
+               return retval;
+       }
+
+       retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us);
+       if (retval) {
+               err_msg("Failed to set stop total us\n");
+               return retval;
+       }
+
+       return 0;
+}
index 9ec2b7632c376eb2f01c2f43ef4bb3fc1d237e5b..c5e73d4600a0989f4dd2db8831ee54b11e8e3c71 100644 (file)
@@ -152,7 +152,11 @@ void osnoise_destroy_tool(struct osnoise_tool *top);
 struct osnoise_tool *osnoise_init_tool(char *tool_name);
 struct osnoise_tool *osnoise_init_trace_tool(const char *tracer);
 bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *record);
+int osnoise_set_stop_us(struct osnoise_context *context, long long stop_us);
+int osnoise_set_stop_total_us(struct osnoise_context *context,
+                             long long stop_total_us);
 
 int common_apply_config(struct osnoise_tool *tool, struct common_params *params);
 int top_main_loop(struct osnoise_tool *tool);
 int hist_main_loop(struct osnoise_tool *tool);
+int osn_set_stop(struct osnoise_tool *tool);
index 312c511fa00443fd6979a4db0bd39855f2250d1a..945eb61efc46567079b69f75fb2724bc388a827f 100644 (file)
@@ -1128,18 +1128,6 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
                goto out_err;
        }
 
-       retval = osnoise_set_stop_us(tool->context, params->common.stop_us);
-       if (retval) {
-               err_msg("Failed to set stop us\n");
-               goto out_err;
-       }
-
-       retval = osnoise_set_stop_total_us(tool->context, params->common.stop_total_us);
-       if (retval) {
-               err_msg("Failed to set stop total us\n");
-               goto out_err;
-       }
-
        retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
        if (retval) {
                err_msg("Failed to set tracing_thresh\n");
@@ -1184,9 +1172,12 @@ int osnoise_enable(struct osnoise_tool *tool)
                        debug_msg("Error cleaning up the buffer");
                        return retval;
                }
-
        }
 
+       retval = osn_set_stop(tool);
+       if (retval)
+               return retval;
+
        return 0;
 }
 
index 75de0d5c706a32290bce2d2a37ab333f62607d50..168669aa7e0d5598dc64a03a38d34209ef2676e3 100644 (file)
@@ -34,12 +34,7 @@ int osnoise_set_runtime_period(struct osnoise_context *context,
                               unsigned long long period);
 void osnoise_restore_runtime_period(struct osnoise_context *context);
 
-int osnoise_set_stop_us(struct osnoise_context *context,
-                       long long stop_us);
 void osnoise_restore_stop_us(struct osnoise_context *context);
-
-int osnoise_set_stop_total_us(struct osnoise_context *context,
-                             long long stop_total_us);
 void osnoise_restore_stop_total_us(struct osnoise_context *context);
 
 int osnoise_set_timerlat_period_us(struct osnoise_context *context,
index df4f9bfe3433168d7f813cb5af4c375e0e52e65a..ee15e344cf3775fbe6d539f05eb89c25e6354e4c 100644 (file)
@@ -48,25 +48,6 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)
                }
        }
 
-       if (params->mode != TRACING_MODE_BPF) {
-               /*
-                * In tracefs and mixed mode, timerlat tracer handles stopping
-                * on threshold
-                */
-               retval = osnoise_set_stop_us(tool->context, params->common.stop_us);
-               if (retval) {
-                       err_msg("Failed to set stop us\n");
-                       goto out_err;
-               }
-
-               retval = osnoise_set_stop_total_us(tool->context, params->common.stop_total_us);
-               if (retval) {
-                       err_msg("Failed to set stop total us\n");
-                       goto out_err;
-               }
-       }
-
-
        retval = osnoise_set_timerlat_period_us(tool->context,
                                                params->timerlat_period_us ?
                                                params->timerlat_period_us :
@@ -184,6 +165,16 @@ int timerlat_enable(struct osnoise_tool *tool)
                }
        }
 
+       /*
+        * In tracefs and mixed mode, timerlat tracer handles stopping
+        * on threshold
+        */
+       if (params->mode != TRACING_MODE_BPF) {
+               retval = osn_set_stop(tool);
+               if (retval)
+                       return retval;
+       }
+
        return 0;
 }