From owner-svn-src-head@FreeBSD.ORG Mon Jun 14 13:48:27 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 1732E1065672; Mon, 14 Jun 2010 13:48:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id DE3AA8FC22; Mon, 14 Jun 2010 13:48:26 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 6D82546B1A; Mon, 14 Jun 2010 09:48:26 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A89318A03C; Mon, 14 Jun 2010 09:48:24 -0400 (EDT) From: John Baldwin To: Lawrence Stewart Date: Mon, 14 Jun 2010 08:25:47 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201006130239.o5D2du3m086332@svn.freebsd.org> <20100613101025.GD1320@garage.freebsd.pl> <4C14E012.7080902@freebsd.org> In-Reply-To: <4C14E012.7080902@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201006140825.47375.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 14 Jun 2010 09:48:24 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek 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: Mon, 14 Jun 2010 13:48:27 -0000 On Sunday 13 June 2010 9:41:38 am Lawrence Stewart wrote: > On 06/13/10 20:10, Pawel Jakub Dawidek wrote: > > On Sun, Jun 13, 2010 at 02:39:55AM +0000, Lawrence Stewart wrote: > >> Author: lstewart > >> Date: Sun Jun 13 02:39:55 2010 > >> New Revision: 209119 > >> URL: http://svn.freebsd.org/changeset/base/209119 > >> > >> Log: > >> Add a utility macro to simplify calculating an aggregate sum from a DPCPU > >> counter variable. > >> > >> Sponsored by: FreeBSD Foundation > >> Reviewed by: jhb, rpaulo, rwatson (previous version of patch) > >> MFC after: 1 week > >> > >> Modified: > >> head/sys/sys/pcpu.h > >> > >> Modified: head/sys/sys/pcpu.h > >> ============================================================================== > >> --- head/sys/sys/pcpu.h Sun Jun 13 01:27:29 2010 (r209118) > >> +++ head/sys/sys/pcpu.h Sun Jun 13 02:39:55 2010 (r209119) > >> @@ -106,6 +106,17 @@ extern uintptr_t dpcpu_off[]; > >> #define DPCPU_ID_GET(i, n) (*DPCPU_ID_PTR(i, n)) > >> #define DPCPU_ID_SET(i, n, v) (*DPCPU_ID_PTR(i, n) = v) > >> > >> +/* > >> + * Utility macros. > >> + */ > >> +#define DPCPU_SUM(n, var, sum) \ > >> +do { \ > >> + (sum) = 0; \ > >> + u_int i; \ > >> + CPU_FOREACH(i) \ > >> + (sum) += (DPCPU_ID_PTR(i, n))->var; \ > >> +} while (0) > > > > I'd suggest first swapping variable declaration and '(sum) = 0;'. > > Can do (will wait until consensus on other issues is reached first > before tweaking though). > > > Also using 'i' as a counter in macro can easly lead to name collision. > > I had a similar concern but after chatting with John on IRC felt it > wasn't such a big deal in this case. Actually, I am a fan of using an inline function if possible to avoid the name collisions. -- John Baldwin