Subject: [PATCH 0/8] rtla improvements

This is a series of improvements for rtla, mainly as a result of our
daily usage of the tool debugging problems at red hat.

The cgroup support and house keeping options are from our usage
of the tool debugging containers.

The auto-analysis overhead reduction is needed when we go to
large boxes - but it is really hand in practice, as it gives an idea
of the problem without having to look at the trace.

Finally, running hwnoise 100 % of CPU time might cause some systems
to slow down too much. Reduce its utilization to 75% by default to
avoid problems for people using it for the first time.

Daniel Bristot de Oliveira (8):
rtla: Add -C cgroup support
rtla: Add --house-keeping option
rtla: Change monitored_cpus from char * to cpu_set_t
rtla: Automatically move rtla to a house-keeping cpu
rtla/timerlat: Give timerlat auto analysis its own instance
rtla/timerlat_hist: Add auto-analysis support
rtla: Start the tracers after creating all instances
rtla/hwnoise: Reduce runtime to 75%

Documentation/tools/rtla/common_options.rst | 8 +
.../tools/rtla/common_timerlat_aa.rst | 7 -
.../tools/rtla/rtla-timerlat-hist.rst | 7 +-
.../tools/rtla/rtla-timerlat-top.rst | 7 +
tools/tracing/rtla/src/osnoise_hist.c | 90 +++++-
tools/tracing/rtla/src/osnoise_top.c | 83 +++++-
tools/tracing/rtla/src/timerlat_aa.c | 35 ++-
tools/tracing/rtla/src/timerlat_aa.h | 5 +-
tools/tracing/rtla/src/timerlat_hist.c | 139 +++++++--
tools/tracing/rtla/src/timerlat_top.c | 127 +++++++--
tools/tracing/rtla/src/utils.c | 266 ++++++++++++++++--
tools/tracing/rtla/src/utils.h | 5 +
12 files changed, 684 insertions(+), 95 deletions(-)

--
2.38.1



Subject: [PATCH 6/8] rtla/timerlat_hist: Add auto-analysis support

Add auto-analysis to timerlat hist, including the --no-aa option to
reduce overhead and --dump-task. --aa-only was not added as it is
already on timerlat top.

Cc: Steven Rostedt <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
---
.../tools/rtla/common_timerlat_aa.rst | 7 ---
.../tools/rtla/rtla-timerlat-hist.rst | 7 ++-
.../tools/rtla/rtla-timerlat-top.rst | 7 +++
tools/tracing/rtla/src/timerlat_hist.c | 51 ++++++++++++++++++-
4 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/Documentation/tools/rtla/common_timerlat_aa.rst b/Documentation/tools/rtla/common_timerlat_aa.rst
index 795b9fbcbc6d..077029e6b289 100644
--- a/Documentation/tools/rtla/common_timerlat_aa.rst
+++ b/Documentation/tools/rtla/common_timerlat_aa.rst
@@ -5,10 +5,3 @@
**--no-aa**

disable auto-analysis, reducing rtla timerlat cpu usage
-
-**--aa-only** *us*
-
- Set stop tracing conditions and run without collecting and displaying statistics.
- Print the auto-analysis if the system hits the stop tracing condition. This option
- is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
- collecting the statistics.
diff --git a/Documentation/tools/rtla/rtla-timerlat-hist.rst b/Documentation/tools/rtla/rtla-timerlat-hist.rst
index 6bf7f0ca4556..7046c428f2e1 100644
--- a/Documentation/tools/rtla/rtla-timerlat-hist.rst
+++ b/Documentation/tools/rtla/rtla-timerlat-hist.rst
@@ -29,15 +29,18 @@ OPTIONS

.. include:: common_options.rst

