From patchwork Wed Sep 9 23:07:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 53356 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id A587422B05 for ; Wed, 9 Sep 2015 23:07:44 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf8227519lbc.1 for ; Wed, 09 Sep 2015 16:07:43 -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=amSli8xXbBarZ3d+lvgd2XyEagrn4Abaltz9gx6qZSg=; b=WrSB0xiQok9p+vX1MffaZj95mOWpVji61ADoi4sw5hvNZXE8P12qZbenOr1zb9mmuF oifcIlD1WmjDaDbJC5XPXBMVxyfVBtOzOell1Hy5JaWZF7wUcGv17hgu1mN69VwKJy28 gF2IT8UgHMNobXAgAM+hTx433xYCp4dWWdJc246NfXvToJIrn5NDarE+GF4QtprB3PWs WzdXbv4ZTair8JPn555D/F3b8bgCqj+ejWOcg+gHtmDQ0W4LegkK19WpCBqAZxIHapOD CrYeayUenZcD4MuabmgLD4VGkhwUf8d5TlxKKOWTldupuPX57dXTXxZU6ElAun89mL+S XNAw== X-Gm-Message-State: ALoCoQm4/0buKKE1Hr6pr+w4MxNUIZShDJwBy+EPHdrj4WFRqOMfly4neeMqh1SRQpVYr1ocDVUI X-Received: by 10.112.167.201 with SMTP id zq9mr8882508lbb.2.1441840063458; Wed, 09 Sep 2015 16:07:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls99252laj.98.gmail; Wed, 09 Sep 2015 16:07:43 -0700 (PDT) X-Received: by 10.152.170.130 with SMTP id am2mr32413805lac.54.1441840063307; Wed, 09 Sep 2015 16:07:43 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ut13si7377610lbb.111.2015.09.09.16.07.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 16:07:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbpo4 with SMTP id o4so14064912lbp.2 for ; Wed, 09 Sep 2015 16:07:43 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr31998574lag.86.1441840063056; Wed, 09 Sep 2015 16:07:43 -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 w3csp608919lbq; Wed, 9 Sep 2015 16:07:42 -0700 (PDT) X-Received: by 10.107.164.133 with SMTP id d5mr53395661ioj.53.1441840061908; Wed, 09 Sep 2015 16:07:41 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com. [209.85.220.47]) by mx.google.com with ESMTPS id rg6si3694738igc.35.2015.09.09.16.07.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 16:07:41 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.47 as permitted sender) client-ip=209.85.220.47; Received: by padhy16 with SMTP id hy16so23238598pad.1 for ; Wed, 09 Sep 2015 16:07:41 -0700 (PDT) X-Received: by 10.68.206.74 with SMTP id lm10mr75145791pbc.117.1441840061218; Wed, 09 Sep 2015 16:07:41 -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 hz5sm8169922pbb.39.2015.09.09.16.07.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 16:07:40 -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] time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64() Date: Wed, 9 Sep 2015 16:07:30 -0700 Message-Id: <1441840051-20244-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.217.175 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 dc491596f639438 (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;