Date: Thu, 17 Jun 2010 22:44:25 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Kostik Belousov <kostikbel@gmail.com> Cc: Matthew Fleming <mdf@FreeBSD.org>, src-committers@FreeBSD.org, Pawel Jakub Dawidek <pjd@FreeBSD.org>, John Baldwin <jhb@FreeBSD.org>, svn-src-all@FreeBSD.org, brde@optusnet.com.au, svn-src-head@FreeBSD.org, Lawrence Stewart <lstewart@FreeBSD.org> Subject: Re: svn commit: r209119 - head/sys/sys Message-ID: <20100617223406.B40711@delplex.bde.org> In-Reply-To: <20100617071300.GX13238@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>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 17 Jun 2010, Kostik Belousov wrote: > On Thu, Jun 17, 2010 at 12:38:08PM +1000, Lawrence Stewart wrote: >> I've tested the above and it works. I also prefer the idea of having >> DPCPU_SUM return the sum so that you can do "var = DPCPU_SUM(...)". My >> only concern with this method is that the caller no longer has the >> choice to make the sum variable a larger type to avoid overflow. It >> would be nice to be able to have the DPCPU vars be uint32_t but be able >> to sum them into a uint64_t accumulator for example. Perhaps this isn't >> really an issue though... I'm not sure. > You are worried about overflow in the sum of 32 or 64 variables, but if > this is the case, then each member of the sum can overflow as well, IMO. > Either ignore the issue, or use a uintmax_t. Or use int variables so that the overflow trap can work, and fix the overflow trap to work (gcc -ftapv, but this is unusable in the kernel), and get a nice panic on all overflows, not just here :-). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100617223406.B40711>