+.. include:: common_timerlat_aa.rst
+
EXAMPLE
=======
In the example below, **rtla timerlat hist** is set to run for *10* minutes,
in the cpus *0-4*, *skipping zero* only lines. Moreover, **rtla timerlat
hist** will change the priority of the *timerlat* threads to run under
*SCHED_DEADLINE* priority, with a *10us* runtime every *1ms* period. The
-*1ms* period is also passed to the *timerlat* tracer::
+*1ms* period is also passed to the *timerlat* tracer. Auto-analysis is disabled
+to reduce overhead ::

- [root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms
+ [root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms --no-aa
# RTLA timerlat histogram
# Time unit is microseconds (us)
# Duration: 0 00:10:00
diff --git a/Documentation/tools/rtla/rtla-timerlat-top.rst b/Documentation/tools/rtla/rtla-timerlat-top.rst
index 73799c1150ad..1b7cf4e3eafe 100644
--- a/Documentation/tools/rtla/rtla-timerlat-top.rst
+++ b/Documentation/tools/rtla/rtla-timerlat-top.rst
@@ -32,6 +32,13 @@ OPTIONS

.. include:: common_timerlat_aa.rst

+**--aa-only** *us*
+
+ Set stop tracing conditions and run without collecting and displaying statistics.
+ Print the auto-analysis if the system hits the stop tracing condition. This option
+ is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
+ collecting the statistics.
+
EXAMPLE
=======

diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 1675d54cae81..e720c8908906 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -16,6 +16,7 @@
#include "utils.h"
#include "osnoise.h"
#include "timerlat.h"
+#include "timerlat_aa.h"

struct timerlat_hist_params {
char *cpus;
@@ -34,6 +35,8 @@ struct timerlat_hist_params {
int dma_latency;
int cgroup;
int hk_cpus;
+ int no_aa;
+ int dump_tasks;
cpu_set_t hk_cpu_set;
struct sched_attr sched_param;
struct trace_events *events;
@@ -438,7 +441,7 @@ static void timerlat_hist_usage(char *usage)
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
" [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
- " [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]]",
+ " [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task]",
"",
" -h/--help: print this menu",
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
@@ -450,12 +453,14 @@ static void timerlat_hist_usage(char *usage)
" -H/--house-keeping cpus: run rtla control threads only on the given cpus",
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
" -d/--duration time[m|h|d]: duration of the session in seconds",
+ " --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)",
" -D/--debug: print debug info",
" -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]",
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
" --filter <filter>: enable a trace event filter to the previous -e event",
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
" -n/--nano: display data in nanoseconds",
+ " --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage",
" -b/--bucket-size N: set the histogram bucket size (default 1)",
" -E/--entries N: set the number of entries of the histogram (default 256)",
" --no-irq: ignore IRQ latencies",
@@ -537,13 +542,15 @@ static struct timerlat_hist_params
{"trigger", required_argument, 0, '6'},
{"filter", required_argument, 0, '7'},
{"dma-latency", required_argument, 0, '8'},
+ {"no-aa", no_argument, 0, '9'},
+ {"dump-task", no_argument, 0, '\1'},
{0, 0, 0, 0}
};

/* getopt_long stores the option index here. */
int option_index = 0;

- c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:0123456:7:8:",
+ c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:0123456:7:8:9\1",
long_options, &option_index);

/* detect the end of the options. */
@@ -556,6 +563,7 @@ static struct timerlat_hist_params

/* set thread stop to auto_thresh */
params->stop_total_us = auto_thresh;
+ params->stop_us = auto_thresh;

/* get stack trace */
params->print_stack = auto_thresh;
@@ -699,6 +707,12 @@ static struct timerlat_hist_params
exit(EXIT_FAILURE);
}
break;
+ case '9':
+ params->no_aa = 1;
+ break;
+ case '\1':
+ params->dump_tasks = 1;
+ break;
default:
timerlat_hist_usage("Invalid option");
}
@@ -715,6 +729,12 @@ static struct timerlat_hist_params
if (params->no_index && !params->with_zeros)
timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense");

