From patchwork Mon Sep 17 22:04:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11474 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 27E7723E53 for ; Mon, 17 Sep 2012 22:05:25 +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 302443D0900A for ; Mon, 17 Sep 2012 22:05:24 +0000 (UTC) Received: by ieak11 with SMTP id k11so9905002iea.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=q3jtwkGTzPqnL+c5JyQPY+JCghKi7VIQHwmyj3X7NH8=; b=Jt4y3nvkM/iYNYUUZOx/WA5ICdp4jmnoFTDkEGC4KXlUrDApvAiy+aVSTiHPVZL0Hy BUQmrBhUQSE4T9ykJyqQ0olDAJbBtDGtw3xthRCMrRGg2IrkWk9G4kMRZ1eaXXqDDMEA EvAAP+OxzVLDKS8ToIJkeP2Qt/JsDowZwy0CYXbmX6CCDFq+iqAPQ7Era7mELFrfotLB R9BAIPRkjXUd8WzJCJuaTS8sexFJ3SUj0xeBNaMOxkpjWiIoekzSNwLCzg8MgZgWmxvl E0Y2dOtcNUGc3fFavarRUggzuAbJYEMqQwgjtyRAZhmk/pi6Ds+wSlVVOkD1g7k0Aobj zmtg== Received: by 10.50.191.227 with SMTP id hb3mr8355325igc.43.1347919523574; 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 ex8csp341504igc; Mon, 17 Sep 2012 15:05:21 -0700 (PDT) Received: by 10.60.170.18 with SMTP id ai18mr12919770oec.125.1347919520955; Mon, 17 Sep 2012 15:05:20 -0700 (PDT) Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com. [32.97.182.137]) by mx.google.com with ESMTPS id qd10si11579543obc.101.2012.09.17.15.05.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 15:05:20 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.137 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.137 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 e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Sep 2012 18:05:19 -0400 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e7.ny.us.ibm.com (192.168.1.107) 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 d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8HM5HGN072740; 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 q8HM5Fwp014613; Mon, 17 Sep 2012 19:05:16 -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 q8HM5DvE014521; Mon, 17 Sep 2012 19:05:14 -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 1/6][RFC] time: Move timekeeper structure to timekeeper_internal.h for vsyscall changes Date: Mon, 17 Sep 2012 18:04:56 -0400 Message-Id: <1347919501-64534-2-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-5806-0000-0000-000019B450F9 X-Gm-Message-State: ALoCoQm+JXqxaADhJ9+2SMFKpZyaG/13L5N0MQKih0dB0O+Acc23BtBYnYjvlBAZBVH8q4IW/YzX We're going to need to access the timekeeper in update_vsyscall, so make the structure available for those who need it. 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 --- include/linux/timekeeper_internal.h | 68 +++++++++++++++++++++++++++++++++++ kernel/time/timekeeping.c | 56 +---------------------------- 2 files changed, 69 insertions(+), 55 deletions(-) create mode 100644 include/linux/timekeeper_internal.h diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h new file mode 100644 index 0000000..8ba43fa --- /dev/null +++ b/include/linux/timekeeper_internal.h @@ -0,0 +1,68 @@ +/* + * You SHOULD NOT be including this unless you're vsyscall + * handling code or timekeeping internal code! + */ + +#ifndef _LINUX_TIMEKEEPER_INTERNAL_H +#define _LINUX_TIMEKEEPER_INTERNAL_H + +#include +#include +#include + +/* Structure holding internal timekeeping values. */ +struct timekeeper { + /* Current clocksource used for timekeeping. */ + struct clocksource *clock; + /* NTP adjusted clock multiplier */ + u32 mult; + /* The shift value of the current clocksource. */ + u32 shift; + /* Number of clock cycles in one NTP interval. */ + cycle_t cycle_interval; + /* Number of clock shifted nano seconds in one NTP interval. */ + u64 xtime_interval; + /* shifted nano seconds left over when rounding cycle_interval */ + s64 xtime_remainder; + /* Raw nano seconds accumulated per NTP interval. */ + u32 raw_interval; + + /* Current CLOCK_REALTIME time in seconds */ + u64 xtime_sec; + /* Clock shifted nano seconds */ + u64 xtime_nsec; + + /* Difference between accumulated time and NTP time in ntp + * shifted nano seconds. */ + s64 ntp_error; + /* Shift conversion between clock shifted nano seconds and + * ntp shifted nano seconds. */ + u32 ntp_error_shift; + + /* + * wall_to_monotonic is what we need to add to xtime (or xtime corrected + * for sub jiffie times) to get to monotonic time. Monotonic is pegged + * at zero at system boot time, so wall_to_monotonic will be negative, + * however, we will ALWAYS keep the tv_nsec part positive so we can use + * the usual normalization. + * + * wall_to_monotonic is moved after resume from suspend for the + * monotonic time not to jump. We need to add total_sleep_time to + * wall_to_monotonic to get the real boot based time offset. + * + * - wall_to_monotonic is no longer the boot time, getboottime must be + * used instead. + */ + struct timespec wall_to_monotonic; + /* Offset clock monotonic -> clock realtime */ + ktime_t offs_real; + /* time spent in suspend */ + struct timespec total_sleep_time; + /* Offset clock monotonic -> clock boottime */ + ktime_t offs_boot; + /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ + struct timespec raw_time; + /* Seqlock for all timekeeper values */ + seqlock_t lock; +}; +#endif /* _LINUX_TIMEKEEPER_INTERNAL_H */ diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 34e5eac..61f5fba 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -8,6 +8,7 @@ * */ +#include #include #include #include @@ -21,61 +22,6 @@ #include #include -/* Structure holding internal timekeeping values. */ -struct timekeeper { - /* Current clocksource used for timekeeping. */ - struct clocksource *clock; - /* NTP adjusted clock multiplier */ - u32 mult; - /* The shift value of the current clocksource. */ - u32 shift; - /* Number of clock cycles in one NTP interval. */ - cycle_t cycle_interval; - /* Number of clock shifted nano seconds in one NTP interval. */ - u64 xtime_interval; - /* shifted nano seconds left over when rounding cycle_interval */ - s64 xtime_remainder; - /* Raw nano seconds accumulated per NTP interval. */ - u32 raw_interval; - - /* Current CLOCK_REALTIME time in seconds */ - u64 xtime_sec; - /* Clock shifted nano seconds */ - u64 xtime_nsec; - - /* Difference between accumulated time and NTP time in ntp - * shifted nano seconds. */ - s64 ntp_error; - /* Shift conversion between clock shifted nano seconds and - * ntp shifted nano seconds. */ - u32 ntp_error_shift; - - /* - * wall_to_monotonic is what we need to add to xtime (or xtime corrected - * for sub jiffie times) to get to monotonic time. Monotonic is pegged - * at zero at system boot time, so wall_to_monotonic will be negative, - * however, we will ALWAYS keep the tv_nsec part positive so we can use - * the usual normalization. - * - * wall_to_monotonic is moved after resume from suspend for the - * monotonic time not to jump. We need to add total_sleep_time to - * wall_to_monotonic to get the real boot based time offset. - * - * - wall_to_monotonic is no longer the boot time, getboottime must be - * used instead. - */ - struct timespec wall_to_monotonic; - /* Offset clock monotonic -> clock realtime */ - ktime_t offs_real; - /* time spent in suspend */ - struct timespec total_sleep_time; - /* Offset clock monotonic -> clock boottime */ - ktime_t offs_boot; - /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ - struct timespec raw_time; - /* Seqlock for all timekeeper values */ - seqlock_t lock; -}; static struct timekeeper timekeeper;