From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756447AbZFYTLX (ORCPT ); Thu, 25 Jun 2009 15:11:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752695AbZFYTLO (ORCPT ); Thu, 25 Jun 2009 15:11:14 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:57888 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbZFYTLO (ORCPT ); Thu, 25 Jun 2009 15:11:14 -0400 Message-ID: <4A43CBB9.7040903@ti.com> Date: Thu, 25 Jun 2009 14:10:49 -0500 From: Jon Hunter User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Thomas Gleixner CC: john stultz , "linux-kernel@vger.kernel.org" , Ingo Molnar Subject: Re: [PATCH 1/2] Dynamic Tick: Prevent clocksource wrapping during idle References: <4A1D52E3.3040204@ti.com> <1243455615.7440.17.camel@localhost.localdomain> <4A1EF244.5040108@ti.com> <4A1EFDBD.8040007@ti.com> <4A208538.3040406@ti.com> <4A282089.5020103@ti.com> In-Reply-To: <4A282089.5020103@ti.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jon Hunter wrote: > Jon Hunter wrote: >> Jon Hunter wrote: >>> + * Calculate the time delta for the next timer event. >>> + * If the time delta exceeds the maximum time delta >>> + * permitted by the current clocksource then adjust >>> + * the time delta accordingly to ensure the >>> + * clocksource does not wrap. >>> + */ >>> + time_delta = tick_period.tv64 * delta_jiffies; >> Thinking about this more, although it is very unlikely, for 64-bit >> machines there is a chance that the above multiply could overflow if >> delta_jiffies is very large. >> >> tick_period.tv64 should always be less than NSEC_PER_SEC and so you >> would need delta_jiffies to be greater than 2^32 to cause overflow. On a >> 32-bit machine an unsigned long will not be greater than 2^32 as it is >> only 32-bits but this would be possible on a 64-bit machines. >> >> So to be safe we should make sure that delta_jiffies is not greater than >> NEXT_TIMER_MAX_DELTA (2^30 - 1) before doing the multiply. If you >> think that this is a valid concern, then I can re-work and re-post. >> Sorry for not catching this before. > > With regard to the above, to ensure that there are no overflows with the > above calculation, I re-worked this patch a little. The below should be > equivalent to the current code, just re-organised a little. Let me know > if this would be acceptable or not. Hi Thomas, John, Did you guys have chance to review this? Let me know if you have any further comments/feedback. Cheers Jon