From patchwork Tue Jul 17 22:05:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 10096 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 382C623F2A for ; Tue, 17 Jul 2012 22:06:56 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id E2CC5A1828B for ; Tue, 17 Jul 2012 22:06:55 +0000 (UTC) Received: by ggnf1 with SMTP id f1so1057694ggn.11 for ; Tue, 17 Jul 2012 15:06:55 -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=TWNhLo1DKeRswjexUBPKqrv3DveBnOZO/Kht/WejG4Y=; b=kudBWEpphfW+JQTERPPgcBuRTEWBSVdKfOP6tjrNFuSirCwmlFwVLnp2hVhPOcoxkB BhIMZY8W+cZVVXJCkcTQ7vCe5Y2ycE6Z5CEyRHrxpj0F+kVk7caVT6uL6GSOGC7k2NOo l9Za3mYNZF+y9/wPPlXjB8z1rTAVcE6m/IHhjeaGFq7758RMHBwNxcdUk66lTiZygcAW wHwlM6fOI2UyBPgEtz/RCb9uYzO9zlxQxHnJid+cdfG/rW24zeC6xN3/mN8sYrR6PA2H SFhLz+0P4PNpuCEd2ZSOnbWRdMgQVDUcCHTJmDMrx6wrcCld8sUCZz0VJ7kSEh8zqZGg WlAg== Received: by 10.50.163.99 with SMTP id yh3mr195272igb.53.1342562815239; Tue, 17 Jul 2012 15:06:55 -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 lc2csp25054ibb; Tue, 17 Jul 2012 15:06:54 -0700 (PDT) Received: by 10.50.190.163 with SMTP id gr3mr248271igc.22.1342562814830; Tue, 17 Jul 2012 15:06:54 -0700 (PDT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com. [32.97.182.146]) by mx.google.com with ESMTPS id qp2si18252083igc.21.2012.07.17.15.06.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jul 2012 15:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.146 as permitted sender) client-ip=32.97.182.146; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.146 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Jul 2012 18:06:54 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Jul 2012 18:06:52 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 3E88738C805C for ; Tue, 17 Jul 2012 18:06:52 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6HM6idm18808968 for ; Tue, 17 Jul 2012 18:06:45 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6HM5hVk022980 for ; Tue, 17 Jul 2012 19:05:43 -0300 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6HM5hMf022948; Tue, 17 Jul 2012 19:05:43 -0300 From: John Stultz To: stable@vger.kernel.org Cc: Thomas Gleixner , John Stultz , Prarit Bhargava , Linux Kernel Subject: [PATCH 07/11] 2.6.32.x: timekeeping: Maintain ktime_t based offsets for hrtimers Date: Tue, 17 Jul 2012 18:05:31 -0400 Message-Id: <1342562735-55870-8-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342562735-55870-1-git-send-email-johnstul@us.ibm.com> References: <1342562735-55870-1-git-send-email-johnstul@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12071722-1976-0000-0000-00000F45FFC1 X-Gm-Message-State: ALoCoQn1Ika/dIpcr5hgAB0Qsx2sH1DhQ696EYbMaAY6kZv1o7XlSLZPVFtCsFdmStB7vlewt+WS 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 1e9808d..c7fbc9f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -161,18 +161,34 @@ struct timespec xtime __attribute__ ((aligned (16))); 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. */ 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, timekeeper.clock, timekeeper.mult); } @@ -576,6 +592,7 @@ void __init timekeeping_init(void) set_normalized_timespec(&wall_to_monotonic, -boot.tv_sec, -boot.tv_nsec); update_xtime_cache(0); + update_rt_offset(); total_sleep_time.tv_sec = 0; total_sleep_time.tv_nsec = 0; write_sequnlock_irqrestore(&xtime_lock, flags); @@ -584,6 +601,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_resume - Resumes the generic timekeeping subsystem. * @dev: unused @@ -607,7 +630,7 @@ static int timekeeping_resume(struct sys_device *dev) ts = timespec_sub(ts, timekeeping_suspend_time); xtime = timespec_add_safe(xtime, ts); wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); - total_sleep_time = timespec_add_safe(total_sleep_time, ts); + update_sleep_time(timespec_add_safe(total_sleep_time, ts)); } update_xtime_cache(0); /* re-base the last cycle value */