Skip to contentSkip to conversation

rtla: Updates for 6.15

PATCH New Steven Rostedt 1 participant 10 messages Mar 26, 2025 Real-time Linux Analysis (rtla) tools

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover rtla: Updates for 6.15

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
tools/for-next

Head SHA1: 732032692f6ae311bc35159b18e5b7c5e64010fc

John Kacur (1):
rtla: Add the ability to create ctags and etags

Tomas Glozar (8):
tools/build: Use SYSTEM_BPFTOOL for system bpftool
rtla: Fix segfault in save_trace_to_file call rtla/osnoise: Unify params struct
rtla: Unify apply_config between top and hist rtla/osnoise: Set OSNOISE_WORKLOAD to true
rtla: Always set all tracer options rtla/tests: Reset osnoise options before check rtla/tests: Test setting default options

----

 tools/build/feature/Makefile           |   2 +-
 tools/scripts/Makefile.include         |   2 +-
 tools/tracing/rtla/Makefile            |   2 +-
 tools/tracing/rtla/Makefile.rtla       |  17 ++++-
 tools/tracing/rtla/src/osnoise.c       |  86 ++++++++++++++++++++++-
 tools/tracing/rtla/src/osnoise.h       |  48 +++++++++++++
 tools/tracing/rtla/src/osnoise_hist.c  | 121 +++++---------------------------
 tools/tracing/rtla/src/osnoise_top.c   | 123 ++++-----------------------------
 tools/tracing/rtla/src/timerlat.c      | 106 ++++++++++++++++++++++++++++
 tools/tracing/rtla/src/timerlat.h      |  12 ++--
 tools/tracing/rtla/src/timerlat_hist.c | 122 +++++---------------------------
 tools/tracing/rtla/src/timerlat_top.c  | 113 ++++--------------------------
 tools/tracing/rtla/src/trace.c         |   2 +-
 tools/tracing/rtla/tests/engine.sh     |  66 ++++++++++++++++++
 tools/tracing/rtla/tests/osnoise.t     |   6 ++
 15 files changed, 397 insertions(+), 431 deletions(-)
author maintainer
#1 lore raw

PATCH 1/9 tools/build: Use SYSTEM_BPFTOOL for system bpftool

From: Tomas Glozar <[email protected]>

The feature test for system bpftool uses BPFTOOL as the variable to set its path, defaulting to just "bpftool" if not set by the user.

This conflicts with selftests and a few other utilities, which expect BPFTOOL to be set to the in-tree bpftool path by default. For example, bpftool selftests fail to build:

$ make -C tools/testing/selftests/bpf/
make: Entering directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

make: *** No rule to make target 'bpftool', needed by '/home/tglozar/dev/linux/tools/testing/selftests/bpf/tools/include/vmlinux.h'. Stop.
make: Leaving directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

Fix the problem by renaming the variable used for system bpftool from BPFTOOL to SYSTEM_BPFTOOL, so that the new usage does not conflict with the existing one of BPFTOOL.

---
 tools/build/feature/Makefile   | 2 +-
 tools/scripts/Makefile.include | 2 +-
 tools/tracing/rtla/Makefile    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/build/feature/Makefile +1 -1
index 4f9c1d950f5d..b8b5fb183dd4 100644
@@ -419,7 +419,7 @@ $(OUTPUT)test-libpfm4.bin:
 	$(BUILD) -lpfm
 
 $(OUTPUT)test-bpftool-skeletons.bin:
-	$(BPFTOOL) version | grep '^features:.*skeletons' \
+	$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
 		> $(@:.bin=.make.output) 2>&1
 ###############################
 
tools/scripts/Makefile.include +1 -1
index 71bbe52721b3..34a33c1ad96c 100644
@@ -92,7 +92,7 @@ LLVM_OBJCOPY	?= llvm-objcopy
 LLVM_STRIP	?= llvm-strip
 
 # Some tools require bpftool
-BPFTOOL		?= bpftool
+SYSTEM_BPFTOOL	?= bpftool
 
 ifeq ($(CC_NO_CLANG), 1)
 EXTRA_WARNINGS += -Wstrict-aliasing=3
