From patchwork Tue Jul 17 07:05:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 10036 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9D5D723E1B for ; Tue, 17 Jul 2012 07:06:29 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6B0D1A185F4 for ; Tue, 17 Jul 2012 07:06:29 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so65734ghb.11 for ; Tue, 17 Jul 2012 00:06:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=CmbqBViGHTmogp74h+0A0mOO8iQ4DLh8lT9DQHYDhjQ=; b=iqUiEqO4Wf9wh971I3ZL76ltRhq1CLu4fwoyDLPMrUS70cFmqyqDZFsRS5a/48rBAe HZuzILIHd2c6G00hOsBJWZSpCq0BXolHHhonGK8R4JlIBwRIQccKcc6/gEym/d62gRlg RP4fb95Snq/2ab/Lg1ZgAer4VxIYk5PRNf7t36/SvqV9kmbrOoo041jfw1mWKBw9AoBF /AEyg6ypJKQ7FDqqhOc5VqAecDXNKfLKPTfH9IFd17ahUihDbGGY8PpWKhOAZu/uyArj 6YRB3bcVes3p+zvJwLgy8/DoeJUyjkyArWC3iy5EA19G6BsiCdzDefai2/VESmvstTpm mBhg== Received: by 10.50.193.196 with SMTP id hq4mr429188igc.57.1342508789055; Tue, 17 Jul 2012 00:06:29 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.241.2 with SMTP id lc2csp15917ibb; Tue, 17 Jul 2012 00:06:28 -0700 (PDT) Received: by 10.42.80.6 with SMTP id t6mr688378ick.15.1342508788667; Tue, 17 Jul 2012 00:06:28 -0700 (PDT) Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com. [32.97.182.145]) by mx.google.com with ESMTPS id bd9si23616949icc.72.2012.07.17.00.06.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jul 2012 00:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.145 as permitted sender) client-ip=32.97.182.145; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.145 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Jul 2012 03:06:27 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e5.ny.us.ibm.com (192.168.1.105) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Jul 2012 03:05:42 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id C447138C803A for ; Tue, 17 Jul 2012 03:05:41 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6H75fQB379422 for ; Tue, 17 Jul 2012 03:05:41 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6H75egx016319 for ; Tue, 17 Jul 2012 03:05:40 -0400 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6H75aBP015997; Tue, 17 Jul 2012 03:05:37 -0400 From: John Stultz To: stable@vger.kernel.org Cc: Thomas Gleixner , John Stultz , Prarit Bhargava , Linux Kernel Subject: [PATCH 07/11] 3.2.x: timekeeping: Maintain ktime_t based offsets for hrtimers Date: Tue, 17 Jul 2012 03:05:20 -0400 Message-Id: <1342508724-14527-8-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342508724-14527-1-git-send-email-johnstul@us.ibm.com> References: <1342508724-14527-1-git-send-email-johnstul@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12071707-5930-0000-0000-000009EE3DE8 X-Gm-Message-State: ALoCoQlp4CTQI2LYbCOg67J3BqN8kKwxomm3QybH4prdfW15aTIaET/Hq5UAHcGXB3WgmgJonaf+ From: Thomas Gleixner This is a backport of 5b9fe759a678e05be4937ddf03d50e950207c1c0 We need to update the hrtimer clock offsets from the hrtimer interrupt context. To avoid conversions from timespec to ktime_t maintain a ktime_t based representation of those offsets in the timekeeper. This puts the conversion overhead into the code which updates the underlying offsets and provides fast accessible values in the hrtimer interrupt. Signed-off-by: Thomas Gleixner Signed-off-by: John Stultz Reviewed-by: Ingo Molnar Acked-by: Peter Zijlstra Acked-by: Prarit Bhargava Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1341960205-56738-4-git-send-email-johnstul@us.ibm.com Signed-off-by: Thomas Gleixner Cc: Prarit Bhargava Cc: Thomas Gleixner Cc: Linux Kernel Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 8958ad7..d5d0e5d 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -161,18 +161,34 @@ static struct timespec xtime __attribute__ ((aligned (16))); static struct timespec wall_to_monotonic __attribute__ ((aligned (16))); static struct timespec total_sleep_time; +/* Offset clock monotonic -> clock realtime */ +static ktime_t offs_real; + +/* Offset clock monotonic -> clock boottime */ +static ktime_t offs_boot; + /* * The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ static struct timespec raw_time; /* must hold write on xtime_lock */ +static void update_rt_offset(void) +{ + struct timespec tmp, *wtm = &wall_to_monotonic; + + set_normalized_timespec(&tmp, -wtm->tv_sec, -wtm->tv_nsec); + offs_real = timespec_to_ktime(tmp); +} + +/* must hold write on xtime_lock */ static void timekeeping_update(bool clearntp) { if (clearntp) { timekeeper.ntp_error = 0; ntp_clear(); } + update_rt_offset(); update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock, timekeeper.mult); } @@ -587,6 +603,7 @@ void __init timekeeping_init(void) } set_normalized_timespec(&wall_to_monotonic, -boot.tv_sec, -boot.tv_nsec); + update_rt_offset(); total_sleep_time.tv_sec = 0; total_sleep_time.tv_nsec = 0; write_sequnlock_irqrestore(&xtime_lock, flags); @@ -595,6 +612,12 @@ void __init timekeeping_init(void) /* time in seconds when suspend began */ static struct timespec timekeeping_suspend_time; +static void update_sleep_time(struct timespec t) +{ + total_sleep_time = t; + offs_boot = timespec_to_ktime(t); +} + /** * __timekeeping_inject_sleeptime - Internal function to add sleep interval * @delta: pointer to a timespec delta value @@ -612,7 +635,7 @@ static void __timekeeping_inject_sleeptime(struct timespec *delta) xtime = timespec_add(xtime, *delta); wall_to_monotonic = timespec_sub(wall_to_monotonic, *delta); - total_sleep_time = timespec_add(total_sleep_time, *delta); + update_sleep_time(timespec_add(total_sleep_time, *delta)); }