From patchwork Thu Jan 23 01:34:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 23560 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7FFC203C6 for ; Thu, 23 Jan 2014 01:35:14 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id fa1sf2827486pad.8 for ; Wed, 22 Jan 2014 17:35:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mTGzwElgjWkTvk0eiSsR8iXgjLWPKYPkMlvV2kpM1ws=; b=HaQFwJw+67pv0jgClsjBg1rh+TjMNnvcGzl0txk0uGZ4B+EjG7+1ZQauX7UYxm+WzI klSdhcSjcYjWL66t/9xo6r8cHl+KQSvWarvCR7nMgrtE0aRMqZOQl84fPhrf4OvVjiMU TIV4SgeF9j+36N/Mz2i7cSfS6UOPJWuguFg6HhXE7FtyhFgHWRfBs4Mriq9VXMq9YZCo SL8CrsZ5kfN3FqvLjrXANZa8ZsLT8fqjgroqo6mOSB8MRhPT1IYGHPIoWVJ4BR8HrcLQ BaodIhLWh6AF1bpDOpwgMviB7Doil5b1RS7lX61QTUvcJAOlB24g5Iqo1xhQMF7YukQJ j+3g== X-Gm-Message-State: ALoCoQmPC/ZT83HR6GoYb0mN80fToJBYDKt4hvBjCGqOTglFXTcJ6AyezzItqj7EmpjWLCWq0P2T X-Received: by 10.68.201.74 with SMTP id jy10mr1961473pbc.2.1390440914032; Wed, 22 Jan 2014 17:35:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.195 with SMTP id 3ls199475qeg.75.gmail; Wed, 22 Jan 2014 17:35:13 -0800 (PST) X-Received: by 10.58.66.137 with SMTP id f9mr2983996vet.11.1390440913889; Wed, 22 Jan 2014 17:35:13 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id gq1si5670210vec.137.2014.01.22.17.35.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 17:35:13 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so731572veb.18 for ; Wed, 22 Jan 2014 17:35:13 -0800 (PST) X-Received: by 10.220.188.70 with SMTP id cz6mr54773vcb.59.1390440913799; Wed, 22 Jan 2014 17:35:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp224912vcz; Wed, 22 Jan 2014 17:35:13 -0800 (PST) X-Received: by 10.66.241.73 with SMTP id wg9mr5056564pac.69.1390440912903; Wed, 22 Jan 2014 17:35:12 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id tb5si11886345pac.191.2014.01.22.17.35.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 17:35:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.54; Received: by mail-pa0-f54.google.com with SMTP id fa1so1167728pad.41 for ; Wed, 22 Jan 2014 17:35:12 -0800 (PST) X-Received: by 10.68.76.68 with SMTP id i4mr4940710pbw.73.1390440912452; Wed, 22 Jan 2014 17:35:12 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id j3sm29268483pbh.38.2014.01.22.17.35.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 17:35:11 -0800 (PST) From: John Stultz To: stable Cc: John Stultz , Sasha Levin , Thomas Gleixner , Ingo Molnar , David Vrabel , Konrad Rzeszutek Wilk , Prarit Bhargava , Richard Cochran Subject: [PATCH 2/6] 3.13.y: timekeeping: Fix potential lost pv notification of time change Date: Wed, 22 Jan 2014 17:34:55 -0800 Message-Id: <1390440899-10273-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390440899-10273-1-git-send-email-john.stultz@linaro.org> References: <1390440899-10273-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This is a 3.13-stable backport of 5258d3f25c76f6ab86e9333abf97a55a877d3870 In 780427f0e11 (Indicate that clock was set in the pvclock gtod notifier), logic was added to pass a CLOCK_WAS_SET notification to the pvclock notifier chain. While that patch added a action flag returned from accumulate_nsecs_to_secs(), it only uses the returned value in one location, and not in the logarithmic accumulation. This means if a leap second triggered during the logarithmic accumulation (which is most likely where it would happen), the notification that the clock was set would not make it to the pv notifiers. This patch extends the logarithmic_accumulation pass down that action flag so proper notification will occur. This patch also changes the varialbe action -> clock_set per Ingo's suggestion. Cc: Sasha Levin Cc: Thomas Gleixner Cc: Ingo Molnar Cc: David Vrabel Cc: Konrad Rzeszutek Wilk Cc: Prarit Bhargava Cc: Richard Cochran Cc: stable #3.11+ Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6bad3d9..419faec 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1256,7 +1256,7 @@ out_adjust: static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) { u64 nsecps = (u64)NSEC_PER_SEC << tk->shift; - unsigned int action = 0; + unsigned int clock_set = 0; while (tk->xtime_nsec >= nsecps) { int leap; @@ -1279,10 +1279,10 @@ static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); clock_was_set_delayed(); - action = TK_CLOCK_WAS_SET; + clock_set = TK_CLOCK_WAS_SET; } } - return action; + return clock_set; } /** @@ -1295,7 +1295,8 @@ static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) * Returns the unconsumed cycles. */ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, - u32 shift) + u32 shift, + unsigned int *clock_set) { cycle_t interval = tk->cycle_interval << shift; u64 raw_nsecs; @@ -1309,7 +1310,7 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, tk->cycle_last += interval; tk->xtime_nsec += tk->xtime_interval << shift; - accumulate_nsecs_to_secs(tk); + *clock_set |= accumulate_nsecs_to_secs(tk); /* Accumulate raw time */ raw_nsecs = (u64)tk->raw_interval << shift; @@ -1367,7 +1368,7 @@ static void update_wall_time(void) struct timekeeper *tk = &shadow_timekeeper; cycle_t offset; int shift = 0, maxshift; - unsigned int action; + unsigned int clock_set = 0; unsigned long flags; raw_spin_lock_irqsave(&timekeeper_lock, flags); @@ -1402,7 +1403,8 @@ static void update_wall_time(void) maxshift = (64 - (ilog2(ntp_tick_length())+1)) - 1; shift = min(shift, maxshift); while (offset >= tk->cycle_interval) { - offset = logarithmic_accumulation(tk, offset, shift); + offset = logarithmic_accumulation(tk, offset, shift, + &clock_set); if (offset < tk->cycle_interval<cycle_last with the new value */ @@ -1436,7 +1438,7 @@ static void update_wall_time(void) * updating. */ memcpy(real_tk, tk, sizeof(*tk)); - timekeeping_update(real_tk, action); + timekeeping_update(real_tk, clock_set); write_seqcount_end(&timekeeper_seq); out: raw_spin_unlock_irqrestore(&timekeeper_lock, flags);