From: Keir Fraser Subject: Re: [timer/ticks related] dom0 hang during boot on large 1TB system Date: Tue, 22 Dec 2009 07:59:22 +0000 Message-ID: References: <20091221200025.3641d635@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20091221200025.3641d635@mantra.us.oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Mukesh Rathor , Steve Ofsthun Cc: Hackel , Dan Magenheimer , "Xen-devel@lists.xensource.com" , Jeremy Fitzhardinge , "Kurt@acsinet11.oracle.com" List-Id: xen-devel@lists.xenproject.org I'll try and make this *really* clear... On 22/12/2009 04:00, "Mukesh Rathor" wrote: > can't use time_after/before as they do signed comparisions. > time_after(a,b): ((long)(b) - (long)(a) < 0)) The whole point is to do signed comparison. This gives you reliable +/- (BITS_PER_LONG-1) bits to reliably compare: with 32-bit Linux that means jiffy values which do not differ by more than +/- 2^31 can be reliably compared, regardless of wrapping. Bear in mind that even at HZ=1000, it'll take 3.5 *weeks* for jiffies to increase by 2^31. > thus, time_after(0xFFFEDB09, 0xFFFEDB08) will return true as will > time_after(0x1020, 0xFFFEDB08) as they are both after 0xFFFEDB08. Well yeah: anything in the ranges a=0xFFFEDB09-0xFFFFFFFF and a=0x0-0x7FFEDB09 will return true for time_after(a,0xFFFEDB08). That's how a signed 32-bit comparison works. The assumption here is that 0x1020 is derived from jiffies_64=0x100001020: in general the assumption is that the arguments to time_after() were taken within seconds/minutes/hours of each other, not days/weeks. Which precludes a jiffies_64 difference of >0x7FFFFFFF, which is what would invalidate use of time_after(). > For wrapping, unsigned comparision must be done, which is also the jiffies > data type. If you do 32-bit unsigned comparisons, that is broken by jiffies wrapping, the fixing of which was the whole point of the comparison macros. -- Keir