From patchwork Thu Apr 24 23:04:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 29027 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4C6832036A for ; Thu, 24 Apr 2014 23:04:52 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id vb8sf17692500obc.11 for ; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) 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=/0ElixFeu1bLKODPCXCUxXS2yLcuXlJgWehSR50PK10=; b=JFu7j7eEI3JDgm7WerKCkoSUb41yl5FhQYeXpE1yUwosp/l7kZV3LI1lpIz+7i7jCb eV1sk22LiUHiedYzn+nVJd1JwvBi7RvrxdhwWNj/gQsXuQ4UpFkR9OOIIsT07iuDMnTs 3MuCh1CEEIXlHTTRW/PtNdYzAiNeuuaeq/8eQEojcdFHwZs06AiGxCkr1+6DOv/GoymZ HSc6gsGXJe2MPsdJPOzcZMNIeKP7IaSPrqbjVzcoU9yYkX6DMpWuP+HajCh6u9ROwwQ7 PQoJ83faM4EfVv94M+Nc2W/XMNfaeCApsGN0CnwGdCIR+Rw02WjgCtwdCtXc/jDdS4JQ cybQ== X-Gm-Message-State: ALoCoQmDs4Jv2BPm+l9qOe2jG+HVEiZhk9BqXC0Eh/c6k8LURpMTojRXFyvWzK+oiVBh5hq25R2c X-Received: by 10.43.31.81 with SMTP id sf17mr2469579icb.4.1398380691647; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.164 with SMTP id r33ls1379876qgr.2.gmail; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) X-Received: by 10.58.181.170 with SMTP id dx10mr3326619vec.25.1398380691522; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sw4si1284159vdc.192.2014.04.24.16.04.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 16:04:51 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so3820140veb.12 for ; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) X-Received: by 10.58.230.103 with SMTP id sx7mr3391091vec.28.1398380691448; Thu, 24 Apr 2014 16:04:51 -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.220.221.72 with SMTP id ib8csp52710vcb; Thu, 24 Apr 2014 16:04:51 -0700 (PDT) X-Received: by 10.66.189.201 with SMTP id gk9mr3444226pac.25.1398380690770; Thu, 24 Apr 2014 16:04:50 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id ps1si3511277pbc.379.2014.04.24.16.04.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 16:04:50 -0700 (PDT) Received-SPF: none (google.com: john.stultz@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id ey11so591568pad.31 for ; Thu, 24 Apr 2014 16:04:50 -0700 (PDT) X-Received: by 10.66.218.193 with SMTP id pi1mr3459723pac.20.1398380690344; Thu, 24 Apr 2014 16:04:50 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id de5sm11437842pbc.66.2014.04.24.16.04.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 16:04:49 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , Miroslav Lichvar , Richard Cochran , Prarit Bhargava Subject: [PATCH 3/3] [RFC] timekeeping: Loop in the freqadjust logic to speed up convergence Date: Thu, 24 Apr 2014 16:04:37 -0700 Message-Id: <1398380677-8684-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398380677-8684-1-git-send-email-john.stultz@linaro.org> References: <1398380677-8684-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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , I'm not convinced this is necessary, but this patch changes the freqadjust logic so instead of approximating the correct frequency adjustment making one logarithmic adjustment per tick, we loop until the correct adjustment is found on the first call. Thus, rather then splitting the correction up over a number of ticks we do it all in the first tick. This is an increase of work, but should avoid error accumulation which would slow convergence. Again, I'm not sure the error accumulation is significant enough to warrant the extra work here, but it improves simulator results so I'm including this change for review and discussion. Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index a130d00..6e715c3 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1139,6 +1139,7 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, bool negative; u32 adj; +again: tk->ntp_tick = ntp_tick_length(); /* Calculate current error per tick */ tick_error = ntp_tick_length() >> tk->ntp_error_shift; @@ -1159,6 +1160,8 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, /* scale the corrections */ timekeeping_apply_adjustment(tk, offset, negative, adj); + if (adj) + goto again; }