From owner-svn-src-head@freebsd.org Fri Aug 4 15:25:53 2017 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 DC6C4DB611D; Fri, 4 Aug 2017 15:25:53 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pp2.rice.edu (proofpoint2.mail.rice.edu [128.42.201.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B64BB6CC12; Fri, 4 Aug 2017 15:25:52 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pps.filterd (pp2.rice.edu [127.0.0.1]) by pp2.rice.edu (8.16.0.17/8.16.0.17) with SMTP id v74CpF4P006502; Fri, 4 Aug 2017 10:25:50 -0500 Received: from mh1.mail.rice.edu (mh1.mail.rice.edu [128.42.201.20]) by pp2.rice.edu with ESMTP id 2c486u8a7m-1; Fri, 04 Aug 2017 10:25:50 -0500 X-Virus-Scanned: by amavis-2.7.0 at mh1.mail.rice.edu, auth channel Received: from 108-254-203-201.lightspeed.hstntx.sbcglobal.net (108-254-203-201.lightspeed.hstntx.sbcglobal.net [108.254.203.201]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (Authenticated sender: alc) by mh1.mail.rice.edu (Postfix) with ESMTPSA id 08C70460CF1; Fri, 4 Aug 2017 10:25:49 -0500 (CDT) Subject: Re: svn commit: r322041 - head/sys/kern To: Oliver Pinter , Alan Cox Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" References: <201708040423.v744NOix022999@repo.freebsd.org> From: Alan Cox Message-ID: <773de469-dc2f-d335-2506-bdf0a4db848a@rice.edu> Date: Fri, 4 Aug 2017 10:25:49 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=35 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611190142 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 04 Aug 2017 15:25:54 -0000 On 08/04/2017 02:57, Oliver Pinter wrote: > > > On Friday, August 4, 2017, Alan Cox > wrote: > > Author: alc > Date: Fri Aug 4 04:23:23 2017 > New Revision: 322041 > URL: https://svnweb.freebsd.org/changeset/base/322041 > > > Log: > In case readers are misled by expressions that combine > multiplication and > division, add parentheses to make the precedence explicit. > > Submitted by: Doug Moore > > Requested by: imp > Reviewed by: imp > MFC after: 1 week > X-MFC after: r321840 > Differential Revision: https://reviews.freebsd.org/D11815 > > > Modified: > head/sys/kern/subr_blist.c > > Modified: head/sys/kern/subr_blist.c > ============================================================================== > --- head/sys/kern/subr_blist.c Fri Aug 4 04:20:11 2017 > (r322040) > +++ head/sys/kern/subr_blist.c Fri Aug 4 04:23:23 2017 > (r322041) > @@ -110,6 +110,7 @@ __FBSDID("$FreeBSD$"); > #define bitcount64(x) __bitcount64((uint64_t)(x)) > #define malloc(a,b,c) calloc(a, 1) > #define free(a,b) free(a) > +#define CTASSERT(expr) > > > Is this dummy define intended? > Yes, it is for user-space, stand-alone compilation of this file. > > #include > > @@ -142,6 +143,8 @@ static void blst_radix_print(blmeta_t *scan, > daddr_t b > static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap space"); > #endif > > +CTASSERT(BLIST_BMAP_RADIX % BLIST_META_RADIX == 0); > + > /* > * For a subtree that can represent the state of up to 'radix' > blocks, the > * number of leaf nodes of the subtree is > L=radix/BLIST_BMAP_RADIX. If 'm' > @@ -151,17 +154,19 @@ static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap > space"); > * in the 'meta' functions that process subtrees. Since integer > division > * discards remainders, we can express this computation as > * skip = (m * m**h) / (m - 1) > - * skip = (m * radix / BLIST_BMAP_RADIX) / (m - 1) > - * and if m divides BLIST_BMAP_RADIX, we can simplify further to > - * skip = radix / (BLIST_BMAP_RADIX / m * (m - 1)) > - * so that a simple integer division is enough for the calculation. > + * skip = (m * (radix / BLIST_BMAP_RADIX)) / (m - 1) > + * and since m divides BLIST_BMAP_RADIX, we can simplify further to > + * skip = (radix / (BLIST_BMAP_RADIX / m)) / (m - 1) > + * skip = radix / ((BLIST_BMAP_RADIX / m) * (m - 1)) > + * so that simple integer division by a constant can safely be > used for the > + * calculation. > */ > static inline daddr_t > radix_to_skip(daddr_t radix) > { > > return (radix / > - (BLIST_BMAP_RADIX / BLIST_META_RADIX * > (BLIST_META_RADIX - 1))); > + ((BLIST_BMAP_RADIX / BLIST_META_RADIX) * > (BLIST_META_RADIX - 1))); > } > > /* > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > > To unsubscribe, send any mail to > "svn-src-head-unsubscribe@freebsd.org " >