From patchwork Tue Feb 28 00:29: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: 6961 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 1ED5623E4A for ; Tue, 28 Feb 2012 00:30:00 +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 D82A3A18745 for ; Tue, 28 Feb 2012 00:29:59 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so310189iag.11 for ; Mon, 27 Feb 2012 16:29:59 -0800 (PST) Received: from mr.google.com ([10.50.12.170]) by 10.50.12.170 with SMTP id z10mr766452igb.55.1330388999718 (num_hops = 1); Mon, 27 Feb 2012 16:29:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.12.170 with SMTP id z10mr663880igb.55.1330388999677; Mon, 27 Feb 2012 16:29:59 -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.11.10 with SMTP id r10csp13071ibr; Mon, 27 Feb 2012 16:29:59 -0800 (PST) Received: by 10.236.186.1 with SMTP id v1mr19363719yhm.4.1330388998975; Mon, 27 Feb 2012 16:29:58 -0800 (PST) Received: from e3.ny.us.ibm.com (e3.ny.us.ibm.com. [32.97.182.143]) by mx.google.com with ESMTPS id d9si17628279yhn.96.2012.02.27.16.29.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Feb 2012 16:29:58 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) client-ip=32.97.182.143; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Feb 2012 19:29:55 -0500 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e3.ny.us.ibm.com (192.168.1.103) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Feb 2012 19:29:45 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 50D9838C805C; Mon, 27 Feb 2012 19:29:44 -0500 (EST) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1S0ThrT312234; Mon, 27 Feb 2012 19:29:44 -0500 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1S0Thww020050; Mon, 27 Feb 2012 17:29:43 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q1S0ThVU020010; Mon, 27 Feb 2012 17:29:43 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 4CA32C03C6; Mon, 27 Feb 2012 16:29:42 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Eric Dumazet , Richard Cochran Subject: [PATCH 4/7] time: Update timekeeper structure using a local shadow Date: Mon, 27 Feb 2012 16:29:31 -0800 Message-Id: <1330388974-27793-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1330388974-27793-1-git-send-email-john.stultz@linaro.org> References: <1330388974-27793-1-git-send-email-john.stultz@linaro.org> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12022800-8974-0000-0000-000006C26D7F X-Gm-Message-State: ALoCoQn7bLUgEz5hBkreDIvwqGUywNq+DQDEIvs+acO8SYNLTHh7dl/89HoIplH86vYay29wUATe Uses a local shadow structure to update the timekeeper. This will allow for reduced timekeeper.rlock hold time. CC: Thomas Gleixner CC: Eric Dumazet CC: Richard Cochran Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 42 ++++++++++++++++++++++-------------------- 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4962284..6c36d19 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1051,6 +1051,7 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, static void update_wall_time(void) { struct clocksource *clock; + struct timekeeper tk; cycle_t offset; int shift = 0, maxshift; unsigned long flags; @@ -1063,10 +1064,11 @@ static void update_wall_time(void) if (unlikely(timekeeping_suspended)) goto out; - clock = timekeeper.clock; + tk = timekeeper; + clock = tk.clock; #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET - offset = timekeeper.cycle_interval; + offset = tk.cycle_interval; #else offset = (clock->read(clock) - clock->cycle_last) & clock->mask; #endif @@ -1079,19 +1081,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(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<= tk.cycle_interval) { + offset = logarithmic_accumulation(&tk, offset, shift); + if (offset < tk.cycle_interval<= - (NSEC_PER_SEC << timekeeper.shift))) { - timekeeper.xtime_nsec -= NSEC_PER_SEC << timekeeper.shift; - timekeeper.xtime_sec++; + if (unlikely(tk.xtime_nsec >= (NSEC_PER_SEC << tk.shift))) { + tk.xtime_nsec -= NSEC_PER_SEC << tk.shift; + tk.xtime_sec++; second_overflow(); } + + timekeeper = tk; timekeeping_update(&timekeeper, false); out: