From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753153AbbDBIu2 (ORCPT ); Thu, 2 Apr 2015 04:50:28 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:59423 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751306AbbDBIuX (ORCPT ); Thu, 2 Apr 2015 04:50:23 -0400 Date: Thu, 2 Apr 2015 10:50:11 +0200 From: Peter Zijlstra To: John Stultz Cc: lkml , Ingo Molnar , Thomas Gleixner , Prarit Bhargava , Richard Cochran Subject: Re: [PATCH 19/21] clocksource: Improve comment explaining clocks_calc_max_nsecs()'s 50% safety margin Message-ID: <20150402085011.GJ21418@twins.programming.kicks-ass.net> References: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> <1427945681-29972-20-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427945681-29972-20-git-send-email-john.stultz@linaro.org> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 01, 2015 at 08:34:39PM -0700, John Stultz wrote: > 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) > { Should we make a further note that the tk_fast things rely on this slack since they're not strongly serialized against this? That is, they can end up using an older cycle_last value and therefore end up with a larger delta than other code.