tools/tracing/rtla/Makefile +1 -1
index 557af322be61..3dc050317b9d 100644
@@ -78,7 +78,7 @@ src/timerlat.bpf.o: src/timerlat.bpf.c
 	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
 
 src/timerlat.skel.h: src/timerlat.bpf.o
-	$(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
+	$(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@
 else
 src/timerlat.skel.h:
 	$(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH 2/9 rtla: Fix segfault in save_trace_to_file call

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

Running rtla with exit on threshold, but without saving trace leads to a segmenetation fault:

$ rtla timerlat hist -T 10
...
Max timerlat IRQ latency from idle: 4.29 us in cpu 0
Segmentation fault

This is caused by null pointer deference in the call of save_trace_to_file, which attempts to dereference an uninitialized osnoise_tool variable:

save_trace_to_file(record->trace.inst, params->trace_output);
                   ^ this is uninitialized if params->trace_output is
                     not set

Fix this by not attempting to dereference "record" if it is NULL and passing NULL instead. As a safety measure, the first field is also checked for NULL inside save_trace_to_file.

Cc John Kacur <[email protected]>
Cc Luis Goncalves <[email protected]>
Cc Costa Shulyupin <[email protected]>
Fixes dc4d4e7c72d1 ("rtla: Refactor save_trace_to_file")
---
 tools/tracing/rtla/src/osnoise_hist.c  | 3 ++-
 tools/tracing/rtla/src/osnoise_top.c   | 3 ++-
 tools/tracing/rtla/src/timerlat_hist.c | 3 ++-
 tools/tracing/rtla/src/timerlat_top.c  | 3 ++-
 tools/tracing/rtla/src/trace.c         | 2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)
tools/tracing/rtla/src/osnoise_hist.c +2 -1
index 7c6ef67ef3e6..f4c9051c33c4 100644
@@ -983,7 +983,8 @@ int osnoise_hist_main(int argc, char *argv[])
 
 	if (osnoise_trace_is_off(tool, record)) {
 		printf("rtla osnoise hit stop tracing\n");
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		save_trace_to_file(record ? record->trace.inst : NULL,
+				   params->trace_output);
 	}
 
 out_hist:
tools/tracing/rtla/src/osnoise_top.c +2 -1
index 0eeefbbbf317..dacec2f99017 100644
@@ -813,7 +813,8 @@ int osnoise_top_main(int argc, char **argv)
 
 	if (osnoise_trace_is_off(tool, record)) {
 		printf("osnoise hit stop tracing\n");
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		save_trace_to_file(record ? record->trace.inst : NULL,
+				   params->trace_output);
 	}
 
 out_top:
tools/tracing/rtla/src/timerlat_hist.c +2 -1
index 93d0c9e45020..822c068b4776 100644
@@ -1473,7 +1473,8 @@ int timerlat_hist_main(int argc, char *argv[])
 		if (!params->no_aa)
 			timerlat_auto_analysis(params->stop_us, params->stop_total_us);
 
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		save_trace_to_file(record ? record->trace.inst : NULL,
+				   params->trace_output);
 	}
 
 out_hist:
tools/tracing/rtla/src/timerlat_top.c +2 -1
index 3894ac37d81c..c3196a0bb585 100644
@@ -1295,7 +1295,8 @@ int timerlat_top_main(int argc, char *argv[])
 		if (!params->no_aa)
 			timerlat_auto_analysis(params->stop_us, params->stop_total_us);
 
-		save_trace_to_file(record->trace.inst, params->trace_output);
+		save_trace_to_file(record ? record->trace.inst : NULL,
+				   params->trace_output);
 	} else if (params->aa_only) {
 		/*
 		 * If the trace did not stop with --aa-only, at least print the
tools/tracing/rtla/src/trace.c +1 -1
index 74ed2f6208ba..69cbc48d53d3 100644
@@ -75,7 +75,7 @@ int save_trace_to_file(struct tracefs_instance *inst, const char *filename)
 	int out_fd, in_fd;
 	int retval = -1;
 
-	if (!filename)
+	if (!inst || !filename)
 		return 0;
 
 	in_fd = tracefs_instance_file_open(inst, file, O_RDONLY);
Signature · 1 line
2.47.2
author maintainer
#3 lore raw

PATCH 3/9 rtla/osnoise: Unify params struct

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

Instead of having separate structs osnoise_top_params and osnoise_hist_params, use one struct osnoise_params for both.

This allows code using the structs to be shared between osnoise-top and osnoise-hist.

---
 tools/tracing/rtla/src/osnoise.c      |  1 -
 tools/tracing/rtla/src/osnoise.h      | 47 +++++++++++++++++++++++
 tools/tracing/rtla/src/osnoise_hist.c | 52 ++++++--------------------
 tools/tracing/rtla/src/osnoise_top.c  | 54 +++++----------------------
 tools/tracing/rtla/src/timerlat.h     |  1 -
 5 files changed, 68 insertions(+), 87 deletions(-)
tools/tracing/rtla/src/osnoise.c +0 -1
index 85f398b89597..93d485c0e949 100644
@@ -14,7 +14,6 @@
 #include <stdio.h>
 
 #include "osnoise.h"
-#include "utils.h"
 
 /*
  * osnoise_get_cpus - return the original "osnoise/cpus" content
tools/tracing/rtla/src/osnoise.h +47 -0

55 lines not on this page · raw message

tools/tracing/rtla/src/osnoise_hist.c +11 -41

122 lines not on this page · raw message

tools/tracing/rtla/src/osnoise_top.c +10 -44

115 lines not on this page · raw message

tools/tracing/rtla/src/timerlat.h +0 -1
index e452d385cb0f..cadc613dc82e 100644
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "utils.h"
 #include "osnoise.h"
 
 struct timerlat_params {
Signature · 1 line
2.47.2
author maintainer
#4 lore raw

PATCH 4/9 rtla: Unify apply_config between top and hist

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

The functions osnoise_top_apply_config and osnoise_hist_apply_config, as well as timerlat_top_apply_config and timerlat_hist_apply_config, are mostly the same.

Move common part from them into separate functions osnoise_apply_config and timerlat_apply_config.

For rtla-timerlat, also unify params->user_hist and params->user_top into one field called params->user_data, and move several fields used only by timerlat-top into the top-only section of struct timerlat_params.

---
 tools/tracing/rtla/src/osnoise.c       |  79 ++++++++++++++++
 tools/tracing/rtla/src/osnoise.h       |   1 +
 tools/tracing/rtla/src/osnoise_hist.c  |  66 +-------------
 tools/tracing/rtla/src/osnoise_top.c   |  66 +-------------
 tools/tracing/rtla/src/timerlat.c      | 109 ++++++++++++++++++++++
 tools/tracing/rtla/src/timerlat.h      |  11 +--
 tools/tracing/rtla/src/timerlat_hist.c | 119 ++++---------------------
 tools/tracing/rtla/src/timerlat_top.c  | 110 +++--------------------
 8 files changed, 227 insertions(+), 334 deletions(-)
tools/tracing/rtla/src/osnoise.c +79 -0
index 93d485c0e949..1735a36466c4 100644
@@ -3,6 +3,7 @@
  * Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <[email protected]>
  */
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <pthread.h>
@@ -12,6 +13,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <sched.h>
 
 #include "osnoise.h"
 
@@ -1114,6 +1116,83 @@ osnoise_report_missed_events(struct osnoise_tool *tool)
 	}
 }
 
