From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932213Ab2B1AaK (ORCPT ); Mon, 27 Feb 2012 19:30:10 -0500 Received: from e37.co.us.ibm.com ([32.97.110.158]:53401 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932185Ab2B1AaG (ORCPT ); Mon, 27 Feb 2012 19:30:06 -0500 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-7408-0000-0000-00000302491B Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: -- 1.7.3.2.146.gca209