From patchwork Thu Jan 2 22:23:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22868 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5C681202E2 for ; Thu, 2 Jan 2014 22:23:41 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at1sf72335122iec.3 for ; Thu, 02 Jan 2014 14:23:40 -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=+IW3ZQ4ZJB/JWsIHEJ0QN0zJCT9mNYBpLAAy0gHtWNs=; b=Kc992dPp83jM6bizuZoooU5WH65H8ax3ImkgGcasLYEblFpnlIhYVFRpZ/svRV5kZx 4Y+Qwkh4CiQzAcyBnwUw6T3ciQTx+zlna/R2P/8DdXwSQfgVfh9e+VGYk9L2TeSX4Tr1 nf96Vmf3RW5cOOdISVT5hDGHEj8VAkabw6lI4Vzxfjos8irifRRHRB/R8+MTZscPSmdx 6kb+5kgutIEnZvXez3Wk+BYOYyBp6MgQYL1NDKDacL6ubnrHexBxaUlk/p40HGp0brP2 ZX52LALu0ZHKXbRMYpO1SxYrnBwWZlDSs7beV3UVIE7Tk9J7O9Ps/zpllKu4d6giHLpF 2v8g== X-Gm-Message-State: ALoCoQlmt11SVXui350kn5lQMpq4kLjnnRA0BDxH86c07yaQdGyymVl+IyppDhSC+MqhrwDXY1y+ X-Received: by 10.182.111.227 with SMTP id il3mr4220319obb.41.1388701420701; Thu, 02 Jan 2014 14:23:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.145 with SMTP id u17ls4670216qef.42.gmail; Thu, 02 Jan 2014 14:23:40 -0800 (PST) X-Received: by 10.58.4.138 with SMTP id k10mr38290638vek.8.1388701420539; Thu, 02 Jan 2014 14:23:40 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id g11si8842447veg.87.2014.01.02.14.23.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 14:23:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so7532602veb.2 for ; Thu, 02 Jan 2014 14:23:40 -0800 (PST) X-Received: by 10.52.113.97 with SMTP id ix1mr40468256vdb.9.1388701420355; Thu, 02 Jan 2014 14:23:40 -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 ey3csp795759ved; Thu, 2 Jan 2014 14:23:39 -0800 (PST) X-Received: by 10.68.241.234 with SMTP id wl10mr19733536pbc.121.1388701419324; Thu, 02 Jan 2014 14:23:39 -0800 (PST) Received: from mail-pb0-f43.google.com (mail-pb0-f43.google.com [209.85.160.43]) by mx.google.com with ESMTPS id s4si11109244pbg.63.2014.01.02.14.23.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 14:23:39 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.43 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.43; Received: by mail-pb0-f43.google.com with SMTP id rq2so14899565pbb.16 for ; Thu, 02 Jan 2014 14:23:39 -0800 (PST) X-Received: by 10.68.89.162 with SMTP id bp2mr26151648pbb.151.1388701418905; Thu, 02 Jan 2014 14:23:38 -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 ju10sm104179969pbd.33.2014.01.02.14.23.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Jan 2014 14:23:38 -0800 (PST) From: John Stultz To: LKML Cc: John Stultz , Sasha Levin , Thomas Gleixner , Prarit Bhargava , Richard Cochran , Ingo Molnar , stable Subject: [PATCH 5/9] timekeeping: Fix CLOCK_TAI timer/nanosleep delays Date: Thu, 2 Jan 2014 14:23:23 -0800 Message-Id: <1388701407-5029-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388701407-5029-1-git-send-email-john.stultz@linaro.org> References: <52C5E6A0.7010507@linaro.org> <1388701407-5029-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.171 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: , A think-o in the calculation of the monotonic -> tai time offset results in CLOCK_TAI timers and nanosleeps to expire late (the latency is ~2x the tai offset). Fix this by adding the tai offset from the realtime offset instead of subtracting. Cc: Sasha Levin Cc: Thomas Gleixner Cc: Prarit Bhargava Cc: Richard Cochran Cc: Ingo Molnar Cc: stable #3.10+ Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 44b7e6b..3f6a827 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -77,7 +77,7 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec wtm) tk->wall_to_monotonic = wtm; set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec); tk->offs_real = timespec_to_ktime(tmp); - tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tk->tai_offset, 0)); + tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0)); } static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t) @@ -595,7 +595,7 @@ s32 timekeeping_get_tai_offset(void) static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) { tk->tai_offset = tai_offset; - tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tai_offset, 0)); + tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0)); } /**