From owner-svn-src-head@freebsd.org Mon May 30 21:41:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47296B4F31F; Mon, 30 May 2016 21:41:41 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from gw.catspoiler.org (unknown [IPv6:2602:304:b010:ef20::f2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gw.catspoiler.org", Issuer "gw.catspoiler.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 258771301; Mon, 30 May 2016 21:41:41 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.15.2/8.15.2) with ESMTP id u4ULfVWU029594; Mon, 30 May 2016 14:41:35 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <201605302141.u4ULfVWU029594@gw.catspoiler.org> Date: Mon, 30 May 2016 14:41:31 -0700 (PDT) From: Don Lewis Subject: Re: svn commit: r300949 - head/sys/netpfil/ipfw To: brde@optusnet.com.au cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org In-Reply-To: <20160529173603.G2146@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2016 21:41:41 -0000 On 29 May, Bruce Evans wrote: > On Sun, 29 May 2016, Don Lewis wrote: > >> Log: >> Cast some expressions that multiply a long long constant by a >> floating point constant to int64_t. This avoids the runtime >> conversion of the the other operand in a set of comparisons from >> int64_t to floating point and doing the comparisions in floating >> point. >> >> Suggested by: lidl >> Submitted by: Rasool Al-Saadi >> MFC after: 2 weeks (with r300779) > > Compilers are still permitted to (and perhaps even required to) > evaluate FP constant expressions at runtime (to get rounding and/or > exception flags right). They probably don't in practice, but it is > unclear what happens for -O0 and the rules for rounding are too hard > to understand. > >> Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c >> ============================================================================== >> --- head/sys/netpfil/ipfw/dn_aqm_pie.c Sun May 29 07:14:51 2016 (r300948) >> +++ head/sys/netpfil/ipfw/dn_aqm_pie.c Sun May 29 07:23:56 2016 (r300949) >> @@ -244,17 +244,17 @@ calculate_drop_prob(void *x) >> p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S; >> >> /* auto-tune drop probability */ >> - if (prob< PIE_MAX_PROB * 0.000001) >> + if (prob < (int64_t)(PIE_MAX_PROB * 0.000001)) >> p >>= 11 + PIE_FIX_POINT_BITS+12; >> + else if (prob < (int64_t)(PIE_MAX_PROB * 0.00001)) >> p >>= 9 + PIE_FIX_POINT_BITS+12; > > Why not just divide by integer powers of 10? > > This might not give a suitably monotonic/continuous scaling at the > endpoints, but it is unclear if the FP gives that either even if we > are more careful with the rounding mode. > > A table of endpoints could be used to get precise control. Then FP > can be used more safely, since it is clear that constants in tables > must be evaluated at compile time. > >> ... > > Similarly for all cases. Thanks. I've passed this upstream.