Skip to content

Commit 5ea8abf

Browse files
committed
Merge tag 'trace-tools-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing tools updates from Steven Rostedt: - Add auto-analysis only option to rtla/timerlat Add an --aa-only option to the tooling to perform only the auto analysis and not to parse and format the data. - Other minor fixes and clean ups * tag 'trace-tools-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rtla/timerlat: Fix "Previous IRQ" auto analysis' line rtla/timerlat: Add auto-analysis only option rv: Remove redundant assignment to variable retval rv: Fix addition on an uninitialized variable 'run' rtla: Add .gitignore file
2 parents d579c46 + 82253a2 commit 5ea8abf

6 files changed

Lines changed: 54 additions & 9 deletions

File tree

Documentation/tools/rtla/common_timerlat_aa.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@
55
**--no-aa**
66

77
disable auto-analysis, reducing rtla timerlat cpu usage
8+
9+
**--aa-only** *us*
10+
11+
Set stop tracing conditions and run without collecting and displaying statistics.
12+
Print the auto-analysis if the system hits the stop tracing condition. This option
13+
is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
14+
collecting the statistics.

kernel/trace/rv/rv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ static ssize_t monitor_enable_write_data(struct file *filp, const char __user *u
290290
if (retval)
291291
return retval;
292292

293-
retval = count;
294-
295293
mutex_lock(&rv_interface_lock);
296294

297295
if (val)

tools/tracing/rtla/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/rtla

tools/tracing/rtla/src/timerlat_aa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
548548
exp_irq_ts = taa_data->timer_irq_start_time - taa_data->timer_irq_start_delay;
549549

550550
if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration)
551-
printf(" Previous IRQ interference: \t up to %9.2f us",
551+
printf(" Previous IRQ interference: \t\t up to %9.2f us\n",
552552
ns_to_usf(taa_data->prev_irq_duration));
553553

554554
/*

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct timerlat_top_params {
3333
int set_sched;
3434
int dma_latency;
3535
int no_aa;
36+
int aa_only;
3637
int dump_tasks;
3738
struct sched_attr sched_param;
3839
struct trace_events *events;
@@ -142,10 +143,12 @@ timerlat_top_handler(struct trace_seq *s, struct tep_record *record,
142143
top = container_of(trace, struct osnoise_tool, trace);
143144
params = top->params;
144145

145-
tep_get_field_val(s, event, "context", record, &thread, 1);
146-
tep_get_field_val(s, event, "timer_latency", record, &latency, 1);
146+
if (!params->aa_only) {
147+
tep_get_field_val(s, event, "context", record, &thread, 1);
148+
tep_get_field_val(s, event, "timer_latency", record, &latency, 1);
147149

148-
timerlat_top_update(top, cpu, thread, latency);
150+
timerlat_top_update(top, cpu, thread, latency);
151+
}
149152

150153
if (!params->no_aa)
151154
timerlat_aa_handler(s, record, event, context);
@@ -250,6 +253,9 @@ timerlat_print_stats(struct timerlat_top_params *params, struct osnoise_tool *to
250253
static int nr_cpus = -1;
251254
int i;
252255

256+
if (params->aa_only)
257+
return;
258+
253259
if (nr_cpus == -1)
254260
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
255261

@@ -279,10 +285,11 @@ static void timerlat_top_usage(char *usage)
279285
"",
280286
" usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
281287
" [[-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] \\",
282-
" [-P priority] [--dma-latency us]",
288+
" [-P priority] [--dma-latency us] [--aa-only us]",
283289
"",
284290
" -h/--help: print this menu",
285291
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
292+
" --aa-only us: stop if <us> latency is hit, only printing the auto analysis (reduces CPU usage)",
286293
" -p/--period us: timerlat period in us",
287294
" -i/--irq us: stop trace if the irq latency is higher than the argument in us",
288295
" -T/--thread us: stop trace if the thread latency is higher than the argument in us",
@@ -362,13 +369,14 @@ static struct timerlat_top_params
362369
{"dma-latency", required_argument, 0, '2'},
363370
{"no-aa", no_argument, 0, '3'},
364371
{"dump-tasks", no_argument, 0, '4'},
372+
{"aa-only", required_argument, 0, '5'},
365373
{0, 0, 0, 0}
366374
};
367375

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

371-
c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:0:1:2:34",
379+
c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:0:1:2:345:",
372380
long_options, &option_index);
373381

374382
/* detect the end of the options. */
@@ -389,6 +397,20 @@ static struct timerlat_top_params
389397
/* set trace */
390398
params->trace_output = "timerlat_trace.txt";
391399
break;
400+
case '5':
401+
/* it is here because it is similar to -a */
402+
auto_thresh = get_llong_from_str(optarg);
403+
404+
/* set thread stop to auto_thresh */
405+
params->stop_total_us = auto_thresh;
406+
params->stop_us = auto_thresh;
407+
408+
/* get stack trace */
409+
params->print_stack = auto_thresh;
410+
411+
/* set aa_only to avoid parsing the trace */
412+
params->aa_only = 1;
413+
break;
392414
case 'c':
393415
retval = parse_cpu_list(optarg, &params->monitored_cpus);
394416
if (retval)
@@ -503,6 +525,9 @@ static struct timerlat_top_params
503525
if (!params->stop_us && !params->stop_total_us)
504526
params->no_aa = 1;
505527

528+
if (params->no_aa && params->aa_only)
529+
timerlat_top_usage("--no-aa and --aa-only are mutually exclusive!");
530+
506531
return params;
507532
}
508533

@@ -634,6 +659,7 @@ int timerlat_top_main(int argc, char *argv[])
634659
struct trace_instance *trace;
635660
int dma_latency_fd = -1;
636661
int return_value = 1;
662+
char *max_lat;
637663
int retval;
638664

639665
params = timerlat_top_parse_args(argc, argv);
@@ -700,6 +726,9 @@ int timerlat_top_main(int argc, char *argv[])
700726
while (!stop_tracing) {
701727
sleep(params->sleep_time);
702728

729+
if (params->aa_only && !trace_is_off(&top->trace, &record->trace))
730+
continue;
731+
703732
retval = tracefs_iterate_raw_events(trace->tep,
704733
trace->inst,
705734
NULL,
@@ -733,6 +762,16 @@ int timerlat_top_main(int argc, char *argv[])
733762
printf(" Saving trace to %s\n", params->trace_output);
734763
save_trace_to_file(record->trace.inst, params->trace_output);
735764
}
765+
} else if (params->aa_only) {
766+
/*
767+
* If the trace did not stop with --aa-only, at least print the
768+
* max known latency.
769+
*/
770+
max_lat = tracefs_instance_file_read(trace->inst, "tracing_max_latency", NULL);
771+
if (max_lat) {
772+
printf(" Max latency was %s\n", max_lat);
773+
free(max_lat);
774+
}
736775
}
737776

738777
out_top:

tools/verification/rv/src/rv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void rv_list(int argc, char **argv)
7474
static void rv_mon(int argc, char **argv)
7575
{
7676
char *monitor_name;
77-
int i, run;
77+
int i, run = 0;
7878

7979
static const char *const usage[] = {
8080
"",

0 commit comments

Comments
 (0)