* [PATCH] tracing/hwlat: Store the maximum latency in nanoseconds
@ 2026-11-11 3:13 Wenwu Hou
2026-11-12 10:12 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Wenwu Hou @ 2026-11-11 3:13 UTC (permalink / raw)
To: rostedt
Cc: mhiramat, mathieu.desnoyers, linux-trace-kernel, linux-kernel,
Wenwu Hou
tr->max_latency is expected to hold nanoseconds: tracing_max_lat_read()
converts it with nsecs_to_usecs() to print the usecs documented in
hwlat_detector.rst, and the other latency tracers store nanoseconds there
too.
Fixes: e7c15cd8a1133 ("tracing: Added hardware latency tracer")
Signed-off-by: Wenwu Hou <hwenwur@gmail.com>
---
kernel/trace/trace_hwlat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 65e184d800ff1..701b6a542e51a 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -293,7 +293,7 @@ static int get_sample(void)
s.count = count;
trace_hwlat_sample(&s);
- latency = max(sample, outer_sample);
+ latency = max(sample, outer_sample) * NSEC_PER_USEC;
/* Keep a running maximum ever recorded hardware latency */
if (latency > tr->max_latency) {
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] tracing/hwlat: Store the maximum latency in nanoseconds
2026-11-11 3:13 [PATCH] tracing/hwlat: Store the maximum latency in nanoseconds Wenwu Hou
@ 2026-11-12 10:12 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2026-11-12 10:12 UTC (permalink / raw)
To: Wenwu Hou; +Cc: mhiramat, mathieu.desnoyers, linux-trace-kernel, linux-kernel
On Wed, 11 Nov 2026 11:13:04 +0800
Wenwu Hou <hwenwur@gmail.com> wrote:
> tr->max_latency is expected to hold nanoseconds: tracing_max_lat_read()
> converts it with nsecs_to_usecs() to print the usecs documented in
> hwlat_detector.rst, and the other latency tracers store nanoseconds there
> too.
>
> Fixes: e7c15cd8a1133 ("tracing: Added hardware latency tracer")
> Signed-off-by: Wenwu Hou <hwenwur@gmail.com>
Amazing that this bug has been here for 10 years and nobody noticed.
> ---
> kernel/trace/trace_hwlat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
> index 65e184d800ff1..701b6a542e51a 100644
> --- a/kernel/trace/trace_hwlat.c
> +++ b/kernel/trace/trace_hwlat.c
> @@ -293,7 +293,7 @@ static int get_sample(void)
> s.count = count;
> trace_hwlat_sample(&s);
>
> - latency = max(sample, outer_sample);
> + latency = max(sample, outer_sample) * NSEC_PER_USEC;
The real fix is to just use nanoseconds in the calculations. The only
reason it was doing the conversions was to match max_latency anyway.
The time recorded in the events would need to be converted to
microseconds too, if the raw numbers are in nanos.
Thanks,
-- Steve
>
> /* Keep a running maximum ever recorded hardware latency */
> if (latency > tr->max_latency) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 3:13 [PATCH] tracing/hwlat: Store the maximum latency in nanoseconds Wenwu Hou
2026-11-12 10:12 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox