Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932167AbXEFIhA (ORCPT ); Sun, 6 May 2007 04:37:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932192AbXEFIhA (ORCPT ); Sun, 6 May 2007 04:37:00 -0400 Received: from 1wt.eu ([62.212.114.60]:2511 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932167AbXEFIg7 (ORCPT ); Sun, 6 May 2007 04:36:59 -0400 Date: Sun, 6 May 2007 10:36:00 +0200 From: Willy Tarreau To: Ingo Molnar Cc: Linus Torvalds , Esben Nielsen , Balbir Singh , linux-kernel@vger.kernel.org, Andrew Morton , Con Kolivas , Nick Piggin , Mike Galbraith , Arjan van de Ven , Peter Williams , Thomas Gleixner , caglar@pardus.org.tr, Gene Heskett , Mark Lord , Zach Carter , buddabrod Subject: Re: [patch] CFS scheduler, -v8 Message-ID: <20070506083600.GA16043@1wt.eu> References: <20070501212223.GA29867@elte.hu> <463854F3.3020403@linux.vnet.ibm.com> <20070502100545.GA6857@elte.hu> <46386F2B.9050307@linux.vnet.ibm.com> <20070502111742.GA18132@elte.hu> <20070506082911.GA32644@elte.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070506082911.GA32644@elte.hu> User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1461 Lines: 40 Hi Ingo, On Sun, May 06, 2007 at 10:29:11AM +0200, Ingo Molnar wrote: > > * Linus Torvalds wrote: > > > So the _only_ valid way to handle timers is to > > - either not allow wrapping at all (in which case "unsigned" is better, > > since it is bigger) > > - or use wrapping explicitly, and use unsigned arithmetic (which is > > well-defined in C) and do something like "(long)(a-b) > 0". > > hm, there is a corner-case in CFS where a fix like this is necessary. > > CFS uses 64-bit values for almost everything, and the majority of values > are of 'relative' nature with no danger of overflow. (They are signed > because they are relative values that center around zero and can be > negative or positive.) (...) > - if (key < entry->fair_key) { > + if ((s64)(entry->fair_key - key) > 0) { Just a hint: while your code here is correct, it is a good practise to check against < 0 instead, so that if for any reason you sometimes forget to cast to signed, the compiler will emit a warning stating that the condition is always false. This would simply become : - if (key < entry->fair_key) { + if ((s64)(key - entry->fair_key) < 0) { Just my .02 euros :-) Willy - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/