rtla: Save trace when option `--trace` is specified
Subsystems (2)
PATCH 1/1 rtla: Save trace when option `--trace` is specified
Rtla saves trace output only when option --auto or --stop is specified. Single option --trace enables tracing, but doesn't save it.
Save trace output in any case.
--- tools/tracing/rtla/src/osnoise_hist.c | 9 ++++----- tools/tracing/rtla/src/osnoise_top.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-)
tools/tracing/rtla/src/osnoise_hist.c +4 -5
@@ -981,12 +981,11 @@ int osnoise_hist_main(int argc, char *argv[]) return_value =0 ; -if (osnoise_trace_is_off (tool, record)) { +if (osnoise_trace_is_off (tool, record))printf ("rtla osnoise hit stop tracing\n" ); -if (params->trace_output) { -printf (" Saving trace to %s\n" , params->trace_output); -save_trace_to_file (record->trace.inst, params->trace_output); - } +if (params->trace_output) { +printf (" Saving trace to %s\n" , params->trace_output); +save_trace_to_file (record->trace.inst, params->trace_output); } out_hist:
tools/tracing/rtla/src/osnoise_top.c +4 -5
@@ -811,12 +811,11 @@ int osnoise_top_main(int argc, char **argv) return_value =0 ; -if (osnoise_trace_is_off (tool, record)) { +if (osnoise_trace_is_off (tool, record))printf ("osnoise hit stop tracing\n" ); -if (params->trace_output) { -printf (" Saving trace to %s\n" , params->trace_output); -save_trace_to_file (record->trace.inst, params->trace_output); - } +if (params->trace_output) { +printf (" Saving trace to %s\n" , params->trace_output); +save_trace_to_file (record->trace.inst, params->trace_output); } out_top:
Signature · 1 line
2.47.0
Steven Rostedt
maintainerQuoted 6 lines · On Mon, 27 Jan 2025 19:02:40 +0200 Costa Shulyupin <[email protected]>…
+++
b/tools/tracing/rtla/src/osnoise_hist.ctools/tracing/rtla/src/osnoise_hist.c +0
-1@@ -981,12 +981,11 @@ int osnoise_hist_main(int argc, char *argv[]) return_value =0 ; -if (osnoise_trace_is_off (tool, record)) {
tools/tracing/rtla/src/osnoise_hist.c int osnoise_hist_main(int argc, char *argv[]) · line 989
Quoted 10 lines
tools/tracing/rtla/src/osnoise_hist.c +4
-4+if (osnoise_trace_is_off (tool, record))printf ("rtla osnoise hit stop tracing\n" ); -if (params->trace_output) { -printf (" Saving trace to %s\n" , params->trace_output); -save_trace_to_file (record->trace.inst, params->trace_output); - } +if (params->trace_output) { +printf (" Saving trace to %s\n" , params->trace_output); +save_trace_to_file (record->trace.inst, params->trace_output); }
Without tracing being off, this can run forever if the events come in faster than it can be recorded. And save trace uses the "trace" file, which is slow to read.
Are you sure you want that?
-- Steve
Tomas Glozar
maintainerpá 28. 2. 2025 v 2:05 odesílatel Steven Rostedt <[email protected]> napsal:
Quoted 7 lines
Without tracing being off, this can run forever if the events come in faster than it can be recorded. And save trace uses the "trace" file, which is slow to read.
Are you sure you want that?
Isn't that a different problem though? As far as I'm aware, it shouldn't matter at all whether tracing is stopped on the main instance for collecting the trace from the record instance.
If the record instance generates a lot of samples, this can already run forever, regardless of whether tracing is stopped on the main instance or not. This should be a separate fix.
Tomas
Actually trace collection can be performed using just trace-cmd start, trace-cmd stop, and trace-cmd extract.
Tomas Glozar
maintainerpo 3. 3. 2025 v 16:55 odesílatel Costa Shulyupin <[email protected]> napsal:
Quoted 4 lines
Actually trace collection can be performed using just trace-cmd start, trace-cmd stop, and trace-cmd extract.
Yes, but that does not necessarily mean we cannot add it to rtla, too; we already do that e.g. for event histograms, which you could also replace with trace-cmd. It has the benefit of synchronizing the start/stop of the trace collection with the osnoise/timerlat tracer.
Tomas
Steven Rostedt
maintainerQuoted 9 lines · On Mon, 3 Mar 2025 16:34:21 +0100 Tomas Glozar <[email protected]> wrote:
pá 28. 2. 2025 v 2:05 odesílatel Steven Rostedt <[email protected]> napsal:
Quoted 7 lines
Without tracing being off, this can run forever if the events come in faster than it can be recorded. And save trace uses the "trace" file, which is slow to read.
Are you sure you want that?
Quoted 7 lines
Isn't that a different problem though? As far as I'm aware, it shouldn't matter at all whether tracing is stopped on the main instance for collecting the trace from the record instance.
If the record instance generates a lot of samples, this can already run forever, regardless of whether tracing is stopped on the main instance or not. This should be a separate fix.
Not sure what you mean by "main instance"?
The code being changed is:
- if (osnoise_trace_is_off(tool, record)) {
+ if (osnoise_trace_is_off(tool, record))
printf("rtla osnoise hit stop tracing\n");
- if (params->trace_output) {
- printf(" Saving trace to %s\n", params->trace_output);
- save_trace_to_file(record->trace.inst, params->trace_output);
- }
+ if (params->trace_output) {
+ printf(" Saving trace to %s\n", params->trace_output);
+ save_trace_to_file(record->trace.inst, params->trace_output);
}
Where osnoise_trace_is_off() is:
bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *record)
{
/*
* The tool instance is always present, it is the one used to collect
* data.
*/
if (!tracefs_trace_is_on(tool->trace.inst))
return true;
/*
* The trace record instance is only enabled when -t is set. IOW, when the system
* is tracing.
*/
return record && !tracefs_trace_is_on(record->trace.inst);
}Which returns true if the tool->trace.inst is on and false otherwise.
-- Steve
Tomas Glozar
maintainerpo 3. 3. 2025 v 21:04 odesílatel Steven Rostedt <[email protected]> napsal:
Quoted 3 lines
Not sure what you mean by "main instance"?
By "main instance", I meant tool->trace.inst. My point was that record->trace.inst, which is a different instance, would be still on. But that's not the case, osnoise_stop_tracing() stops *all* osnoise instances, not just the first one - sorry, that was my mistake.
Quoted 5 lines
The code being changed is:
tools/tracing/rtla/src/osnoise_hist.c +0
-1-if (osnoise_trace_is_off (tool, record)) {
tools/tracing/rtla/src/osnoise_hist.c int osnoise_hist_main(int argc, char *argv[]) · line 989
Quoted 10 lines
tools/tracing/rtla/src/osnoise_hist.c +4
-4+if (osnoise_trace_is_off (tool, record))printf ("rtla osnoise hit stop tracing\n" ); -if (params->trace_output) { -printf (" Saving trace to %s\n" , params->trace_output); -save_trace_to_file (record->trace.inst, params->trace_output); - } +if (params->trace_output) { +printf (" Saving trace to %s\n" , params->trace_output); +save_trace_to_file (record->trace.inst, params->trace_output); }
So we need to stop tracing here, before we save the trace, if we want to do that. Perhaps combining this with the cleanup patch [1] and doing the stopping in save_trace_to_file would make sense?
[1] - https://lore.kernel.org/linux-trace-kernel/[email protected]/
Tomas
Tomas Glozar
maintainerút 4. 3. 2025 v 9:00 odesílatel Tomas Glozar <[email protected]> napsal:
Quoted 5 lines
So we need to stop tracing here, before we save the trace, if we want to do that. Perhaps combining this with the cleanup patch [1] and doing the stopping in
save_trace_to_filewould make sense?
Also, the patch will also save the trace if running with -a and the threshold was not violated, which is not what one usually wants, e.g.:
$ rtla osnoise top -c 0 -q -a 10000000 -d 5s
Operating System Noiseduration: 0 00:00:05 | time is in us
CPU Period Runtime Noise % CPU Aval Max Noise Max
Single HW NMI IRQ Softirq Threa
d
0 #4 4000000 37712 99.05720 10998
555 7624 0 4011 34 2
4
Saving trace to osnoise_trace.txt
I believe it would be better to add a new option, something like --force-trace, that would be used to save the trace even if there is no threshold violation. -t/--trace and -a could then be used with the same semantics as before.
Tomas
Steven Rostedt
maintainerQuoted 22 lines · On Tue, 4 Mar 2025 09:16:11 +0100 Tomas Glozar <[email protected]> wrote:
út 4. 3. 2025 v 9:00 odesílatel Tomas Glozar <[email protected]> napsal:
Quoted 5 lines
So we need to stop tracing here, before we save the trace, if we want to do that. Perhaps combining this with the cleanup patch [1] and doing the stopping in
save_trace_to_filewould make sense?Also, the patch will also save the trace if running with -a and the threshold was not violated, which is not what one usually wants, e.g.:
$ rtla osnoise top -c 0 -q -a 10000000 -d 5s Operating System Noiseduration: 0 00:00:05 | time is in us
CPU Period Runtime Noise % CPU Aval Max Noise Max
Single HW NMI IRQ Softirq Threa
d
0 #4 4000000 37712 99.05720 10998
555 7624 0 4011 34 2
4
Saving trace to osnoise_trace.txt
Quoted 4 lines
I believe it would be better to add a new option, something like --force-trace, that would be used to save the trace even if there is no threshold violation. -t/--trace and -a could then be used with the same semantics as before.
As long is this is what you expect to happen. I just wanted to point out that recording the trace while it is active means it may never stop recording. If that is OK, then I'm fine with the change.
-- Steve
Steven Rostedt
maintainerQuoted 25 lines · On Tue, 4 Mar 2025 12:10:53 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 22 lines · On Tue, 4 Mar 2025 09:16:11 +0100 Tomas Glozar <[email protected]> wrote:
út 4. 3. 2025 v 9:00 odesílatel Tomas Glozar <[email protected]> napsal:
Quoted 5 lines
So we need to stop tracing here, before we save the trace, if we want to do that. Perhaps combining this with the cleanup patch [1] and doing the stopping in
save_trace_to_filewould make sense?Also, the patch will also save the trace if running with -a and the threshold was not violated, which is not what one usually wants, e.g.:
$ rtla osnoise top -c 0 -q -a 10000000 -d 5s Operating System Noiseduration: 0 00:00:05 | time is in us
CPU Period Runtime Noise % CPU Aval Max Noise Max
Single HW NMI IRQ Softirq Threa
d
0 #4 4000000 37712 99.05720 10998
555 7624 0 4011 34 2
4
Saving trace to osnoise_trace.txt
Quoted 9 lines
Quoted 4 lines
I believe it would be better to add a new option, something like --force-trace, that would be used to save the trace even if there is no threshold violation. -t/--trace and -a could then be used with the same semantics as before.
As long is this is what you expect to happen. I just wanted to point out that recording the trace while it is active means it may never stop recording. If that is OK, then I'm fine with the change.
I just noticed that this patch was never applied. Is it still something to add?
-- Steve
Quoted 1 line · Steven Rostedt
I just noticed that this patch was never applied. Is it still something to add?
No, it’s no longer needed — we can drop it.
Costa