From patchwork Fri Mar 2 07:12:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 7052 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 B4D0C23E4A for ; Fri, 2 Mar 2012 07:13:06 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5B2D5A1849E for ; Fri, 2 Mar 2012 07:13:06 +0000 (UTC) Received: by iage36 with SMTP id e36so2587473iag.11 for ; Thu, 01 Mar 2012 23:13:05 -0800 (PST) Received: by 10.50.193.131 with SMTP id ho3mr611654igc.55.1330672385837; Thu, 01 Mar 2012 23:13:05 -0800 (PST) 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.53.18 with SMTP id k18csp3344ibg; Thu, 1 Mar 2012 23:13:05 -0800 (PST) Received: by 10.68.138.130 with SMTP id qq2mr10241498pbb.164.1330672384788; Thu, 01 Mar 2012 23:13:04 -0800 (PST) Received: from e1.ny.us.ibm.com (e1.ny.us.ibm.com. [32.97.182.141]) by mx.google.com with ESMTPS id 2si1635233pbj.203.2012.03.01.23.13.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Mar 2012 23:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.141 as permitted sender) client-ip=32.97.182.141; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.141 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e1.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Mar 2012 02:13:03 -0500 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e1.ny.us.ibm.com (192.168.1.101) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 2 Mar 2012 02:13:01 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A956E38C8059; Fri, 2 Mar 2012 02:13:00 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q227D06g116910; Fri, 2 Mar 2012 02:13:00 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q227D08C014629; Fri, 2 Mar 2012 02:13:00 -0500 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q227Cx8o014575; Fri, 2 Mar 2012 02:12:59 -0500 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id D9D66C03E5; Thu, 1 Mar 2012 23:12:58 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Ingo Molnar , Thomas Gleixner , Eric Dumazet , Richard Cochran Subject: [PATCH 4/9] time: Update timekeeper structure using a local shadow Date: Thu, 1 Mar 2012 23:12:43 -0800 Message-Id: <1330672368-32290-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1330672368-32290-1-git-send-email-john.stultz@linaro.org> References: <1330672368-32290-1-git-send-email-john.stultz@linaro.org> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12030207-6078-0000-0000-000008A1D138 X-Gm-Message-State: ALoCoQmq70YPditR57mj2pgcBYtEnh7MFBeRV4jdMt61LFZn1WQr95OKOvZ1wJW5hYyesKDxv4VQ Uses a local shadow structure to update the timekeeper. This will allow for reduced timekeeper.rlock hold time. CC: Ingo Molnar CC: Thomas Gleixner CC: Eric Dumazet CC: Richard Cochran Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 43 +++++++++++++++++++++++-------------------- 1 files changed, 23 insertions(+), 20 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f9ee96c..09460c1 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -74,6 +74,7 @@ struct timekeeper { }; static struct timekeeper timekeeper; +static struct timekeeper shadow_tk; /* Locks for timekeeper variable: */ /* This seqcount serializes readers from updates */ @@ -1072,10 +1073,11 @@ static void update_wall_time(void) if (unlikely(timekeeping_suspended)) goto out; - clock = timekeeper.clock; + shadow_tk = timekeeper; + clock = shadow_tk.clock; #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET - offset = timekeeper.cycle_interval; + offset = shadow_tk.cycle_interval; #else offset = (clock->read(clock) - clock->cycle_last) & clock->mask; #endif @@ -1088,19 +1090,19 @@ static void update_wall_time(void) * chunk in one go, and then try to consume the next smaller * doubled multiple. */ - shift = ilog2(offset) - ilog2(timekeeper.cycle_interval); + shift = ilog2(offset) - ilog2(shadow_tk.cycle_interval); shift = max(0, shift); /* Bound shift to one less then what overflows tick_length */ maxshift = (64 - (ilog2(ntp_tick_length())+1)) - 1; shift = min(shift, maxshift); - while (offset >= timekeeper.cycle_interval) { - offset = logarithmic_accumulation(&timekeeper, offset, shift); - if(offset < timekeeper.cycle_interval<= shadow_tk.cycle_interval) { + offset = logarithmic_accumulation(&shadow_tk, offset, shift); + if (offset < shadow_tk.cycle_interval<= - ((u64)NSEC_PER_SEC << timekeeper.shift))) { - timekeeper.xtime_nsec -= (u64)NSEC_PER_SEC << timekeeper.shift; - timekeeper.xtime_sec++; + if (unlikely(shadow_tk.xtime_nsec >= + ((u64)NSEC_PER_SEC << shadow_tk.shift))) { + shadow_tk.xtime_nsec -= (u64)NSEC_PER_SEC << shadow_tk.shift; + shadow_tk.xtime_sec++; second_overflow(); } + + timekeeper = shadow_tk; timekeeping_update(&timekeeper, false); out: