When using rtla timerlat with userspace threads (-u or -U), rtla
disables the OSNOISE_WORKLOAD option in
/sys/kernel/tracing/osnoise/options. This option is not re-enabled in a
subsequent run with kernel-space threads, leading to rtla collecting no
results if the previous run exited abnormally:

$ rtla timerlat hist -u
^\Quit (core dumped)
$ rtla timerlat hist -k -d 1s
Index
over:
count:
min:
avg:
max:
ALL:        IRQ       Thr       Usr
count:        0         0         0
min:          -         -         -
avg:          -         -         -
max:          -         -         -

The issue persists until OSNOISE_WORKLOAD is set manually by running:
$ echo OSNOISE_WORKLOAD > /sys/kernel/tracing/osnoise/options

Set OSNOISE_WORKLOAD when running rtla with kernel-space threads if
available to fix the issue.

Cc: sta...@vger.kernel.org
Fixes: ed774f7481fa ("rtla/timerlat_hist: Add timerlat user-space support")
Signed-off-by: Tomas Glozar <tglo...@redhat.com>
---
 tools/tracing/rtla/src/timerlat_hist.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/tracing/rtla/src/timerlat_hist.c 
b/tools/tracing/rtla/src/timerlat_hist.c
index 4403cc4eba30..66dbc034bdc7 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -1100,12 +1100,15 @@ timerlat_hist_apply_config(struct osnoise_tool *tool, 
struct timerlat_hist_param
                }
        }
 
-       if (params->user_hist) {
-               retval = osnoise_set_workload(tool->context, 0);
-               if (retval) {
-                       err_msg("Failed to set OSNOISE_WORKLOAD option\n");
-                       goto out_err;
-               }
+       /*
+       * Set workload according to type of thread if the kernel supports it.
+       * On kernels without support, user threads will have already failed
+       * on missing timerlat_fd, and kernel threads do not need it.
+       */
+       retval = osnoise_set_workload(tool->context, params->kernel_workload);
+       if (retval < -1) {
+               err_msg("Failed to set OSNOISE_WORKLOAD option\n");
+               goto out_err;
        }
 
        return 0;
-- 
2.47.1


Reply via email to