From patchwork Sat Jan 10 00:34:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 42932 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B93BD26CF1 for ; Sat, 10 Jan 2015 00:34:52 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf9294851lam.2 for ; Fri, 09 Jan 2015 16:34:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=SsdZthESc1/7VkuQPDgwqfeBmPxFx+O3ChP0mGquCbs=; b=L7Sk39vkgM2k0SJX3rr+YJ/FqcLFP8hXIbKLscThJ7jnhOYPdxplMrzPP1SOvuZKbW Xsy+bv8EpmvbqNgqxnK4hfA6zcX9iD2KohFFtPHuGUQ8IosciUicFBQmhSSOyzRsK//q vtteIHv6Yptm9Uvns9/Wa444QtkdP5mZs6IFnHCQcTVMzJ5jjY4YHFELD9FCe9yJoG1l vAhV5mVOHRSkTSvcZXZSJyviHy1/bnegLrz0ZMvOE36BOFMYokioJxDanuJW9baw6y3A tXOJsV5siFLYEzCdXszYPK2aiIYF/7OQwmXGj+S5AYCE18mcaKTMj53kiP0jmTi76xc3 M8ug== X-Gm-Message-State: ALoCoQm31vZY/dtjIJA3QMcJmLj4BR0vFrd7DMRdUDRsRUv/ICeNigpLu5FR89x4PzWK1swsIYpz X-Received: by 10.180.82.34 with SMTP id f2mr759112wiy.1.1420850091729; Fri, 09 Jan 2015 16:34:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.169 with SMTP id uf9ls448516lac.75.gmail; Fri, 09 Jan 2015 16:34:51 -0800 (PST) X-Received: by 10.152.27.130 with SMTP id t2mr24087043lag.28.1420850091572; Fri, 09 Jan 2015 16:34:51 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id g8si14650169laf.55.2015.01.09.16.34.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Jan 2015 16:34:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id w7so10985189lbi.2 for ; Fri, 09 Jan 2015 16:34:51 -0800 (PST) X-Received: by 10.152.45.4 with SMTP id i4mr24648018lam.74.1420850091475; Fri, 09 Jan 2015 16:34:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp484828lbb; Fri, 9 Jan 2015 16:34:50 -0800 (PST) X-Received: by 10.66.55.41 with SMTP id o9mr27297816pap.80.1420850081389; Fri, 09 Jan 2015 16:34:41 -0800 (PST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com. [209.85.220.43]) by mx.google.com with ESMTPS id g1si9599539pde.233.2015.01.09.16.34.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Jan 2015 16:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.43 as permitted sender) client-ip=209.85.220.43; Received: by mail-pa0-f43.google.com with SMTP id kx10so21449804pab.2 for ; Fri, 09 Jan 2015 16:34:40 -0800 (PST) X-Received: by 10.70.130.73 with SMTP id oc9mr27514062pdb.42.1420850080495; Fri, 09 Jan 2015 16:34:40 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id hc10sm8046439pbd.78.2015.01.09.16.34.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Jan 2015 16:34:39 -0800 (PST) From: John Stultz To: Linux Kernel Mailing List Cc: John Stultz , Dave Jones , Linus Torvalds , Thomas Gleixner , Richard Cochran , Prarit Bhargava , Stephen Boyd , Ingo Molnar , Peter Zijlstra Subject: [PATCH 05/10] time: Add debugging checks to warn if we see delays Date: Fri, 9 Jan 2015 16:34:23 -0800 Message-Id: <1420850068-27828-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420850068-27828-1-git-send-email-john.stultz@linaro.org> References: <1420850068-27828-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Recently there's been some request for better sanity checking in the time code, so that its more clear when something is going wrong since timekeeping issues could manifest in a large number of strange ways with various subsystems. Thus, this patch adds some extra infrastructure to add a check update_wall_time to print warnings if we see the call delayed beyond the max_cycles overflow point, or beyond the clocksource max_idle_ns value which is currently 50% of the overflow point. Tested this a bit by halting qemu for specified lengths of time to trigger the warnings. Cc: Dave Jones Cc: Linus Torvalds Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: John Stultz --- kernel/time/jiffies.c | 1 + kernel/time/timekeeping.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c index a6a5bf5..7e41390 100644 --- a/kernel/time/jiffies.c +++ b/kernel/time/jiffies.c @@ -71,6 +71,7 @@ static struct clocksource clocksource_jiffies = { .mask = 0xffffffff, /*32bits*/ .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ .shift = JIFFIES_SHIFT, + .max_cycles = 10, }; __cacheline_aligned_in_smp DEFINE_SEQLOCK(jiffies_lock); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a93185..0dcceba 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1319,6 +1319,22 @@ static int __init timekeeping_init_ops(void) } device_initcall(timekeeping_init_ops); +static void timekeeping_check_offset(struct timekeeper *tk, cycle_t offset) +{ + + cycle_t max_cycles = tk->tkr.clock->max_cycles; + const char *name = tk->tkr.clock->name; + + if (offset > max_cycles) + printk("ERROR: cycle offset (%lld) is larger then" + " allowed %s max_cycles (%lld)\n", + offset, name, max_cycles); + else if (offset > (max_cycles >> 1)) + printk("WARNING: cycle offset (%lld) is past" + " the %s 50%% safety margin (%lld)\n", + offset, name, max_cycles>>1); +} + /* * Apply a multiplier adjustment to the timekeeper */ @@ -1602,6 +1618,8 @@ void update_wall_time(void) if (offset < real_tk->cycle_interval) goto out; + timekeeping_check_offset(real_tk, offset); + /* * With NO_HZ we may have to accumulate many cycle_intervals * (think "ticks") worth of time at once. To do this efficiently,