From patchwork Mon Sep 17 22:05:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11472 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 65937392CCF for ; Mon, 17 Sep 2012 22:05:24 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id C0D2A3D09006 for ; Mon, 17 Sep 2012 22:05:23 +0000 (UTC) Received: by ieak11 with SMTP id k11so9904992iea.11 for ; Mon, 17 Sep 2012 15:05:23 -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-cbid :x-gm-message-state; bh=T7WEHMHaAt5PO6a6wqB32Om2bnTmz2HUFxOp9q7gNII=; b=U6si7ByRvFSV6Y+z/0Ivuru91iVkFCKdvSNahil3QZgP1ggtwF739updQQiNdbkiCE Eel61MRnVeJdDKFfooiqt94cBeyQx8BkturZjZYrCoQ8QfFGCaM4rf4DtrNfMwjcUnm3 HirF7VacWjhBFL5u54FFC/jlNdjQOseyl80IGDgh/bJjcQLumXLP/50imDFiNN3NH413 pTuatCVxTN1QfCa1tDkD5YEOaTsePMfXpxDxnLijPARynI2vvpwOHi1371tk9+6gqvGa Ez7nFEgTDyk0VGpjJ5+1Eux2MzUketeE6b5iABqzWvtbYjvvWI6gTsM2Igbi/7I1gygi 3wdA== Received: by 10.42.109.194 with SMTP id m2mr10060850icp.48.1347919523169; Mon, 17 Sep 2012 15:05:23 -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.50.184.232 with SMTP id ex8csp341505igc; Mon, 17 Sep 2012 15:05:21 -0700 (PDT) Received: by 10.50.168.3 with SMTP id zs3mr4151433igb.60.1347919521212; Mon, 17 Sep 2012 15:05:21 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id cw2si15821303icc.16.2012.09.17.15.05.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 15:05:21 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Sep 2012 18:05:20 -0400 Received: from d01relay05.pok.ibm.com (9.56.227.237) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Sep 2012 18:05:18 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8HM5Hhe168436; Mon, 17 Sep 2012 18:05:17 -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 q8HM5Fr8014667; Mon, 17 Sep 2012 19:05:17 -0300 Received: from kernel-pok.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 q8HM5DvI014521; Mon, 17 Sep 2012 19:05:15 -0300 From: John Stultz To: linux-kernel Cc: John Stultz , Tony Luck , Paul Mackerras , Benjamin Herrenschmidt , Andy Lutomirski , Martin Schwidefsky , Paul Turner , Steven Rostedt , Richard Cochran , Prarit Bhargava , Thomas Gleixner Subject: [PATCH 5/6][RFC] time: Only do nanosecond rounding on GENERIC_TIME_VSYSCALL_OLD systems Date: Mon, 17 Sep 2012 18:05:00 -0400 Message-Id: <1347919501-64534-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347919501-64534-1-git-send-email-john.stultz@linaro.org> References: <1347919501-64534-1-git-send-email-john.stultz@linaro.org> x-cbid: 12091722-7182-0000-0000-000002A5608B X-Gm-Message-State: ALoCoQm4bLkzlAun9iqwURErTjgCBDHPx2bFlRc6M7Gxk5be9kuoq9HuU+i0XoB+upYEK0p75n8J We only do rounding to the next nanosecond so we don't see minor 1ns inconsistencies in the vsyscall implementations. Since we're changing the vsyscall implementations to avoid this, conditionalize the rounding only to the GENERIC_TIME_VSYSCALL_OLD architectures. Cc: Tony Luck Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Andy Lutomirski Cc: Martin Schwidefsky Cc: Paul Turner Cc: Steven Rostedt Cc: Richard Cochran Cc: Prarit Bhargava Cc: Thomas Gleixner Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 61eaf3b..b976692 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1059,6 +1059,33 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, return offset; } +#ifdef CONFIG_GENERIC_TIME_VSYSCALL_OLD +static inline void old_vsyscall_fixup(struct timekeeper *tk) +{ + s64 remainder; + + /* + * Store only full nanoseconds into xtime_nsec after rounding + * it up and add the remainder to the error difference. + * XXX - This is necessary to avoid small 1ns inconsistnecies caused + * by truncating the remainder in vsyscalls. However, it causes + * additional work to be done in timekeeping_adjust(). Once + * the vsyscall implementations are converted to use xtime_nsec + * (shifted nanoseconds), and CONFIG_GENERIC_TIME_VSYSCALL_OLD + * users are removed, this can be killed. + */ + remainder = tk->xtime_nsec & ((1ULL << tk->shift) - 1); + tk->xtime_nsec -= remainder; + tk->xtime_nsec += 1ULL << tk->shift; + tk->ntp_error += remainder << tk->ntp_error_shift; + +} +#else +#define old_vsyscall_fixup(tk) +#endif + + + /** * update_wall_time - Uses the current clocksource to increment the wall time * @@ -1070,7 +1097,6 @@ static void update_wall_time(void) cycle_t offset; int shift = 0, maxshift; unsigned long flags; - s64 remainder; write_seqlock_irqsave(&tk->lock, flags); @@ -1112,20 +1138,11 @@ static void update_wall_time(void) /* correct the clock when NTP error is too big */ timekeeping_adjust(tk, offset); - /* - * Store only full nanoseconds into xtime_nsec after rounding - * it up and add the remainder to the error difference. - * XXX - This is necessary to avoid small 1ns inconsistnecies caused - * by truncating the remainder in vsyscalls. However, it causes - * additional work to be done in timekeeping_adjust(). Once - * the vsyscall implementations are converted to use xtime_nsec - * (shifted nanoseconds), this can be killed. - */ - remainder = tk->xtime_nsec & ((1ULL << tk->shift) - 1); - tk->xtime_nsec -= remainder; - tk->xtime_nsec += 1ULL << tk->shift; - tk->ntp_error += remainder << tk->ntp_error_shift; + * XXX This can be killed once everyone converts + * to the new update_vsyscall. + */ + old_vsyscall_fixup(tk); /* * Finally, make sure that after the rounding