Date: Sat, 19 Dec 2009 12:44:14 +0100 From: Hans Petter Selasky <hselasky@c2i.net> To: freebsd-arch@freebsd.org Cc: Ulrich =?iso-8859-1?q?Sp=F6rlein?= <uqs@spoerlein.net>, Harti Brandt <harti@freebsd.org> Subject: Re: network statistics in SMP Message-ID: <200912191244.17803.hselasky@c2i.net> In-Reply-To: <20091219112711.GR55913@acme.spoerlein.net> References: <20091215103759.P97203@beagle.kn.op.dlr.de> <200912151313.28326.jhb@freebsd.org> <20091219112711.GR55913@acme.spoerlein.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 19 December 2009 12:27:12 Ulrich Sp=F6rlein wrote: > On Tue, 15.12.2009 at 13:13:28 -0500, John Baldwin wrote: > > On Tuesday 15 December 2009 12:45:13 pm Harti Brandt wrote: > > > I see. I was also thinking along these lines, but was not sure whether > > > it is worth the trouble. I suppose this does not help to implement > > > 64-bit counters on 32-bit architectures, though, because you cannot > > > read them reliably without locking to sum them up, right? > > > > Either that or you just accept that you have a small race since it is > > only stats. :) > > This might be stupid, but can we not easily *read* 64bit counters > on 32bit machines like this: > > do { > h1 =3D read_upper_32bits; > l1 =3D read_lower_32bits; > h2 =3D read_upper_32bits; > l2 =3D read_lower_32bits; /* not needed */ > } while (h1 !=3D h2); Hi, Just a comment. You know you don't need a while loop to get a stable value?= =20 Should be implemented like this, in my opinion: h1 =3D read_upper_32bits; l1 =3D read_lower_32bits; h2 =3D read_upper_32bits; if (h1 !=3D h2) l1 =3D 0xffffffffUL; sum64 =3D (h1<<32) | l1; =2D-HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912191244.17803.hselasky>