From patchwork Thu Apr 2 03:34:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46693 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 932BB216D1 for ; Thu, 2 Apr 2015 03:35:46 +0000 (UTC) Received: by labtp8 with SMTP id tp8sf15186668lab.2 for ; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) 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=OzFTLQWDMFloYtHBu4U4iEPVSBohS+C1iBB0dq+NPVQ=; b=bodu+wibtoTgGcLWhpOfFUEGYD2rYgUUP9ZGSDb38ne/d9ooibrwrqTPvpL3YY9Njz H6efgH2QM8dvb2jmjNBl+Q+0latjhM7LWdo/Q9W0IjVCrBpLd/Yr6ZeoV5J9ZHUaVIfV /xW5F6S6VsLCH0UQISGu930lEQJSeNPEOWwWmNozoPu/71mcPi6kUy6gtWQ0byLcvf63 Jym5Taadq4ddWGdBlm841FCKU9DP3JKd+sIppuw1ALB7q4TlsXI5kEp2Y6uniUI0AMsI Yf66y18RH71aq80qkF549oJTz2MNQS8RsTPYg22+2VKhg7jD4tiTp3yZ3Tw52Xi/fQEQ qUKg== X-Gm-Message-State: ALoCoQk/lHSTZ9Wq08L6RSMy9MCJTDwvu8hwtvh5LL35T9H2dLPA4h+vGaBXlfRx0H/JApWCsjtH X-Received: by 10.112.235.70 with SMTP id uk6mr7471045lbc.24.1427945745528; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.97 with SMTP id it1ls162395lac.1.gmail; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) X-Received: by 10.152.42.141 with SMTP id o13mr31863006lal.79.1427945745386; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id zr4si3120238lbc.130.2015.04.01.20.35.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:35:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagg8 with SMTP id g8so51129453lag.1 for ; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) X-Received: by 10.112.160.227 with SMTP id xn3mr24464552lbb.112.1427945745291; Wed, 01 Apr 2015 20:35:45 -0700 (PDT) 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.57.201 with SMTP id k9csp1063448lbq; Wed, 1 Apr 2015 20:35:44 -0700 (PDT) X-Received: by 10.69.16.1 with SMTP id fs1mr83130101pbd.125.1427945713769; Wed, 01 Apr 2015 20:35:13 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com. [209.85.220.48]) by mx.google.com with ESMTPS id wo4si5449656pbc.243.2015.04.01.20.35.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.48 as permitted sender) client-ip=209.85.220.48; Received: by pactp5 with SMTP id tp5so71159734pac.1 for ; Wed, 01 Apr 2015 20:35:12 -0700 (PDT) X-Received: by 10.70.96.142 with SMTP id ds14mr47921186pdb.129.1427945712357; Wed, 01 Apr 2015 20:35:12 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id da10sm3572603pac.42.2015.04.01.20.35.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:35:11 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Prarit Bhargava , Richard Cochran Subject: [PATCH 21/21] time: Rework debugging variables so they aren't global Date: Wed, 1 Apr 2015 20:34:41 -0700 Message-Id: <1427945681-29972-22-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> References: <1427945681-29972-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.215.50 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: , Ingo suggested that the timekeeping debugging variables recently added should not be global, and should be tied to the timekeeper's read_base. Thus this patch implements that suggestion. I'm a little hesitant here, since the tkr structure has been carefully designed to fit in a cacheline. However, these additions are all at the end of the structure and are conditionally compiled. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Prarit Bhargava Cc: Richard Cochran Signed-off-by: John Stultz --- include/linux/timekeeper_internal.h | 18 +++++++++++++++++- kernel/time/timekeeping.c | 33 ++++++++++----------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index fb86963..9b33027 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h @@ -20,9 +20,13 @@ * @shift: Shift value for scaled math conversion * @xtime_nsec: Shifted (fractional) nano seconds offset for readout * @base: ktime_t (nanoseconds) base time for readout + * @last_warning: Warning ratelimiter (DEBUG_TIMEKEEPING) + * @underflow_seen: Underflow warning flag (DEBUG_TIMEKEEPING) + * @overflow_seen: Overflow warning flag (DEBUG_TIMEKEEPING) * * This struct has size 56 byte on 64 bit. Together with a seqcount it - * occupies a single 64byte cache line. + * occupies a single 64byte cache line (when DEBUG_TIMEKEEPING is not + * enabled). * * The struct is separate from struct timekeeper as it is also used * for a fast NMI safe accessors. @@ -36,6 +40,18 @@ struct tk_read_base { u32 shift; u64 xtime_nsec; ktime_t base; +#ifdef CONFIG_DEBUG_TIMEKEEPING + long last_warning; + /* + * These simple flag variables are managed + * without locks, which is racy, but ok since + * we don't really care about being super + * precise about how many events were seen, + * just that a problem was observed. + */ + int underflow_seen; + int overflow_seen; +#endif }; /** diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 676896e..ad7a80f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -118,19 +118,6 @@ static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta) #ifdef CONFIG_DEBUG_TIMEKEEPING #define WARNING_FREQ (HZ*300) /* 5 minute rate-limiting */ -/* - * These simple flag variables are managed - * without locks, which is racy, but ok since - * we don't really care about being super - * precise about how many events were seen, - * just that a problem was observed. - */ -static int timekeeping_underflow_seen; -static int timekeeping_overflow_seen; - -/* last_warning is only modified under the timekeeping lock */ -static long timekeeping_last_warning; - static void timekeeping_check_update(struct tk_read_base *tkr, cycle_t offset) { @@ -149,24 +136,24 @@ static void timekeeping_check_update(struct tk_read_base *tkr, cycle_t offset) } } - if (timekeeping_underflow_seen) { - if (jiffies - timekeeping_last_warning > WARNING_FREQ) { + if (tkr->underflow_seen) { + if (jiffies - tkr->last_warning > WARNING_FREQ) { printk_deferred("WARNING: Underflow in clocksource '%s' observed, time update ignored.\n", name); printk_deferred(" Please report this, consider using a different clocksource, if possible.\n"); printk_deferred(" Your kernel is probably still fine.\n"); - timekeeping_last_warning = jiffies; + tkr->last_warning = jiffies; } - timekeeping_underflow_seen = 0; + tkr->underflow_seen = 0; } - if (timekeeping_overflow_seen) { - if (jiffies - timekeeping_last_warning > WARNING_FREQ) { + if (tkr->overflow_seen) { + if (jiffies - tkr->last_warning > WARNING_FREQ) { printk_deferred("WARNING: Overflow in clocksource '%s' observed, time update capped.\n", name); printk_deferred(" Please report this, consider using a different clocksource, if possible.\n"); printk_deferred(" Your kernel is probably still fine.\n"); - timekeeping_last_warning = jiffies; + tkr->last_warning = jiffies; } - timekeeping_overflow_seen = 0; + tkr->overflow_seen = 0; } } @@ -197,13 +184,13 @@ static inline cycle_t timekeeping_get_delta(struct tk_read_base *tkr) * mask-relative negative values. */ if (unlikely((~delta & mask) < (mask >> 3))) { - timekeeping_underflow_seen = 1; + tkr->underflow_seen = 1; delta = 0; } /* Cap delta value to the max_cycles values to avoid mult overflows */ if (unlikely(delta > max)) { - timekeeping_overflow_seen = 1; + tkr->overflow_seen = 1; delta = tkr->clock->max_cycles; }