+/*
+ * osnoise_apply_config - apply common configs to the initialized tool
+ */
+int
+osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
+{
+	int retval;
+
+	if (!params->sleep_time)
+		params->sleep_time = 1;
+
+	if (params->cpus) {
+		retval = osnoise_set_cpus(tool->context, params->cpus);
+		if (retval) {
+			err_msg("Failed to apply CPUs config\n");
+			goto out_err;
+		}
+	}
+
+	if (params->runtime || params->period) {
+		retval = osnoise_set_runtime_period(tool->context,
+						    params->runtime,
+						    params->period);
+		if (retval) {
+			err_msg("Failed to set runtime and/or period\n");
+			goto out_err;
+		}
+	}
+
+	if (params->stop_us) {
+		retval = osnoise_set_stop_us(tool->context, params->stop_us);
+		if (retval) {
+			err_msg("Failed to set stop us\n");
+			goto out_err;
+		}
+	}
+
+	if (params->stop_total_us) {
+		retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us);
+		if (retval) {
+			err_msg("Failed to set stop total us\n");
+			goto out_err;
+		}
+	}
+
+	if (params->threshold) {
+		retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
+		if (retval) {
+			err_msg("Failed to set tracing_thresh\n");
+			goto out_err;
+		}
+	}
+
+	if (params->hk_cpus) {
+		retval = sched_setaffinity(getpid(), sizeof(params->hk_cpu_set),
+					   &params->hk_cpu_set);
+		if (retval == -1) {
+			err_msg("Failed to set rtla to the house keeping CPUs\n");
+			goto out_err;
+		}
+	} else if (params->cpus) {
+		/*
+		 * Even if the user do not set a house-keeping CPU, try to
+		 * move rtla to a CPU set different to the one where the user
+		 * set the workload to run.
+		 *
+		 * No need to check results as this is an automatic attempt.
+		 */
+		auto_house_keeping(&params->monitored_cpus);
+	}
+
+	return 0;
+
+out_err:
+	return -1;
+}
+
 static void osnoise_usage(int err)
 {
 	int i;
tools/tracing/rtla/src/osnoise.h +1 -0
index f78ffbdc8c8d..ac1c99910744 100644
@@ -155,6 +155,7 @@ struct osnoise_tool *osnoise_init_tool(char *tool_name);
 struct osnoise_tool *osnoise_init_trace_tool(char *tracer);
 void osnoise_report_missed_events(struct osnoise_tool *tool);
 bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *record);