+ /*
+ * Auto analysis only happens if stop tracing, thus:
+ */
+ if (!params->stop_us && !params->stop_total_us)
+ params->no_aa = 1;
+
return params;
}

@@ -848,6 +868,7 @@ int timerlat_hist_main(int argc, char *argv[])
struct timerlat_hist_params *params;
struct osnoise_tool *record = NULL;
struct osnoise_tool *tool = NULL;
+ struct osnoise_tool *aa = NULL;
struct trace_instance *trace;
int dma_latency_fd = -1;
int return_value = 1;
@@ -919,6 +940,26 @@ int timerlat_hist_main(int argc, char *argv[])
trace_instance_start(&record->trace);
}

+ if (!params->no_aa) {
+ aa = osnoise_init_tool("timerlat_aa");
+ if (!aa)
+ goto out_hist;
+
+ retval = timerlat_aa_init(aa, params->dump_tasks);
+ if (retval) {
+ err_msg("Failed to enable the auto analysis instance\n");
+ goto out_hist;
+ }
+
+ retval = enable_timerlat(&aa->trace);
+ if (retval) {
+ err_msg("Failed to enable timerlat tracer\n");
+ goto out_hist;
+ }
+
+ trace_instance_start(&aa->trace);
+ }
+
tool->start_time = time(NULL);
timerlat_hist_set_signals(params);

@@ -946,6 +987,10 @@ int timerlat_hist_main(int argc, char *argv[])

if (trace_is_off(&tool->trace, &record->trace)) {
printf("rtla timerlat hit stop tracing\n");
+
+ if (!params->no_aa)
+ timerlat_auto_analysis(params->stop_us, params->stop_total_us);
+
if (params->trace_output) {
printf(" Saving trace to %s\n", params->trace_output);
save_trace_to_file(record->trace.inst, params->trace_output);
@@ -953,12 +998,14 @@ int timerlat_hist_main(int argc, char *argv[])
}

out_hist:
+ timerlat_aa_destroy();
if (dma_latency_fd >= 0)
close(dma_latency_fd);
trace_events_destroy(&record->trace, params->events);
params->events = NULL;
out_free:
timerlat_free_histogram(tool->data);
+ osnoise_destroy_tool(aa);
osnoise_destroy_tool(record);
osnoise_destroy_tool(tool);
free(params);
--
2.38.1


Subject: [PATCH 7/8] rtla: Start the tracers after creating all instances

Group all start tracing after finishing creating all instances.

The tracing instance starts first for the case of hitting a stop
tracing while enabling other instances. The trace instance is the
one with most valuable information.

Cc: Steven Rostedt <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
---
tools/tracing/rtla/src/osnoise_hist.c | 14 +++++++++++---
tools/tracing/rtla/src/osnoise_top.c | 13 ++++++++++---
tools/tracing/rtla/src/timerlat_hist.c | 17 ++++++++++++-----
tools/tracing/rtla/src/timerlat_top.c | 19 +++++++++++++------
4 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index dfbcb5ca7ecb..8f81fa007364 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -870,8 +870,6 @@ int osnoise_hist_main(int argc, char *argv[])
}
}

- trace_instance_start(trace);
-
if (params->trace_output) {
record = osnoise_init_trace_tool("osnoise");
if (!record) {
@@ -885,9 +883,19 @@ int osnoise_hist_main(int argc, char *argv[])
goto out_hist;
}

- trace_instance_start(&record->trace);
}

+ /*
+ * Start the tracer here, after having set all instances.
+ *
+ * Let the trace instance start first for the case of hitting a stop
+ * tracing while enabling other instances. The trace instance is the
+ * one with most valuable information.
+ */
+ if (params->trace_output)
+ trace_instance_start(&record->trace);
+ trace_instance_start(trace);
+
tool->start_time = time(NULL);
osnoise_hist_set_signals(params);

diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 0833537bb2eb..85abba568faf 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -697,8 +697,6 @@ int osnoise_top_main(int argc, char **argv)
}
}

