* [PATCH 0/3] rtla fixes for 6.5
@ 2023-08-04 15:52 Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 1/3] rtla/timerlat_aa: Zero thread sum after every sample analysis Daniel Bristot de Oliveira
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2023-08-04 15:52 UTC (permalink / raw)
To: linux-kernel, linux-trace-devel, Steven Rostedt
Cc: William White, Daniel Bristot de Oliveira, Masami Hiramatsu
Here are some fixes for rtla timerlat auto-analysis.
The first one zeroes the variable that accounts for the amount of
thread interference when a new cycle begins.
The second fixes an imprecision on the IRQ delay account when
the value is near 0.
The last one fixes the case when an IRQ interference for the
next activation is considered for the previous one.
Daniel Bristot de Oliveira (3):
rtla/timerlat_aa: Zero thread sum after every sample analysis
rtla/timerlat_aa: Fix negative irq delay
rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after
thread sample
tools/tracing/rtla/src/timerlat_aa.c | 32 ++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] rtla/timerlat_aa: Zero thread sum after every sample analysis
2023-08-04 15:52 [PATCH 0/3] rtla fixes for 6.5 Daniel Bristot de Oliveira
@ 2023-08-04 15:52 ` Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 2/3] rtla/timerlat_aa: Fix negative IRQ delay Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 3/3] rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample Daniel Bristot de Oliveira
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2023-08-04 15:52 UTC (permalink / raw)
To: linux-kernel, linux-trace-devel, Steven Rostedt
Cc: William White, Daniel Bristot de Oliveira, Masami Hiramatsu
The thread thread_thread_sum accounts for thread interference
during a single activation. It was not being zeroed, so it was
accumulating thread interference over all activations.
It was not that visible when timerlat was the highest priority.
Fixes: 27e348b221f6 ("rtla/timerlat: Add auto-analysis core")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
tools/tracing/rtla/src/timerlat_aa.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/timerlat_aa.c
index e0ffe69c271c..dec5b4c4511e 100644
--- a/tools/tracing/rtla/src/timerlat_aa.c
+++ b/tools/tracing/rtla/src/timerlat_aa.c
@@ -159,6 +159,7 @@ static int timerlat_aa_irq_latency(struct timerlat_aa_data *taa_data,
taa_data->thread_nmi_sum = 0;
taa_data->thread_irq_sum = 0;
taa_data->thread_softirq_sum = 0;
+ taa_data->thread_thread_sum = 0;
taa_data->thread_blocking_duration = 0;
taa_data->timer_irq_start_time = 0;
taa_data->timer_irq_duration = 0;
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] rtla/timerlat_aa: Fix negative IRQ delay
2023-08-04 15:52 [PATCH 0/3] rtla fixes for 6.5 Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 1/3] rtla/timerlat_aa: Zero thread sum after every sample analysis Daniel Bristot de Oliveira
@ 2023-08-04 15:52 ` Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 3/3] rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample Daniel Bristot de Oliveira
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2023-08-04 15:52 UTC (permalink / raw)
To: linux-kernel, linux-trace-devel, Steven Rostedt
Cc: William White, Daniel Bristot de Oliveira, Masami Hiramatsu
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.
Fixes: 27e348b221f6 ("rtla/timerlat: Add auto-analysis core")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
tools/tracing/rtla/src/timerlat_aa.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/timerlat_aa.c
index dec5b4c4511e..baf1efda0581 100644
--- a/tools/tracing/rtla/src/timerlat_aa.c
+++ b/tools/tracing/rtla/src/timerlat_aa.c
@@ -338,7 +338,23 @@ static int timerlat_aa_irq_handler(struct trace_seq *s, struct tep_record *recor
taa_data->timer_irq_start_time = start;
taa_data->timer_irq_duration = duration;
- taa_data->timer_irq_start_delay = taa_data->timer_irq_start_time - expected_start;
+ /*
+ * 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 start delay as 0. In the end,
+ * it is less relevant than the noise.
+ */
+ if (expected_start < taa_data->timer_irq_start_time)
+ taa_data->timer_irq_start_delay = taa_data->timer_irq_start_time - expected_start;
+ else
+ taa_data->timer_irq_start_delay = 0;
/*
* not exit from idle.
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample
2023-08-04 15:52 [PATCH 0/3] rtla fixes for 6.5 Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 1/3] rtla/timerlat_aa: Zero thread sum after every sample analysis Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 2/3] rtla/timerlat_aa: Fix negative IRQ delay Daniel Bristot de Oliveira
@ 2023-08-04 15:52 ` Daniel Bristot de Oliveira
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2023-08-04 15:52 UTC (permalink / raw)
To: linux-kernel, linux-trace-devel, Steven Rostedt
Cc: William White, Daniel Bristot de Oliveira, Masami Hiramatsu
timerlat auto-analysis takes note of all IRQs, before or after the
execution of the timerlat thread.
Because we cannot go backward in the trace (we will fix it when
moving to trace-cmd lib?), timerlat aa take note of the last IRQ
execution in the waiting for the IRQ state, and then print it
if it is executed after the expected timer IRQ starting time.
After the thread sample, the timerlat starts recording the next IRQs as
"previous" irq for the next occurrence.
However, if an IRQ happens after the thread measurement but before the
tracing stops, it is classified as a previous IRQ. That is not
wrong, as it can be "previous" for the subsequent activation. What is
wrong is considering it as a potential source for the last activation.
Ignore the IRQ interference that happens after the IRQ starting time for
now. A future improvement for timerlat can be either keeping a list of
previous IRQ execution or using the trace-cmd library. Still, it requires
further investigation - it is a new feature.
Fixes: 27e348b221f6 ("rtla/timerlat: Add auto-analysis core")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
tools/tracing/rtla/src/timerlat_aa.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/timerlat_aa.c
index baf1efda0581..7093fd5333be 100644
--- a/tools/tracing/rtla/src/timerlat_aa.c
+++ b/tools/tracing/rtla/src/timerlat_aa.c
@@ -545,7 +545,7 @@ static int timerlat_aa_kworker_start_handler(struct trace_seq *s, struct tep_rec
static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
int irq_thresh, int thread_thresh)
{
- unsigned long long exp_irq_ts;
+ long long exp_irq_ts;
int total;
int irq;
@@ -562,12 +562,15 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu,
/*
* Expected IRQ arrival time using the trace clock as the base.
+ *
+ * TODO: Add a list of previous IRQ, and then run the list backwards.
*/
exp_irq_ts = taa_data->timer_irq_start_time - taa_data->timer_irq_start_delay;
-
- if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration)
- printf(" Previous IRQ interference: \t\t up to %9.2f us\n",
- ns_to_usf(taa_data->prev_irq_duration));
+ if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration) {
+ if (taa_data->prev_irq_timstamp < taa_data->timer_irq_start_time)
+ printf(" Previous IRQ interference: \t\t up to %9.2f us\n",
+ ns_to_usf(taa_data->prev_irq_duration));
+ }
/*
* The delay that the IRQ suffered before starting.
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-04 15:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 15:52 [PATCH 0/3] rtla fixes for 6.5 Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 1/3] rtla/timerlat_aa: Zero thread sum after every sample analysis Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 2/3] rtla/timerlat_aa: Fix negative IRQ delay Daniel Bristot de Oliveira
2023-08-04 15:52 ` [PATCH 3/3] rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample Daniel Bristot de Oliveira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).