All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH] trace: Default to using trace_global_clock is sched_clock is unstable
Date: Tue, 27 Mar 2018 10:55:35 +0100	[thread overview]
Message-ID: <20180327095535.17319-1-chris@chris-wilson.co.uk> (raw)

Across suspend, we may see a very large drift in timestamps if the sched
clock is unstable, prompting the global trace's ringbuffer code to warn
and suggest switching to the global clock. Preempt this request by
detecting when the sched clock is unstable (determined during
late_initcall) and automatically switching the default clock over to
trace_global_clock.

This should prevent requiring user interaction to resolve warnings such
as:

    Delta way too big! 18446743856563626466 ts=18446744054496180323 write stamp = 197932553857
    If you just came from a suspend/resume,
    please switch to the trace global clock:
    echo global > /sys/kernel/debug/tracing/trace_clock

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 kernel/trace/trace.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 13baf85b27d8..3e39aafb9bc1 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -41,6 +41,7 @@
 #include <linux/nmi.h>
 #include <linux/fs.h>
 #include <linux/trace.h>
+#include <linux/sched/clock.h>
 #include <linux/sched/rt.h>
 
 #include "trace.h"
@@ -8484,6 +8485,13 @@ void __init trace_init(void)
 	trace_event_init();
 }
 
+#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
+static inline bool sched_clock_stable(void)
+{
+	return true;
+}
+#endif
+
 __init static int clear_boot_tracer(void)
 {
 	/*
@@ -8500,6 +8508,10 @@ __init static int clear_boot_tracer(void)
 	       default_bootup_tracer);
 	default_bootup_tracer = NULL;
 
+	/* sched_clock_stable() is determined in late_initcall */
+	if (!trace_boot_clock && !sched_clock_stable())
+		tracing_set_clock(&global_trace, "global");
+
 	return 0;
 }
 
-- 
2.16.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2018-03-27  9:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27  9:55 Chris Wilson [this message]
2018-03-27  9:57 ` [PATCH] trace: Default to using trace_global_clock is sched_clock is unstable Chris Wilson
2018-03-27 10:24 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-03-27 10:37   ` [PATCH v2] trace: Default to using trace_global_clock if " Chris Wilson
2018-03-27 11:04   ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-03-27 11:19   ` ✓ Fi.CI.BAT: success " Patchwork
2018-03-27 14:19   ` ✓ Fi.CI.IGT: " Patchwork
2018-03-27 10:40 ` ✓ Fi.CI.BAT: success for trace: Default to using trace_global_clock is " Patchwork
2018-03-27 14:16 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180327095535.17319-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.