From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by huchra.bufferbloat.net (Postfix) with ESMTPS id AE9FF21F09F for ; Sat, 5 May 2012 01:14:19 -0700 (PDT) Received: by wgbds1 with SMTP id ds1so1837988wgb.4 for ; Sat, 05 May 2012 01:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; bh=Z4FpXOgNq21w1rCn5jD14AoDV0GYZU7u6c3WvqDLPPU=; b=K+x32n7qplsV6FMy4spf6kCTGkLsFR+oHZ6cNsCulQy0nQcVDyw4wckhD8Z8TT6iYy SPUNOZ/+XxWR7GYoPQ2HuAUc43+hju2ENIzXXUEZ6AtENUcFlwCu3zfE1qeF1fQ0kPWF 6V2DSe8B/EV9VFi+Xzg6Fr5UTBrbhCnL5lVgjSk0acYlNfA+ZpfmnsU/ErfgiDOXpVdo NL9p0Z1oV0hkVT1aItfvjqP5l4XIirLoza5C4WbFF86chtwTIdUpuqwasX4ugQ3vYqvT ZyLNj5KvEXfE53ZGmxiVbJR/oqfFRPHkErcXvQghfJSafPqEGmbXJCOCBmT5RGeVd1zI OeMw== Received: by 10.180.95.37 with SMTP id dh5mr19639195wib.8.1336205657421; Sat, 05 May 2012 01:14:17 -0700 (PDT) Received: from [172.28.130.107] ([74.125.122.49]) by mx.google.com with ESMTPS id b3sm3660294wib.4.2012.05.05.01.14.13 (version=SSLv3 cipher=OTHER); Sat, 05 May 2012 01:14:14 -0700 (PDT) From: Eric Dumazet To: Dave Taht In-Reply-To: <1336159005.3752.384.camel@edumazet-glaptop> References: <4FA3F248.3070101@freedesktop.org> <4FA3F50D.7080406@freedesktop.org> <1336146993.3752.354.camel@edumazet-glaptop> <1336153652.3752.361.camel@edumazet-glaptop> <1336155996.3752.368.camel@edumazet-glaptop> <1336157416.3752.378.camel@edumazet-glaptop> <1336159005.3752.384.camel@edumazet-glaptop> Content-Type: text/plain; charset="UTF-8" Date: Sat, 05 May 2012 10:14:12 +0200 Message-ID: <1336205652.3752.498.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Cc: codel@lists.bufferbloat.net Subject: Re: [Codel] fp sqrt vis int sqrt? X-BeenThere: codel@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: CoDel AQM discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 08:14:20 -0000 On Fri, 2012-05-04 at 21:16 +0200, Eric Dumazet wrote: > On Fri, 2012-05-04 at 12:04 -0700, Dave Taht wrote: > > > Late this evening I'll have time to incorporate the progress so far > > today (thx for the cleanups and help!!!) and I'll try to get another > > patch out late tonight. Unless you beat me to it. > > > > I am not planning to send a patch in a near future, its 9h15pm here in > France, and TGIF. > > Oh well, this is obvious, just use the following and be done : /* return interval/sqrt(x) with good precision */ u32 int_sqrt_div(u32 _interval, unsigned long x) { u64 interval = _interval; /* scale for maximum precision */ while (x < (1UL << (BITS_PER_LONG - 2))) { x <<= 2; interval <<= 1; } do_div(interval, int_sqrt(x)); return (u32)interval; } Doing the scaling before calling int_sqrt() makes int_sqrt() faster, since we avoid the initial scaling on 'one' one = 1UL << (BITS_PER_LONG - 2); while (one > op) one >>= 2; Always sleep a bit, its good.