+int osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params);
 
 int osnoise_hist_main(int argc, char *argv[]);
 int osnoise_top_main(int argc, char **argv);
tools/tracing/rtla/src/osnoise_hist.c +3 -63

78 lines not on this page · raw message

tools/tracing/rtla/src/osnoise_top.c +3 -63

84 lines not on this page · raw message

tools/tracing/rtla/src/timerlat.c +109 -0

124 lines not on this page · raw message

tools/tracing/rtla/src/timerlat.h +6 -5
index cadc613dc82e..73045aef23fa 100644
@@ -15,17 +15,15 @@ struct timerlat_params {
 	int			sleep_time;
 	int			output_divisor;
 	int			duration;
-	int			quiet;
 	int			set_sched;
 	int			dma_latency;
 	int			no_aa;
-	int			aa_only;
 	int			dump_tasks;
 	int			cgroup;
 	int			hk_cpus;
 	int			user_workload;
 	int			kernel_workload;
-	int			pretty_output;
+	int			user_data;
 	int			warmup;
 	int			buffer_size;
 	int			deepest_idle_state;
@@ -35,11 +33,12 @@ struct timerlat_params {
 	union {
 		struct {
 			/* top only */
-			int			user_top;
+			int			quiet;
+			int			aa_only;
+			int			pretty_output;
 		};
 		struct {
 			/* hist only */
-			int			user_hist;
 			char			no_irq;
 			char			no_thread;
 			char			no_header;
@@ -52,6 +51,8 @@ struct timerlat_params {
 	};
 };
 
+int timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params);
+
 int timerlat_hist_main(int argc, char *argv[]);
 int timerlat_top_main(int argc, char *argv[]);
 int timerlat_main(int argc, char *argv[]);
tools/tracing/rtla/src/timerlat_hist.c +16 -103

205 lines not on this page · raw message

tools/tracing/rtla/src/timerlat_top.c +10 -100

166 lines not on this page · raw message

Signature · 1 line
2.47.2
author maintainer
#5 lore raw

PATCH 5/9 rtla/osnoise: Set OSNOISE_WORKLOAD to true

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

If running rtla osnoise with NO_OSNOISE_WORKLOAD, it reports no samples:

$ echo NO_OSNOISE_WORKLOAD > /sys/kernel/tracing/osnoise/options
$ rtla osnoise hist -d 10s
Index
over: 0
count: 0
min: 0
avg: 0
max: 0

This situation can also happen when running rtla-osnoise after an improperly exited rtla-timerlat run.

Set OSNOISE_WORKLOAD in rtla-osnoise, too, similarly to what we already did for timerlat in commit 217f0b1e990e ("rtla/timerlat_top: Set OSNOISE_WORKLOAD for kernel threads") and commit d8d866171a41 ("rtla/timerlat_hist: Set OSNOISE_WORKLOAD for kernel threads").

Note that there is no user workload mode for rtla-osnoise yet, so OSNOISE_WORKLOAD is always set to true.

Cc Luis Goncalves <[email protected]>
Fixes 1eceb2fc2ca5 ("rtla/osnoise: Add osnoise top mode")
Fixes 829a6c0b5698 ("rtla/osnoise: Add the hist mode")
---
 tools/tracing/rtla/src/osnoise.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/tracing/rtla/src/osnoise.c +6 -0
index 1735a36466c4..a71618d876e9 100644
@@ -1187,6 +1187,12 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
 		auto_house_keeping(&params->monitored_cpus);
 	}
 
+	retval = osnoise_set_workload(tool->context, true);
+	if (retval < -1) {
+		err_msg("Failed to set OSNOISE_WORKLOAD option\n");
+		goto out_err;
+	}
+
 	return 0;
 
 out_err:
Signature · 1 line
2.47.2
author maintainer
#6 lore raw

PATCH 6/9 rtla: Always set all tracer options

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

rtla currently only sets tracer options that are explicitly set by the user, with the exception of OSNOISE_WORKLOAD.

This leads to improper behavior in case rtla is run with those options not set to the default value. rtla does reset them to the original value upon exiting, but that does not protect it from starting with non-default values set either by an improperly exited rtla or by another user of the tracers.

For example, after running this command:

$ echo 1 > /sys/kernel/tracing/osnoise/stop_tracing_us

all runs of rtla will stop at the 1us threshold, even if not requested by the user:

$ rtla osnoise hist
Index   CPU-000   CPU-001
1             8         5
2             5         9
3             1         2
4             6         1
5             2         1
6             0         1
8             1         1
12            0         1
14            1         0
15            1         0
over:         0         0
count:       25        21
min:          1         1
avg:       3.68      3.05
max:         15        12
rtla osnoise hit stop tracing

Fix the problem by setting the default value for all tracer options if the user has not provided their own value.

For most of the options, it's enough to just drop the if clause checking for the value being set. For cpus, "all" is used as the default value, and for osnoise default period and runtime, default values of the osnoise_data variable in trace_osnoise.c are used.

Cc Luis Goncalves <[email protected]>
Fixes 1eceb2fc2ca5 ("rtla/osnoise: Add osnoise top mode")
Fixes 829a6c0b5698 ("rtla/osnoise: Add the hist mode")
Fixes a828cd18bc4a ("rtla: Add timerlat tool and timelart top mode")
Fixes 1eeb6328e8b3 ("rtla/timerlat: Add timerlat hist mode")
---
 tools/tracing/rtla/src/osnoise.c  | 56 ++++++++++++++---------------
 tools/tracing/rtla/src/timerlat.c | 59 +++++++++++++++----------------
 2 files changed, 56 insertions(+), 59 deletions(-)
tools/tracing/rtla/src/osnoise.c +28 -28
index a71618d876e9..2dc3e4539e99 100644
@@ -17,6 +17,9 @@
 
 #include "osnoise.h"
 
+#define DEFAULT_SAMPLE_PERIOD	1000000			/* 1s */
+#define DEFAULT_SAMPLE_RUNTIME	1000000			/* 1s */
+
 /*
  * osnoise_get_cpus - return the original "osnoise/cpus" content
  *
@@ -1127,46 +1130,43 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
 	if (!params->sleep_time)
 		params->sleep_time = 1;
 
-	if (params->cpus) {
-		retval = osnoise_set_cpus(tool->context, params->cpus);
-		if (retval) {
-			err_msg("Failed to apply CPUs config\n");
-			goto out_err;
-		}
+	retval = osnoise_set_cpus(tool->context, params->cpus ? params->cpus : "all");
+	if (retval) {
+		err_msg("Failed to apply CPUs config\n");
+		goto out_err;
 	}
 
 	if (params->runtime || params->period) {
 		retval = osnoise_set_runtime_period(tool->context,
 						    params->runtime,
 						    params->period);
-		if (retval) {
-			err_msg("Failed to set runtime and/or period\n");
-			goto out_err;
-		}
+	} else {
+		retval = osnoise_set_runtime_period(tool->context,
+						    DEFAULT_SAMPLE_PERIOD,
+						    DEFAULT_SAMPLE_RUNTIME);
 	}
 
-	if (params->stop_us) {
-		retval = osnoise_set_stop_us(tool->context, params->stop_us);
-		if (retval) {
-			err_msg("Failed to set stop us\n");
-			goto out_err;
-		}
+	if (retval) {
+		err_msg("Failed to set runtime and/or period\n");
+		goto out_err;
 	}
 
-	if (params->stop_total_us) {
-		retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us);
-		if (retval) {
-			err_msg("Failed to set stop total us\n");
-			goto out_err;
-		}
+	retval = osnoise_set_stop_us(tool->context, params->stop_us);
+	if (retval) {
+		err_msg("Failed to set stop us\n");
+		goto out_err;
 	}
 
-	if (params->threshold) {
-		retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
-		if (retval) {
-			err_msg("Failed to set tracing_thresh\n");
-			goto out_err;
-		}
+	retval = osnoise_set_stop_total_us(tool->context, params->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");
+		goto out_err;
 	}
 
 	if (params->hk_cpus) {
tools/tracing/rtla/src/timerlat.c +28 -31

83 lines not on this page · raw message

Signature · 1 line
2.47.2
author maintainer
#7 lore raw

PATCH 7/9 rtla/tests: Reset osnoise options before check

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

Remove any dangling tracing instances from previous improperly exited runs of rtla, and reset osnoise options to default before running a test case.

This ensures that the test results are deterministic. Specific test cases checked that rtla behaves correctly even when the tracer state is not clean will be added later.

---
 tools/tracing/rtla/tests/engine.sh | 40 ++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
tools/tracing/rtla/tests/engine.sh +40 -0
index 64d0446dc28e..5db8aa4bc031 100644
@@ -8,12 +8,44 @@ test_begin() {
 	[ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT"
 }
 
+reset_osnoise() {
+	# Reset osnoise options to default and remove any dangling instances created
+	# by improperly exited rtla runs.
+	pushd /sys/kernel/tracing || return 1
+
+	# Remove dangling instances created by previous rtla run
+	echo 0 > tracing_thresh
+	cd instances
+	for i in osnoise_top osnoise_hist timerlat_top timerlat_hist
+	do
+		[ ! -d "$i" ] && continue
+		rmdir "$i"
+	done
+
+	# Reset options to default
+	# Note: those are copied from the default values of osnoise_data
+	# in kernel/trace/trace_osnoise.c
+	cd ../osnoise
+	echo all > cpus
+	echo DEFAULTS > options
+	echo 1000000 > period_us
+	echo 0 > print_stack
+	echo 1000000 > runtime_us
+	echo 0 > stop_tracing_total_us
+	echo 0 > stop_tracing_us
+	echo 1000 > timerlat_period_us
+
+	popd
+}
+
 check() {
 	# Simple check: run rtla with given arguments and test exit code.
 	# If TEST_COUNT is set, run the test. Otherwise, just count.
 	ctr=$(($ctr + 1))
 	if [ -n "$TEST_COUNT" ]
 	then
+		# Reset osnoise options before running test.
+		[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
 		# Run rtla; in case of failure, include its output as comment
 		# in the test results.
 		result=$(stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$?
@@ -37,6 +69,14 @@ unset_timeout() {
 	unset TIMEOUT
 }
 
+set_no_reset_osnoise() {
+	NO_RESET_OSNOISE=1
+}
+
+unset_no_reset_osnoise() {
+	unset NO_RESET_OSNOISE
+}
+
 test_end() {
 	# If running without TEST_COUNT, tests are not actually run, just
 	# counted. In that case, re-run the test with the correct count.
Signature · 1 line
2.47.2
author maintainer
#8 lore raw

PATCH 8/9 rtla/tests: Test setting default options

In reply to Steven Rostedt

From: Tomas Glozar <[email protected]>

Add function to test engine to test with pre-set osnoise options, and use it to test whether osnoise period (as an example) is set correctly.

The test works by pre-setting a high period of 10 minutes and stop on threshold. Thus, it is easy to check whether rtla is properly resetting the period to default: if it is, the test will complete on time, since the first sample will overflow the threshold. If not, it will time out.

---
 tools/tracing/rtla/tests/engine.sh | 26 ++++++++++++++++++++++++++
 tools/tracing/rtla/tests/osnoise.t |  6 ++++++
 2 files changed, 32 insertions(+)
tools/tracing/rtla/tests/engine.sh +26 -0
index 5db8aa4bc031..b1697b3e3f52 100644
@@ -61,6 +61,32 @@ check() {
 	fi
 }
 
+check_with_osnoise_options() {
+	# Do the same as "check", but with pre-set osnoise options.
+	# Note: rtla should reset the osnoise options, this is used to test
+	# if it indeed does so.
+	# Save original arguments
+	arg1=$1
+	arg2=$2
+
+	# Apply osnoise options (if not dry run)
+	if [ -n "$TEST_COUNT" ]
+	then
+		[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
+		shift
+		while shift
+		do
+			[ "$1" == "" ] && continue
+			option=$(echo $1 | cut -d '=' -f 1)
+			value=$(echo $1 | cut -d '=' -f 2)
+			echo "option: $option, value: $value"
+			echo "$value" > "/sys/kernel/tracing/osnoise/$option" || return 1
+		done
+	fi
+
+	NO_RESET_OSNOISE=1 check "$arg1" "$arg2"
+}
+
 set_timeout() {
 	TIMEOUT="timeout -v -k 15s $1"
 }
tools/tracing/rtla/tests/osnoise.t +6 -0
index 86596e547893..e5995c03c790 100644
@@ -16,4 +16,10 @@ check "verify the  --trace param" \
 check "verify the --entries/-E param" \
 	"osnoise hist -P F:1 -c 0 -r 900000 -d 1M -b 10 -E 25"
 
+# Test setting default period by putting an absurdly high period
+# and stopping on threshold.
+# If default period is not set, this will time out.
+check_with_osnoise_options "apply default period" \
+	"osnoise hist -s 1" period_us=600000000
+
 test_end
Signature · 1 line
2.47.2
author maintainer
#9 lore raw

PATCH 9/9 rtla: Add the ability to create ctags and etags

In reply to Steven Rostedt

From: John Kacur <[email protected]>

- Add the ability to create and remove ctags and etags, using the following make tags
make TAGS
make tags_clean

- fix a comment in Makefile.rtla with the correct spelling and don't imply that the ability to create an rtla tarball will be removed

---
 tools/tracing/rtla/Makefile.rtla | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
tools/tracing/rtla/Makefile.rtla +15 -2
index cc1d6b615475..08c1b40883d3 100644
@@ -34,6 +34,8 @@ INSTALL		:= install
 MKDIR		:= mkdir
 STRIP		:= strip
 BINDIR		:= /usr/bin
+CTAGS		:= ctags
+ETAGS		:= ctags -e
 
 .PHONY: install
 install: doc_install
@@ -47,6 +49,18 @@ install: doc_install
 	@test ! -f $(DESTDIR)$(BINDIR)/timerlat || $(RM) $(DESTDIR)$(BINDIR)/timerlat
 	@$(LN) -s rtla $(DESTDIR)$(BINDIR)/timerlat
 
+.PHONY: tags
+tags:
+	$(CTAGS) -R --extras=+f --c-kinds=+p src
+
+.PHONY: TAGS
+TAGS:
+	$(ETAGS) -R --extras=+f --c-kinds=+p src
+
+.PHONY: tags_clean
+tags_clean:
+	$(RM) tags TAGS
+
 .PHONY: doc doc_clean doc_install
 doc:
 	$(MAKE) -C $(DOCSRC)
@@ -57,8 +71,7 @@ doc_clean:
 doc_install:
 	$(MAKE) -C $(DOCSRC) install
 
-# This section is neesary for the tarball, when the tarball
-# support is removed, we can delete these entries.
+# This section is necessary to make the rtla tarball
 NAME		:= rtla
 DIRS		:= src
 FILES		:= Makefile README.txt
Signature · 1 line
2.47.2