From patchwork Mon Mar 25 20:08:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15633 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 181D523E66 for ; Mon, 25 Mar 2013 20:08:38 +0000 (UTC) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by fiordland.canonical.com (Postfix) with ESMTP id B7CDFA19561 for ; Mon, 25 Mar 2013 20:08:37 +0000 (UTC) Received: by mail-vc0-f169.google.com with SMTP id kw10so5090379vcb.28 for ; Mon, 25 Mar 2013 13:08:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=fj1GK+kCRFatQIKLjfaJyvNBZhSW3RgglYCCscMBSBc=; b=W6aFPDPa/pfKbJ7azKapwiNQ21u9ccYXZ2Wv9i9XSzoAgT74vTL2SwzX39fDJEcAPl X1saa+EsizbJGxHFTbq/KXshb0+DnJIbA7KuEHqEQImAdTM9sU7IVDajFUNAFZXOY3nT hZCIQxAbQzDbV7McKMtikYtQZ6cvL2yWv0nT0xDqv2Mt9EMQcNJDRzvoORbQYsjRPsux zlM1Z2N7hbVI067v90yXD4srSKY+hp/ePWxC4aGFz3XbBgjO3hE6L8c8h0UTC+WEDCaO ZzI6Jx/pCFNAuBHe75rNjfvrPUt0IiC6pv27VHBrHe9sJ4mbb1F7cJPMAGFqcn1qBB/R tYBQ== X-Received: by 10.52.20.239 with SMTP id q15mr14897747vde.73.1364242117248; Mon, 25 Mar 2013 13:08:37 -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.59.4.204 with SMTP id cg12csp41763ved; Mon, 25 Mar 2013 13:08:36 -0700 (PDT) X-Received: by 10.68.201.135 with SMTP id ka7mr19625857pbc.119.1364242116327; Mon, 25 Mar 2013 13:08:36 -0700 (PDT) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx.google.com with ESMTPS id tr1si15071836pab.152.2013.03.25.13.08.36 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.177 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.177; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.192.177 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-pd0-f177.google.com with SMTP id y14so2699530pdi.36 for ; Mon, 25 Mar 2013 13:08:36 -0700 (PDT) X-Received: by 10.68.129.135 with SMTP id nw7mr19233875pbb.58.1364242115916; Mon, 25 Mar 2013 13:08:35 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id gn2sm14529074pbb.22.2013.03.25.13.08.34 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:35 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 8/8] ntp: Remove ntp_lock, using the timekeeping locks to protect ntp state Date: Mon, 25 Mar 2013 13:08:18 -0700 Message-Id: <1364242098-5977-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> References: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQneopuoGYdjWGy5bHL8uGaTY+N4u/kfgYZFU3TJPO719U42A1Y6ddJhqN8pLupvQYLcPkrQ In order to properly handle the NTP state in future changes to the timekeeping lock management, this patch moves the management of all of the ntp state under the timekeeping locks. This allows us to remove the ntp_lock. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/ntp.c | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index a331ebc..12ff13a 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -22,10 +22,10 @@ /* * NTP timekeeping variables: + * + * Note: All of the NTP state is protected by the timekeeping locks. */ -DEFINE_RAW_SPINLOCK(ntp_lock); - /* USER_HZ period (usecs): */ unsigned long tick_usec = TICK_USEC; @@ -132,8 +132,6 @@ static inline void pps_reset_freq_interval(void) /** * pps_clear - Clears the PPS state variables - * - * Must be called while holding a write on the ntp_lock */ static inline void pps_clear(void) { @@ -148,8 +146,6 @@ static inline void pps_clear(void) /* Decrease pps_valid to indicate that another second has passed since * the last PPS signal. When it reaches 0, indicate that PPS signal is * missing. - * - * Must be called while holding a write on the ntp_lock */ static inline void pps_dec_valid(void) { @@ -344,10 +340,6 @@ static void ntp_update_offset(long offset) */ void ntp_clear(void) { - unsigned long flags; - - raw_spin_lock_irqsave(&ntp_lock, flags); - time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; time_maxerror = NTP_PHASE_LIMIT; @@ -360,20 +352,12 @@ void ntp_clear(void) /* Clear PPS state variables */ pps_clear(); - raw_spin_unlock_irqrestore(&ntp_lock, flags); - } u64 ntp_tick_length(void) { - unsigned long flags; - s64 ret; - - raw_spin_lock_irqsave(&ntp_lock, flags); - ret = tick_length; - raw_spin_unlock_irqrestore(&ntp_lock, flags); - return ret; + return tick_length; } @@ -391,9 +375,6 @@ int second_overflow(unsigned long secs) { s64 delta; int leap = 0; - unsigned long flags; - - raw_spin_lock_irqsave(&ntp_lock, flags); /* * Leap second processing. If in leap-insert state at the end of the @@ -475,8 +456,6 @@ int second_overflow(unsigned long secs) time_adjust = 0; out: - raw_spin_unlock_irqrestore(&ntp_lock, flags); - return leap; } @@ -571,10 +550,7 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts) time_status |= txc->status & ~STA_RONLY; } -/* - * Called with ntp_lock held, so we can access and modify - * all the global NTP state: - */ + static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts, s32 *time_tai) @@ -666,8 +642,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) { int result; - raw_spin_lock_irq(&ntp_lock); - if (txc->modes & ADJ_ADJTIME) { long save_adjust = time_adjust; @@ -708,8 +682,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) /* fill PPS status fields */ pps_fill_timex(txc); - raw_spin_unlock_irq(&ntp_lock); - txc->time.tv_sec = ts->tv_sec; txc->time.tv_usec = ts->tv_nsec; if (!(time_status & STA_NANO)) @@ -906,8 +878,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) pts_norm = pps_normalize_ts(*phase_ts); - raw_spin_lock_irqsave(&ntp_lock, flags); - /* clear the error bits, they will be set again if needed */ time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR); @@ -919,7 +889,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) * just start the frequency interval */ if (unlikely(pps_fbase.tv_sec == 0)) { pps_fbase = *raw_ts; - raw_spin_unlock_irqrestore(&ntp_lock, flags); return; } @@ -934,7 +903,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) time_status |= STA_PPSJITTER; /* restart the frequency calibration interval */ pps_fbase = *raw_ts; - raw_spin_unlock_irqrestore(&ntp_lock, flags); pr_err("hardpps: PPSJITTER: bad pulse\n"); return; } @@ -951,7 +919,6 @@ void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) hardpps_update_phase(pts_norm.nsec); - raw_spin_unlock_irqrestore(&ntp_lock, flags); } #endif /* CONFIG_NTP_PPS */