Skip to content

Commit 6c73daf

Browse files
author
Daniel Bristot de Oliveira
committed
rtla/timerlat_aa: Fix negative IRQ delay
When estimating the IRQ timer delay, we are dealing with two different clock sources: the external clock source that timerlat uses as a reference and the clock used by the tracer. There are also two moments: the time reading the clock and the timer in which the event is placed in the buffer (the trace event timestamp). If the processor is slow or there is some hardware noise, the difference between the timestamp and the external clock, read can be longer than the IRQ handler delay, resulting in a negative time. If so, set IRQ to start delay as 0. In the end, it is less near-zero and relevant then the noise. Link: https://lore.kernel.org/lkml/a066fb667c7136d86dcddb3c7ccd72587db3e7c7.1691162043.git.bristot@kernel.org Fixes: 27e348b ("rtla/timerlat: Add auto-analysis core") Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
1 parent 02d8991 commit 6c73daf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tools/tracing/rtla/src/timerlat_aa.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,23 @@ static int timerlat_aa_irq_handler(struct trace_seq *s, struct tep_record *recor
338338
taa_data->timer_irq_start_time = start;
339339
taa_data->timer_irq_duration = duration;
340340

341-
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;
342358

343359
/*
344360
* not exit from idle.

0 commit comments

Comments
 (0)