Received: by 10.213.65.68 with SMTP id h4csp2001336imn; Thu, 29 Mar 2018 15:28:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx493LeLspMs0AoXRwN70PlPLieoj0Q2oL3onmPUpqKrF8DCpAAbENFSyCKnk2772ycRHqGyJ X-Received: by 10.99.37.71 with SMTP id l68mr6727420pgl.440.1522362489756; Thu, 29 Mar 2018 15:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522362489; cv=none; d=google.com; s=arc-20160816; b=AEGH5lsjpicq7HEMvmh3zWaYLkTQEJwx7m2ifQqz9SMa3RxktQSNt8f2TEQ0tPiOwV U1qAA5TkYpMnJzm68gtEDlZP387JYhJX3wPTfngAlAiyDiZH8RzeqjbPosex3SnlCWvq o2qI/BU47sg9aYR8MdncS/6d/YXb0WAHgUYTGp8D85zpC9/qrsFqKZ5ktftyB+UkgSQr oO9t3orFjASIYrAgj13C+EMohXlQTAxyGg3S0vkHGtsDPUc0VnDAqu2njg/JeM15XmXf 9KoFaxGPSjdjLUO7R2/wUaFSuFWiUuj+I7MXfuaVyLwWsqwz00AzWusECtBhQ7crJY7+ fLgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2jHJJ+SIz1cPtjm5Jg2Qo6Yi/y9Q2299Bre5AT5V1sQ=; b=UfOezqVfzMgCf8ytCYlK3ug7azgIsWwnypVNu7HUxjNhIl7AEmesq16RYVJFkY4pI4 Nd1Yr0QlZ8ha9t+E5DJxD1fp3lXxz79P14EhONLDTMvUHSzw3a+raYI2/xIkUa4NcpAA w3b2YPNtuvs5A8mXuzJH7HBNwxi5ONDHYupaURqXraUOeVpGyay44feaWl2br5wWzacW kAWaiIsjU+WZpGvqI4CYy29/Ie3ha1K64ctROlZv1J0rzuOwBVOBumBcXWOK77PJuYVd yasTlxIAn3vyQIZa4C9/rBBuznpo5+MNQQ45idIY8TyvgCunf87T5zvnTF1x6tOYBx+r yCjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si4588641pgn.642.2018.03.29.15.27.55; Thu, 29 Mar 2018 15:28:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbeC2W0N (ORCPT + 99 others); Thu, 29 Mar 2018 18:26:13 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:62436 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751124AbeC2W0L (ORCPT ); Thu, 29 Mar 2018 18:26:11 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 11209143-1500050 for multiple; Thu, 29 Mar 2018 23:25:57 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 29 Mar 2018 23:25:58 +0100 From: Chris Wilson To: linux-kernel@vger.kernel.org Cc: intel-gfx@lists.freedesktop.org, Chris Wilson , Steven Rostedt Subject: [PATCH] trace: Default to using trace_global_clock if sched_clock is unstable Date: Thu, 29 Mar 2018 23:25:57 +0100 Message-Id: <20180329222557.6274-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.3 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Steven Rostedt (VMware) --- kernel/trace/trace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 13baf85b27d8..c5462513db90 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "trace.h" @@ -8505,3 +8506,15 @@ __init static int clear_boot_tracer(void) fs_initcall(tracer_init_tracefs); late_initcall_sync(clear_boot_tracer); + +#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK +__init static int tracing_set_default_clock(void) +{ + /* sched_clock_stable() is determined in late_initcall */ + if (!trace_boot_clock && !sched_clock_stable()) + tracing_set_clock(&global_trace, "global"); + + return 0; +} +late_initcall_sync(tracing_set_default_clock); +#endif -- 2.16.3