- trace_instance_start(trace);
-
if (params->trace_output) {
record = osnoise_init_trace_tool("osnoise");
if (!record) {
@@ -711,9 +709,18 @@ int osnoise_top_main(int argc, char **argv)
if (retval)
goto out_top;
}
+ }

+ /*
+ * Start the tracer here, after having set all instances.
+ *
+ * Let the trace instance start first for the case of hitting a stop
+ * tracing while enabling other instances. The trace instance is the
+ * one with most valuable information.
+ */
+ if (params->trace_output)
trace_instance_start(&record->trace);
- }
+ trace_instance_start(trace);

tool->start_time = time(NULL);
osnoise_top_set_signals(params);
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index e720c8908906..f431cf43246c 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -922,8 +922,6 @@ int timerlat_hist_main(int argc, char *argv[])
}
}

- trace_instance_start(trace);
-
if (params->trace_output) {
record = osnoise_init_trace_tool("timerlat");
if (!record) {
@@ -936,8 +934,6 @@ int timerlat_hist_main(int argc, char *argv[])
if (retval)
goto out_hist;
}
-
- trace_instance_start(&record->trace);
}

if (!params->no_aa) {
@@ -956,9 +952,20 @@ int timerlat_hist_main(int argc, char *argv[])
err_msg("Failed to enable timerlat tracer\n");
goto out_hist;
}
+ }

+ /*
+ * Start the tracers here, after having set all instances.
+ *
+ * Let the trace instance start first for the case of hitting a stop
+ * tracing while enabling other instances. The trace instance is the
+ * one with most valuable information.
+ */
+ if (params->trace_output)
+ trace_instance_start(&record->trace);
+ if (!params->no_aa)
trace_instance_start(&aa->trace);
- }
+ trace_instance_start(trace);

tool->start_time = time(NULL);
timerlat_hist_set_signals(params);
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index d6b5a382569e..02cff4948981 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -743,8 +743,6 @@ int timerlat_top_main(int argc, char *argv[])
}
}

- trace_instance_start(trace);
-
if (params->trace_output) {
record = osnoise_init_trace_tool("timerlat");
if (!record) {
@@ -757,8 +755,6 @@ int timerlat_top_main(int argc, char *argv[])
if (retval)
goto out_top;
}
-
- trace_instance_start(&record->trace);
}

if (!params->no_aa) {
@@ -785,11 +781,22 @@ int timerlat_top_main(int argc, char *argv[])
err_msg("Failed to enable timerlat tracer\n");
goto out_top;
}
-
- trace_instance_start(&aa->trace);
}
}

+ /*
+ * Start the tracers here, after having set all instances.
+ *
+ * Let the trace instance start first for the case of hitting a stop
+ * tracing while enabling other instances. The trace instance is the
+ * one with most valuable information.
+ */
+ if (params->trace_output)
+ trace_instance_start(&record->trace);
+ if (!params->no_aa && aa != top)
+ trace_instance_start(&aa->trace);
+ trace_instance_start(trace);
+
top->start_time = time(NULL);
timerlat_top_set_signals(params);

--
2.38.1


Subject: [PATCH 4/8] rtla: Automatically move rtla to a house-keeping cpu

When the user sets -c <cpu-list> try to move rtla out of the <cpu-list>,
even without an -H option. This is useful to avoid having rtla
interfering with the workload.

This works by removing <cpu-list> from rtla's current affinity.

If rtla fails to move itself away it is not that of a problem as this
is an automatic measure.

Cc: Steven Rostedt <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
---
tools/tracing/rtla/src/osnoise_hist.c | 9 +++++
tools/tracing/rtla/src/osnoise_top.c | 9 +++++
tools/tracing/rtla/src/timerlat_hist.c | 9 +++++
tools/tracing/rtla/src/timerlat_top.c | 9 +++++
tools/tracing/rtla/src/utils.c | 50 ++++++++++++++++++++++++++
tools/tracing/rtla/src/utils.h | 1 +
6 files changed, 87 insertions(+)

diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index b616a72d5c0a..dfbcb5ca7ecb 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -753,6 +753,15 @@ osnoise_hist_apply_config(struct osnoise_tool *tool, struct osnoise_hist_params
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;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 0e2f3b216d34..0833537bb2eb 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -582,6 +582,15 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
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;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 00287e96f22e..1675d54cae81 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -776,6 +776,15 @@ timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_hist_param
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;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 920f2f6ef842..f0c6d9735e2a 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -619,6 +619,15 @@ timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params *
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;
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index 8f9ad8f01e0f..3e25f0277fb9 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -709,3 +709,53 @@ int set_comm_cgroup(const char *comm_prefix, const char *cgroup)
close(cg_fd);
return 0;
}
+
+/**
+ * auto_house_keeping - Automatically move rtla out of measurement threads
+ *
+ * Try to move rtla away from the tracer, if possible.
+ *
+ * Returns 1 on success, 0 otherwise.
+ */
+int auto_house_keeping(cpu_set_t *monitored_cpus)
+{
+ cpu_set_t rtla_cpus, house_keeping_cpus;
+ int retval;
+
+ /* first get the CPUs in which rtla can actually run. */
+ retval = sched_getaffinity(getpid(), sizeof(rtla_cpus), &rtla_cpus);
+ if (retval == -1) {
+ debug_msg("Could not get rtla affinity, rtla might run with the threads!\n");
+ return 0;
+ }
+
+ /* then check if the existing setup is already good. */
+ CPU_AND(&house_keeping_cpus, &rtla_cpus, monitored_cpus);
+ if (!CPU_COUNT(&house_keeping_cpus)) {
+ debug_msg("rtla and the monitored CPUs do not share CPUs.");
+ debug_msg("Skipping auto house-keeping\n");
+ return 1;
+ }
+
+ /* remove the intersection */
+ CPU_XOR(&house_keeping_cpus, &rtla_cpus, monitored_cpus);
+
+ /* get only those that rtla can run */
+ CPU_AND(&house_keeping_cpus, &house_keeping_cpus, &rtla_cpus);
+
+ /* is there any cpu left? */
+ if (!CPU_COUNT(&house_keeping_cpus)) {
+ debug_msg("Could not find any CPU for auto house-keeping\n");
+ return 0;
+ }
+
+ retval = sched_setaffinity(getpid(), sizeof(house_keeping_cpus), &house_keeping_cpus);
+ if (retval == -1) {
+ debug_msg("Could not set affinity for auto house-keeping\n");
+ return 0;
+ }
+
+ debug_msg("rtla automatically moved to an auto house-keeping cpu set\n");
+
+ return 1;
+}
diff --git a/tools/tracing/rtla/src/utils.h b/tools/tracing/rtla/src/utils.h
index 9ab2f0d7bc1c..dec59163cfbc 100644
--- a/tools/tracing/rtla/src/utils.h
+++ b/tools/tracing/rtla/src/utils.h
@@ -60,6 +60,7 @@ int parse_cpu_set(char *cpu_list, cpu_set_t *set);
int set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);
int set_comm_cgroup(const char *comm_prefix, const char *cgroup);
int set_cpu_dma_latency(int32_t latency);
+int auto_house_keeping(cpu_set_t *monitored_cpus);

#define ns_to_usf(x) (((double)x/1000))
#define ns_to_per(total, part) ((part * 100) / (double)total)
--
2.38.1


