From patchwork Wed Sep 9 05:57:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 53297 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 5848522A09 for ; Wed, 9 Sep 2015 06:04:22 +0000 (UTC) Received: by lbcjc2 with SMTP id jc2sf43147666lbc.0 for ; Tue, 08 Sep 2015 23:04:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=mqZpZyIfCXPxynIl7V3qD8hNKS+lHvhHb4cMAzMXbYM=; b=HnHMX5PYIiqffS9+kQ0dLmO2yIpDDo69pXB4JE3uHl7D0MkgyS2VcKsKiIMQhgt1LS NgccKt2kVf2KOL/5U232BPFG5nMNOIBB2bgKJgRrnTqhNvUR5wpZQIFcFKHc0xrWVJPY 8vJw81oyYhEMlZY9MMphC+vuyoQLSAHBGV5rYncJLFCgc24p1wLsy0ry5TJiyF2pT+uh wWvvvbo2xjtxkKDUNSDAMBzSV36HX0zulKUAxqHmMYrahRuLUwxLheNBRgtHGw2Mwz94 c9ilc+YMdKhigqvQGU9kRHRGrmiiXrpewEV2W2vA1CXA/AWRcpGkMfXiPRpuf/7UWBO7 zUrA== X-Gm-Message-State: ALoCoQnyBeD1hE85zn8SfH9N6uy4DMIXBrSez7EynqUXy4JEgIjn96AgO6ZEnFTcykuvUo/Qy/F4 X-Received: by 10.112.158.202 with SMTP id ww10mr5093780lbb.13.1441778661254; Tue, 08 Sep 2015 23:04:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.193 with SMTP id 1ls412042law.30.gmail; Tue, 08 Sep 2015 23:04:21 -0700 (PDT) X-Received: by 10.152.22.4 with SMTP id z4mr27141137lae.81.1441778661111; Tue, 08 Sep 2015 23:04:21 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id c8si5642266lah.87.2015.09.08.23.04.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 23:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lanb10 with SMTP id b10so82781136lan.3 for ; Tue, 08 Sep 2015 23:04:20 -0700 (PDT) X-Received: by 10.112.77.10 with SMTP id o10mr27055568lbw.73.1441778660569; Tue, 08 Sep 2015 23:04:20 -0700 (PDT) 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.112.59.35 with SMTP id w3csp116311lbq; Tue, 8 Sep 2015 23:04:19 -0700 (PDT) X-Received: by 10.50.26.66 with SMTP id j2mr46566253igg.42.1441778659566; Tue, 08 Sep 2015 23:04:19 -0700 (PDT) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com. [209.85.220.42]) by mx.google.com with ESMTPS id pi9si9656866pdb.48.2015.09.08.23.04.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 23:04:19 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.42 as permitted sender) client-ip=209.85.220.42; Received: by padhk3 with SMTP id hk3so62246634pad.3 for ; Tue, 08 Sep 2015 23:04:18 -0700 (PDT) X-Received: by 10.68.223.162 with SMTP id qv2mr67935278pbc.6.1441778658450; Tue, 08 Sep 2015 23:04:18 -0700 (PDT) Received: from localhost.localdomain (c-76-115-103-22.hsd1.or.comcast.net. [76.115.103.22]) by smtp.gmail.com with ESMTPSA id et3sm5584254pad.43.2015.09.08.23.04.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Sep 2015 23:04:17 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , =?UTF-8?q?Nuno=20Gon=C3=A7alves?= , Miroslav Lichvar , Prarit Bhargava , Richard Cochran , Ingo Molnar , Thomas Gleixner , Subject: [PATCH 1/2][RFC] time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64() Date: Tue, 8 Sep 2015 22:57:05 -0700 Message-Id: <1441778226-16538-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mailfrom=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: , The internal clocksteering done for fine-grained error correction uses a logarithmic approximation, so any time adjtimex() adjusts the clock steering, timekeeping_freqadjust() quickly approximates the correct clock frequency over a series of ticks. Unfortunately, the logic in timekeeping_freqadjust(), introduced in commit dc491596f639 ("timekeeping: Rework frequency adjustments to work better w/ nohz"), used the abs() function with a s64 error value to calculate the size of the approximated adjustment to be made. Per include/linux/kernel.h: "abs() should not be used for 64-bit types (s64, u64, long long) - use abs64()". Thus on 32-bit platforms, this resulted in the clocksteering to take a quite dampended random walk trying to converge on the proper frequency, which caused the adjustments to be made much slower then intended (most easily observed when large adjustments are made). This patch fixes the issue by using abs64() instead. Cc: Nuno Gonçalves Cc: Miroslav Lichvar Cc: Prarit Bhargava Cc: Richard Cochran Cc: Ingo Molnar Cc: Thomas Gleixner Cc: # v3.17+ Reported-by: Nuno Gonçalves Tested-by: Nuno Goncalves Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f6ee2e6..3739ac6 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1614,7 +1614,7 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, negative = (tick_error < 0); /* Sort out the magnitude of the correction */ - tick_error = abs(tick_error); + tick_error = abs64(tick_error); for (adj = 0; tick_error > interval; adj++) tick_error >>= 1;