From patchwork Mon Feb 10 21:07:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 24417 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B29F20143 for ; Mon, 10 Feb 2014 21:07:37 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id m20sf15084749qcx.10 for ; Mon, 10 Feb 2014 13:07:37 -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=tmOF5lKvuzbdesv/8CskTspUUeVKdaTPpZ4sAU8ykks=; b=jxXt/pjVxdFFlIYQQSabl5CLrXYq5WHeegx2gey4zZVr6C7LenvPbGh/7WslwU+/MO egGrP2Gm5FBenw9riu3Qt98Pc4XxRd4uqUCciuEOuSn6LuaC+cglMcHo+0bcQaBpF+sV xpsA0A712H0lRt0U2I95LkvRlCqFdckWfHJ0yF1Os9d2+Nn40UtSPowJelXhzJ2ZxVb3 wojU83M5Mi9MqBtZ6eGA2nue+zJWzC5pFpHXyd389LnDYreFNC0aQ1sk9F0CQV1hI/Ys VryUCp8GCdgSdVy0tWftbcApEtSdn4u3ibenfnNY4kkl7uTWOVX80NDKD9BbJeK4O+jc kqxg== X-Gm-Message-State: ALoCoQn3xoJq6dk74nr6+3LpzYistZRvWKGV6Q4nIqJZGHbm8iStaX/3MhOOblX1tdo3jstVZ9dT X-Received: by 10.236.221.168 with SMTP id r38mr12352473yhp.54.1392066457096; Mon, 10 Feb 2014 13:07:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.110 with SMTP id y101ls2344566qgd.0.gmail; Mon, 10 Feb 2014 13:07:37 -0800 (PST) X-Received: by 10.52.236.132 with SMTP id uu4mr40191vdc.47.1392066457004; Mon, 10 Feb 2014 13:07:37 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id tj7si5145282vdc.46.2014.02.10.13.07.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:07:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id la4so5141205vcb.7 for ; Mon, 10 Feb 2014 13:07:36 -0800 (PST) X-Received: by 10.58.94.195 with SMTP id de3mr45901veb.39.1392066456912; Mon, 10 Feb 2014 13:07:36 -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 u4csp197760vcz; Mon, 10 Feb 2014 13:07:36 -0800 (PST) X-Received: by 10.68.129.201 with SMTP id ny9mr40237367pbb.70.1392066455810; Mon, 10 Feb 2014 13:07:35 -0800 (PST) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id r3si16600582pbh.250.2014.02.10.13.07.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:07:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.50; Received: by mail-pb0-f50.google.com with SMTP id rq2so6756116pbb.23 for ; Mon, 10 Feb 2014 13:07:35 -0800 (PST) X-Received: by 10.67.3.97 with SMTP id bv1mr28091138pad.54.1392066455242; Mon, 10 Feb 2014 13:07:35 -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 bz4sm45596387pbb.12.2014.02.10.13.07.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 13:07:34 -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/7] 3.13.y: timekeeping: Fix potential lost pv notification of time change Date: Mon, 10 Feb 2014 13:07:19 -0800 Message-Id: <1392066444-4940-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392066444-4940-1-git-send-email-john.stultz@linaro.org> References: <1392066444-4940-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.220.176 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: 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);