From owner-freebsd-arch@FreeBSD.ORG Sat Dec 19 11:27:13 2009 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8E5B1065672; Sat, 19 Dec 2009 11:27:13 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2a01:198:206::1]) by mx1.freebsd.org (Postfix) with ESMTP id 4F1468FC16; Sat, 19 Dec 2009 11:27:13 +0000 (UTC) Received: from acme.spoerlein.net (localhost.spoerlein.net [IPv6:::1]) by acme.spoerlein.net (8.14.3/8.14.3) with ESMTP id nBJBRCkd046767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 19 Dec 2009 12:27:12 +0100 (CET) (envelope-from uqs@spoerlein.net) Received: (from uqs@localhost) by acme.spoerlein.net (8.14.3/8.14.3/Submit) id nBJBRCn9046766; Sat, 19 Dec 2009 12:27:12 +0100 (CET) (envelope-from uqs@spoerlein.net) Date: Sat, 19 Dec 2009 12:27:12 +0100 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: John Baldwin Message-ID: <20091219112711.GR55913@acme.spoerlein.net> Mail-Followup-To: John Baldwin , Harti Brandt , freebsd-arch@freebsd.org References: <20091215103759.P97203@beagle.kn.op.dlr.de> <200912150812.35521.jhb@freebsd.org> <20091215183859.S53283@beagle.kn.op.dlr.de> <200912151313.28326.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200912151313.28326.jhb@freebsd.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Harti Brandt , freebsd-arch@freebsd.org Subject: Re: network statistics in SMP X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Dec 2009 11:27:13 -0000 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 = read_upper_32bits; l1 = read_lower_32bits; h2 = read_upper_32bits; l2 = read_lower_32bits; /* not needed */ } while (h1 != h2); sum64 = (h1<<32) + l1; or something like that? If h2 does not change between readings, no wrap-around has occured. If l1 was read in between the readings of h1 and h2, the code above is sound. Right? Regards, Uli