Subject: 0001-rtla-Add-C-cgroup-support.patch

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 1/8] rtla: Add -C cgroup support
Date: Thu, 11 May 2023 20:02:53 +0200
Message-Id: <df9ab6da3d389ebc4e5049fd84079e801974a397.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Juri Lelli <[email protected]> from line 'Suggested-by: Juri Lelli <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 2/8] rtla: Add --house-keeping option
Date: Thu, 11 May 2023 20:02:54 +0200
Message-Id: <9d24752f2af0cb5b6fe9893f236b576cedf31b62.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 3/8] rtla: Change monitored_cpus from char * to cpu_set_t
Date: Thu, 11 May 2023 20:02:55 +0200
Message-Id: <0b2e708c5951e5e3016b0a3838960066cfcea19d.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 4/8] rtla: Automatically move rtla to a house-keeping cpu
Date: Thu, 11 May 2023 20:02:56 +0200
Message-Id: <ebe5dbd39620bfae91eb95fe6c69f766334c6381.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 5/8] rtla/timerlat: Give timerlat auto-analysis its own instance
Date: Thu, 11 May 2023 20:02:57 +0200
Message-Id: <dc2fa88f7c8c6103db986122baa496c944571d02.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 6/8] rtla/timerlat_hist: Add auto-analysis support
Date: Thu, 11 May 2023 20:02:58 +0200
Message-Id: <09d6bbc8642fa930cdfc9fa003a0546f9106261d.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 7/8] rtla: Start the tracers after creating all instances
Date: Thu, 11 May 2023 20:02:59 +0200
Message-Id: <26d837baec9e9e261a1352fba6ffe9be8967ba25.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK
(mbox) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'From: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Steven Rostedt <[email protected]> from line 'Cc: Steven Rostedt <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Cc: Daniel Bristot de Oliveira <[email protected]>'
(body) Adding cc: Masami Hiramatsu <[email protected]> from line 'Cc: Masami Hiramatsu <[email protected]>'
(body) Adding cc: Jonathan Corbet <[email protected]> from line 'Cc: Jonathan Corbet <[email protected]>'
(body) Adding cc: Daniel Bristot de Oliveira <[email protected]> from line 'Signed-off-by: Daniel Bristot de Oliveira <[email protected]>'
Dry-OK. Log says:
Server: mail.kernel.org
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
From: Daniel Bristot de Oliveira <[email protected]>
To: [email protected],
Steven Rostedt <[email protected]>
Cc: [email protected],
[email protected],
Juri Lelli <[email protected]>,
William White <[email protected]>,
Daniel Bristot de Oliveira <[email protected]>,
Masami Hiramatsu <[email protected]>,
Jonathan Corbet <[email protected]>
Subject: [PATCH 8/8] rtla/hwnoise: Reduce runtime to 75%
Date: Thu, 11 May 2023 20:03:00 +0200
Message-Id: <09fd28d1be7a5f3e01da1c2c007cf56790635f39.1683827510.git.bristot@kernel.org>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <[email protected]>
References: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: OK

Subject: Re: 0001-rtla-Add-C-cgroup-support.patch

ok, today is one of those days... Ignore this email, it is the log --dry-run I tried before.

I need to automate this final checks :-)

-- Daniel

Subject: [PATCH 3/8] rtla: Change monitored_cpus from char * to cpu_set_t

Use a cpumask instead of a char *, reducing memory footprint and code.

No functional change, and in preparation for auto house-keeping.

Cc: Steven Rostedt <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
---
tools/tracing/rtla/src/osnoise_hist.c | 18 ++++----
tools/tracing/rtla/src/osnoise_top.c | 6 +--
tools/tracing/rtla/src/timerlat_hist.c | 18 ++++----
tools/tracing/rtla/src/timerlat_top.c | 6 +--
tools/tracing/rtla/src/utils.c | 63 --------------------------
5 files changed, 24 insertions(+), 87 deletions(-)

diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index d2b68177ffac..b616a72d5c0a 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -19,7 +19,7 @@

