From patchwork Thu Apr 2 03:34:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED1C8216D1 for ; Thu, 2 Apr 2015 03:36:51 +0000 (UTC) Received: by wibgr10 with SMTP id gr10sf15751511wib.2 for ; Wed, 01 Apr 2015 20:36: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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=a7I75ghZNJvLCBFUYRtyB9NeyNq2b5FaHjdFJaD64vI=; b=S+221hhYl9+P1rs1F/KtoDsKu5JmGjj1FYUQF6MN1LRok9IfCDyjCHfn1tf/wEgFWZ Gy+Ks7bYMReHryc7jyVxSeyJfQn4AqbO5tCV9Wl+rvm8RNNUPRJpeBjyKyO/IL4V2Paj 7ZMcGHskq6Kw5TtG8m+YDTaRuU04pUFkR1s3ZFIJ72OqtAgqcdnDMdxH3/c12m+OyWeD nMEZ0gOR+6DJuUb5BCQ2ExwTmm7vdiKT7DEKZvQD/nBKRAYERjHjnWnQZxSc53tXa2cK NJYZamk3WPLN7z+HC3HFXyWtdHo2OkO3DCh/ULDWRhdNlAFmMf7u4Uao6NxBU/aWRluM Ys8A== X-Gm-Message-State: ALoCoQnia+utcaYpbHxDqx1esX5j29a9DtfPNbql5vTDBarZR6xYCjd/QOo9loRqvKoSJeubccyJ X-Received: by 10.152.19.67 with SMTP id c3mr10255943lae.7.1427945811171; Wed, 01 Apr 2015 20:36:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.7 with SMTP id o7ls158914lao.52.gmail; Wed, 01 Apr 2015 20:36:51 -0700 (PDT) X-Received: by 10.112.147.131 with SMTP id tk3mr11716389lbb.11.1427945810994; Wed, 01 Apr 2015 20:36:50 -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 eb3si3139706lbc.50.2015.04.01.20.36.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:36:50 -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 lbbzk7 with SMTP id zk7so34233353lbb.0 for ; Wed, 01 Apr 2015 20:36:50 -0700 (PDT) X-Received: by 10.152.4.104 with SMTP id j8mr18786219laj.72.1427945810843; Wed, 01 Apr 2015 20:36:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1063848lbq; Wed, 1 Apr 2015 20:36:49 -0700 (PDT) X-Received: by 10.68.143.65 with SMTP id sc1mr82471544pbb.2.1427945808316; Wed, 01 Apr 2015 20:36:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si5580227pdf.62.2015.04.01.20.36.46; Wed, 01 Apr 2015 20:36:48 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbbDBDgn (ORCPT + 27 others); Wed, 1 Apr 2015 23:36:43 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36573 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752997AbbDBDfK (ORCPT ); Wed, 1 Apr 2015 23:35:10 -0400 Received: by pdea3 with SMTP id a3so24279032pde.3 for ; Wed, 01 Apr 2015 20:35:09 -0700 (PDT) X-Received: by 10.66.182.201 with SMTP id eg9mr42051164pac.68.1427945709791; Wed, 01 Apr 2015 20:35:09 -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 da10sm3572603pac.42.2015.04.01.20.35.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:35:09 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Prarit Bhargava , Richard Cochran Subject: [PATCH 19/21] clocksource: Improve comment explaining clocks_calc_max_nsecs()'s 50% safety margin Date: Wed, 1 Apr 2015 20:34:39 -0700 Message-Id: <1427945681-29972-20-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> References: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Ingo noted that the description of clocks_calc_max_nsecs()'s 50% safety margin was somewhat circular. So this patch tries to improve the comment to better explain what we mean by the 50% safety margin and why we need it. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Prarit Bhargava Cc: Richard Cochran Signed-off-by: John Stultz --- kernel/time/clocksource.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index c3be3c7..15facb1 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -472,8 +472,11 @@ static u32 clocksource_max_adjustment(struct clocksource *cs) * @max_cyc: maximum cycle value before potential overflow (does not include * any safety margin) * - * NOTE: This function includes a safety margin of 50%, so that bad clock values - * can be detected. + * NOTE: This function includes a safety margin of 50%, in other words, we + * return half the number of nanoseconds the hardware counter can technically + * cover. This is done so that we can potentially detect problems caused by + * delayed timers or bad hardware, which might result in time intervals that + * are larger then what the math used can handle without overflows. */ u64 clocks_calc_max_nsecs(u32 mult, u32 shift, u32 maxadj, u64 mask, u64 *max_cyc) {