Skip to content

Commit 3006adf

Browse files
committed
Merge tag 'rtla-v6.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bristot/linux
Pull rtla fixes from Daniel Bristot de Oliveira: "rtla (Real-Time Linux Analysis) tool fixes. Timerlat auto-analysis: - Timerlat is reporting thread interference time without thread noise events occurrence. It was caused because the thread interference variable was not reset after the analysis of a timerlat activation that did not hit the threshold. - The IRQ handler delay is estimated from the delta of the IRQ latency reported by timerlat, and the timestamp from IRQ handler start event. If the delta is near-zero, the drift from the external clock and the trace event and/or the overhead can cause the value to be negative. If the value is negative, print a zero-delay. - IRQ handlers happening after the timerlat thread event but before the stop tracing were being reported as IRQ that happened before the *current* IRQ occurrence. Ignore Previous IRQ noise in this condition because they are valid only for the *next* timerlat activation. Timerlat user-space: - Timerlat is stopping all user-space thread if a CPU becomes offline. Do not stop the entire tool if a CPU is/become offline, but only the thread of the unavailable CPU. Stop the tool only, if all threads leave because the CPUs become/are offline. man-pages: - Fix command line example in timerlat hist man page" * tag 'rtla-v6.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bristot/linux: rtla: fix a example in rtla-timerlat-hist.rst rtla/timerlat: Do not stop user-space if a cpu is offline rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample rtla/timerlat_aa: Fix negative IRQ delay rtla/timerlat_aa: Zero thread sum after every sample analysis
2 parents ba7d997 + 81ec384 commit 3006adf

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

Documentation/tools/rtla/rtla-timerlat-hist.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ EXAMPLE
3636
In the example below, **rtla timerlat hist** is set to run for *10* minutes,
3737
in the cpus *0-4*, *skipping zero* only lines. Moreover, **rtla timerlat
3838
hist** will change the priority of the *timerlat* threads to run under
39-
*SCHED_DEADLINE* priority, with a *10us* runtime every *1ms* period. The
39+
*SCHED_DEADLINE* priority, with a *100us* runtime every *1ms* period. The
4040
*1ms* period is also passed to the *timerlat* tracer. Auto-analysis is disabled
4141
to reduce overhead ::
4242

43-
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms --no-aa
43+
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1000 --no-aa
4444
# RTLA timerlat histogram
4545
# Time unit is microseconds (us)
4646
# Duration: 0 00:10:00

tools/tracing/rtla/src/timerlat_aa.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static int timerlat_aa_irq_latency(struct timerlat_aa_data *taa_data,
159159
taa_data->thread_nmi_sum = 0;
160160
taa_data->thread_irq_sum = 0;
161161
taa_data->thread_softirq_sum = 0;
162+
taa_data->thread_thread_sum = 0;
162163
taa_data->thread_blocking_duration = 0;
163164
taa_data->timer_irq_start_time = 0;
164165
taa_data->timer_irq_duration = 0;
@@ -337,7 +338,23 @@ static int timerlat_aa_irq_handler(struct trace_seq *s, struct tep_record *recor
337338
taa_data->timer_irq_start_time = start;
338339
taa_data->timer_irq_duration = duration;
339340

340-
taa_data->timer_irq_start_delay = taa_data->timer_irq_start_time - expected_start;
341+
/*
342+
* We are dealing with two different clock sources: the
343+
* external clock source that timerlat uses as a reference
344+
* and the clock used by the tracer. There are also two
345+
* moments: the time reading the clock and the timer in
346+
* which the event is placed in the buffer (the trace
347+
* event timestamp). If the processor is slow or there
348+
* is some hardware noise, the difference between the
349+
* timestamp and the external clock read can be longer
350+
* than the IRQ handler delay, resulting in a negative
351+
* time. If so, set IRQ start delay as 0. In the end,
352+
* it is less relevant than the noise.
353+
*/
354+
if (expected_start < taa_data->timer_irq_start_time)
355+
taa_data->timer_irq_start_delay = taa_data->timer_irq_start_time - expected_start;
356+
else
357+
taa_data->timer_irq_start_delay = 0;
341358

342359
/*
343360
* not exit from idle.
@@ -528,7 +545,7 @@ static int timerlat_aa_kworker_start_handler(struct trace_seq *s, struct tep_rec
528545
static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
529546
int irq_thresh, int thread_thresh)
530547
{
531-
unsigned long long exp_irq_ts;
548+
long long exp_irq_ts;
532549
int total;
533550
int irq;
534551

@@ -545,12 +562,15 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
545562

546563
/*
547564
* Expected IRQ arrival time using the trace clock as the base.
565+
*
566+
* TODO: Add a list of previous IRQ, and then run the list backwards.
548567
*/
549568
exp_irq_ts = taa_data->timer_irq_start_time - taa_data->timer_irq_start_delay;
550-
551-
if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration)
552-
printf(" Previous IRQ interference: \t\t up to %9.2f us\n",
553-
ns_to_usf(taa_data->prev_irq_duration));
569+
if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration) {
570+
if (taa_data->prev_irq_timstamp < taa_data->timer_irq_start_time)
571+
printf(" Previous IRQ interference: \t\t up to %9.2f us\n",
572+
ns_to_usf(taa_data->prev_irq_duration));
573+
}
554574

555575
/*
556576
* The delay that the IRQ suffered before starting.

tools/tracing/rtla/src/timerlat_u.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int timerlat_u_main(int cpu, struct timerlat_u_params *params)
4545

4646
retval = sched_setaffinity(gettid(), sizeof(set), &set);
4747
if (retval == -1) {
48-
err_msg("Error setting user thread affinity\n");
48+
debug_msg("Error setting user thread affinity %d, is the CPU online?\n", cpu);
4949
exit(1);
5050
}
5151

@@ -193,7 +193,9 @@ void *timerlat_u_dispatcher(void *data)
193193
procs_count--;
194194
}
195195
}
196-
break;
196+
197+
if (!procs_count)
198+
break;
197199
}
198200

199201
sleep(1);

0 commit comments

Comments
 (0)