struct osnoise_hist_params {
char *cpus;
- char *monitored_cpus;
+ cpu_set_t monitored_cpus;
char *trace_output;
char *cgroup_name;
unsigned long long runtime;
@@ -274,7 +274,7 @@ static void osnoise_hist_header(struct osnoise_tool *tool)
trace_seq_printf(s, "Index");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -305,7 +305,7 @@ osnoise_print_summary(struct osnoise_hist_params *params,
trace_seq_printf(trace->seq, "count:");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -319,7 +319,7 @@ osnoise_print_summary(struct osnoise_hist_params *params,
trace_seq_printf(trace->seq, "min: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -334,7 +334,7 @@ osnoise_print_summary(struct osnoise_hist_params *params,
trace_seq_printf(trace->seq, "avg: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -352,7 +352,7 @@ osnoise_print_summary(struct osnoise_hist_params *params,
trace_seq_printf(trace->seq, "max: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -387,7 +387,7 @@ osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *too
bucket * data->bucket_size);

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -411,7 +411,7 @@ osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *too
trace_seq_printf(trace->seq, "over: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].count)
@@ -559,7 +559,7 @@ static struct osnoise_hist_params
osnoise_hist_usage("Bucket size needs to be > 0 and <= 1000000\n");
break;
case 'c':
- retval = parse_cpu_list(optarg, &params->monitored_cpus);
+ retval = parse_cpu_set(optarg, &params->monitored_cpus);
if (retval)
osnoise_hist_usage("\nInvalid -c cpu list\n");
params->cpus = optarg;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index fcf6c14ce1bc..0e2f3b216d34 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -26,7 +26,7 @@ enum osnoise_mode {
*/
struct osnoise_top_params {
char *cpus;
- char *monitored_cpus;
+ cpu_set_t monitored_cpus;
char *trace_output;
char *cgroup_name;
unsigned long long runtime;
@@ -263,7 +263,7 @@ osnoise_print_stats(struct osnoise_top_params *params, struct osnoise_tool *top)
osnoise_top_header(top);

for (i = 0; i < nr_cpus; i++) {
- if (params->cpus && !params->monitored_cpus[i])
+ if (params->cpus && !CPU_ISSET(i, &params->monitored_cpus))
continue;
osnoise_top_print(top, i);
}
@@ -397,7 +397,7 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)

break;
case 'c':
- retval = parse_cpu_list(optarg, &params->monitored_cpus);
+ retval = parse_cpu_set(optarg, &params->monitored_cpus);
if (retval)
osnoise_top_usage(params, "\nInvalid -c cpu list\n");
params->cpus = optarg;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index d48c05d238f9..00287e96f22e 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -19,7 +19,7 @@

struct timerlat_hist_params {
char *cpus;
- char *monitored_cpus;
+ cpu_set_t monitored_cpus;
char *trace_output;
char *cgroup_name;
unsigned long long runtime;
@@ -227,7 +227,7 @@ static void timerlat_hist_header(struct osnoise_tool *tool)
trace_seq_printf(s, "Index");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -263,7 +263,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
trace_seq_printf(trace->seq, "count:");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -283,7 +283,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
trace_seq_printf(trace->seq, "min: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -303,7 +303,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
trace_seq_printf(trace->seq, "avg: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -331,7 +331,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
trace_seq_printf(trace->seq, "max: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -371,7 +371,7 @@ timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *t
bucket * data->bucket_size);

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -405,7 +405,7 @@ timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *t
trace_seq_printf(trace->seq, "over: ");

for (cpu = 0; cpu < data->nr_cpus; cpu++) {
- if (params->cpus && !params->monitored_cpus[cpu])
+ if (params->cpus && !CPU_ISSET(cpu, &params->monitored_cpus))
continue;

if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
@@ -565,7 +565,7 @@ static struct timerlat_hist_params

break;
case 'c':
- retval = parse_cpu_list(optarg, &params->monitored_cpus);
+ retval = parse_cpu_set(optarg, &params->monitored_cpus);
if (retval)
timerlat_hist_usage("\nInvalid -c cpu list\n");
params->cpus = optarg;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 5395d1c5921e..920f2f6ef842 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -21,7 +21,7 @@

struct timerlat_top_params {
char *cpus;
- char *monitored_cpus;
+ cpu_set_t monitored_cpus;
char *trace_output;
char *cgroup_name;
unsigned long long runtime;
@@ -271,7 +271,7 @@ timerlat_print_stats(struct timerlat_top_params *params, struct osnoise_tool *to
timerlat_top_header(top);

for (i = 0; i < nr_cpus; i++) {
- if (params->cpus && !params->monitored_cpus[i])
+ if (params->cpus && !CPU_ISSET(i, &params->monitored_cpus))
continue;
timerlat_top_print(top, i);
}
@@ -422,7 +422,7 @@ static struct timerlat_top_params
params->aa_only = 1;
break;
case 'c':
- retval = parse_cpu_list(optarg, &params->monitored_cpus);
+ retval = parse_cpu_set(optarg, &params->monitored_cpus);
if (retval)
timerlat_top_usage("\nInvalid -c cpu list\n");
params->cpus = optarg;
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index ee6fab09acae..8f9ad8f01e0f 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -88,69 +88,6 @@ void get_duration(time_t start_time, char *output, int output_size)
tm_info->tm_sec);
}

-/*
- * parse_cpu_list - parse a cpu_list filling a char vector with cpus set
- *
- * Receives a cpu list, like 1-3,5 (cpus 1, 2, 3, 5), and then set the char
- * in the monitored_cpus.
- *
- * XXX: convert to a bitmask.
- */
-int parse_cpu_list(char *cpu_list, char **monitored_cpus)
-{
- char *mon_cpus;
- const char *p;
- int end_cpu;
- int nr_cpus;
- int cpu;
- int i;
-
- nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
-
- mon_cpus = calloc(nr_cpus, sizeof(char));
- if (!mon_cpus)
- goto err;
-
- for (p = cpu_list; *p; ) {
- cpu = atoi(p);
- if (cpu < 0 || (!cpu && *p != '0') || cpu >= nr_cpus)
- goto err;
-
- while (isdigit(*p))
- p++;
- if (*p == '-') {
- p++;
- end_cpu = atoi(p);
- if (end_cpu < cpu || (!end_cpu && *p != '0') || end_cpu >= nr_cpus)
- goto err;
- while (isdigit(*p))
- p++;
- } else
- end_cpu = cpu;
-
- if (cpu == end_cpu) {
- debug_msg("cpu_list: adding cpu %d\n", cpu);
- mon_cpus[cpu] = 1;
- } else {
- for (i = cpu; i <= end_cpu; i++) {
- debug_msg("cpu_list: adding cpu %d\n", i);
- mon_cpus[i] = 1;
- }
- }
-
- if (*p == ',')
- p++;
- }
-
- *monitored_cpus = mon_cpus;
-
- return 0;
-
-err:
- debug_msg("Error parsing the cpu list %s", cpu_list);
- return 1;
-}
-
/*
* parse_cpu_set - parse a cpu_list filling cpu_set_t argument
*
--
2.38.1


Subject: [PATCH 8/8] rtla/hwnoise: Reduce runtime to 75%

osnoise runs 100% of time by default. It makes sense because osnoise
is preemptive. hwnoise checks preemption once a second, so it
reduces system progress.

Reduce runtime to 75% to avoid problems by default. I added a Fixes
as it might avoid problems for first time users as it lands on distros.

Cc: Steven Rostedt <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Fixes: 1f428356c38d ("rtla: Add hwnoise tool")
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
---
tools/tracing/rtla/src/osnoise_top.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 85abba568faf..f7c959be8677 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -348,8 +348,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
if (!params)
exit(1);

- if (strcmp(argv[0], "hwnoise") == 0)
+ if (strcmp(argv[0], "hwnoise") == 0) {
params->mode = MODE_HWNOISE;
+ /*
+ * Reduce CPU usage for 75% to avoid killing the system.
+ */
+ params->runtime = 750000;
+ params->period = 1000000;
+ }

while (1) {
static struct option long_options[] = {
--
2.38.1