From owner-svn-src-head@FreeBSD.ORG Sun Jul 11 08:25:00 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5A0D106564A; Sun, 11 Jul 2010 08:24:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7C98F8FC13; Sun, 11 Jul 2010 08:24:59 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o6B8OsjF064645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Jul 2010 11:24:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o6B8Os9j075958; Sun, 11 Jul 2010 11:24:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o6B8OseC075957; Sun, 11 Jul 2010 11:24:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 11 Jul 2010 11:24:54 +0300 From: Kostik Belousov To: Lawrence Stewart Message-ID: <20100711082454.GN2408@deviant.kiev.zoral.com.ua> References: <201006130239.o5D2du3m086332@svn.freebsd.org> <20100613101025.GD1320@garage.freebsd.pl> <4C158B71.205@freebsd.org> <20100614085205.GD13238@deviant.kiev.zoral.com.ua> <4C1605A7.2000202@freebsd.org> <20100614104349.GF13238@deviant.kiev.zoral.com.ua> <4C198A90.3060905@freebsd.org> <20100617071300.GX13238@deviant.kiev.zoral.com.ua> <4C1AD292.5070508@freebsd.org> <4C369172.4020700@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dPW7zu3hTOhZvCDO" Content-Disposition: inline In-Reply-To: <4C369172.4020700@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r209119 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 11 Jul 2010 08:25:00 -0000 --dPW7zu3hTOhZvCDO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 09, 2010 at 01:03:14PM +1000, Lawrence Stewart wrote: > On 06/18/10 11:57, Lawrence Stewart wrote: > > On 06/17/10 17:13, Kostik Belousov wrote: > >> On Thu, Jun 17, 2010 at 12:38:08PM +1000, Lawrence Stewart wrote: > >>> On 06/14/10 20:43, Kostik Belousov wrote: > > [snip] > >>>> Or, you could ditch the sum at all, indeed using ({}) and returning = the > >>>> result. __typeof is your friend to select proper type of accumulator. > >>> > >>> So, something like this? > >>> > >>> #define DPCPU_SUM(n, var) __extension__ = \ > >>> ({ = \ > >>> u_int > >>> _i; \ > >>> __typeof((DPCPU_PTR(n))->var) > >>> sum; \ > >>> = =20 > >>> \ > >>> sum =3D > >>> 0; \ > >>> CPU_FOREACH(_i) > >>> { \ > >>> sum +=3D (DPCPU_ID_PTR(_i, > >>> n))->var; \ > >>> =20 > >>> } \ > >>> =20 > >>> sum; \ > >>> }) > >>> > >>> Which can be used like this: > >>> > >>> totalss.n_in =3D DPCPU_SUM(ss, n_in); >=20 > [snip] >=20 > > I'll commit the above version of the macro this evening (GMT+10) unless > > I hear any objections. Thanks to all of you for your input. >=20 > Any objections to the following patch going in as a follow up to the > above discussion? >=20 > http://people.freebsd.org/~lstewart/patches/tcp_ffcaia2008/dpcpu_zeromemb= er_9.x.r209745.patch >=20 > Turns out I need DPCPU_ZERO to fix a bug in SIFTR and it occurred to me > that providing variants of the macros which work on the DPCPU variable > itself or a member of a DPCPU struct makes good sense. The new patch > therefore renames my original DPCPU_SUM to DPCPU_MEMBERSUM and includes > DPCPU_MEMBERZERO(). >=20 > Also open to suggestions on a sensible shortening of MEMBER or other > appropriate and descriptive indicator to reduce the macro name lengths. > MBR implies some sort of memory barrier... any other ideas? I suggest changing MEMBER to VAR. Are the macros only believed to be useful, or you already use them ? For the usual reasons, it seems to be better to wrap DCPU_ZERO into do/while (0). --dPW7zu3hTOhZvCDO Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkw5f9YACgkQC3+MBN1Mb4h4/ACfagFoqk7I2yAkvp+gu3jGvP0Z HJEAoM+1XFk8J2pHN+29u/mQEtDBdD5p =ZeY9 -----END PGP SIGNATURE----- --dPW7zu3hTOhZvCDO--