From patchwork Fri Dec 20 18:59:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22696 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 630D4202AE for ; Fri, 20 Dec 2013 19:00:00 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id oy12sf3202669veb.1 for ; Fri, 20 Dec 2013 10:59:59 -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=gfd31Dlq+H9vnl0AuP99w+2btUkh4RLXaX8zIaK+/9Y=; b=QhnbfgCR3zhj3Bw4e21cGorRPtieiUOmbLSCb0Grbbi5zak6aRuvuB67NjSaQwa8kj CLA6N0zuthLlTWNzr6KqkP28kiUkU6perqZL4Hz+GPo/iS0AT4eBNpe10yZpkF7T1AqK mnvCpJAd0JmpD+fi6vWINDWvn6NPazgbXIR54hRpdKin23kTI4OMmOme3WEUJDMa0ab7 3ogeZ18wgvZP820Jsc0GzZH9VJkHMNk2Db7mNBgbYlwD5BBdsMgRIqt0jUc/LmB1G/K+ 3NmaVgnpS1I84Fpkz+8WP5PGLMykkR7kRLNZMXOkaVp9Q37sQhiqOW4rTrvLAjQHT4G9 Ykog== X-Gm-Message-State: ALoCoQlHvv5FivaHX0zJ+/rFAX33Jl8KeXOtQqBy5Z3lgWCHitzORiEca1qSamzzmJc/rh/xV77c X-Received: by 10.224.131.6 with SMTP id v6mr4035483qas.1.1387565999402; Fri, 20 Dec 2013 10:59:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.5 with SMTP id ky5ls858412qeb.26.gmail; Fri, 20 Dec 2013 10:59:59 -0800 (PST) X-Received: by 10.221.39.195 with SMTP id tn3mr5901160vcb.2.1387565999322; Fri, 20 Dec 2013 10:59:59 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id tl2si1694863vdc.142.2013.12.20.10.59.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:59:59 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 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.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so1754783veb.27 for ; Fri, 20 Dec 2013 10:59:59 -0800 (PST) X-Received: by 10.52.74.99 with SMTP id s3mr2929vdv.42.1387565999225; Fri, 20 Dec 2013 10:59:59 -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.59.13.131 with SMTP id ey3csp83372ved; Fri, 20 Dec 2013 10:59:58 -0800 (PST) X-Received: by 10.68.239.70 with SMTP id vq6mr10226460pbc.152.1387565998199; Fri, 20 Dec 2013 10:59:58 -0800 (PST) Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by mx.google.com with ESMTPS id za5si5912118pbc.159.2013.12.20.10.59.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:59:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.41; Received: by mail-pb0-f41.google.com with SMTP id jt11so2971295pbb.14 for ; Fri, 20 Dec 2013 10:59:57 -0800 (PST) X-Received: by 10.68.232.132 with SMTP id to4mr10199371pbc.141.1387565997726; Fri, 20 Dec 2013 10:59:57 -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 z10sm20919924pas.6.2013.12.20.10.59.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 10:59:56 -0800 (PST) From: John Stultz To: LKML Cc: John Stultz , Sasha Levin , Thomas Gleixner , Ingo Molnar , David Vrabel , Konrad Rzeszutek Wilk , Prarit Bhargava , Richard Cochran , , stable Subject: [PATCH 2/3] timekeeping: Fix potential lost pv notification of time change Date: Fri, 20 Dec 2013 10:59:45 -0800 Message-Id: <1387565986-11738-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1387565986-11738-1-git-send-email-john.stultz@linaro.org> References: <1387565986-11738-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.182 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: , 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_was_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..d4c78f0 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_was_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_was_set = TK_CLOCK_WAS_SET; } } - return action; + return clock_was_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_was_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_was_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_was_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_was_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_was_set); write_seqcount_end(&timekeeper_seq); out: raw_spin_unlock_irqrestore(&timekeeper_lock, flags);