From owner-freebsd-arch Tue Jan 1 1: 9:29 2002 Delivered-To: freebsd-arch@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id B84D337B41F for ; Tue, 1 Jan 2002 01:09:25 -0800 (PST) Received: (from uucp@localhost) by srv1.cosmo-project.de (8.11.6/8.11.6) with UUCP id g0199FZ38164; Tue, 1 Jan 2002 10:09:15 +0100 (CET) (envelope-from ticso@cicely8.cicely.de) Received: from mail.cicely.de (cicely20.cicely.de [10.1.1.22]) by cicely5.cicely.de (8.12.1/8.12.1) with ESMTP id g0198Ptx034207; Tue, 1 Jan 2002 10:08:25 +0100 (CET)?g (envelope-from ticso@cicely8.cicely.de) Received: from cicely8.cicely.de (cicely8.cicely.de [10.1.2.10]) by mail.cicely.de (8.11.0/8.11.0) with ESMTP id g0198OW10702; Tue, 1 Jan 2002 10:08:24 +0100 (CET) Received: (from ticso@localhost) by cicely8.cicely.de (8.11.6/8.11.6) id g0198Ne98249; Tue, 1 Jan 2002 10:08:23 +0100 (CET) (envelope-from ticso) Date: Tue, 1 Jan 2002 10:08:23 +0100 From: Bernd Walter To: Michal Mertl Cc: Matthew Dillon , arch@FreeBSD.ORG Subject: When to use atomic_ functions? (was: 64 bit counters) Message-ID: <20020101100822.B96092@cicely8.cicely.de> References: <200112292016.fBTKGWR01735@apollo.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23i X-Operating-System: FreeBSD cicely8.cicely.de 5.0-CURRENT i386 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Dec 30, 2001 at 01:48:07AM +0100, Michal Mertl wrote: > On Sat, 29 Dec 2001, Matthew Dillon wrote: > > > :You can use cmpxchg8b on SMP systems (it's available on all machines that > > :support SMP I think) and use non-SMP versions otherwise where needed. You > > :would just implement the atomic_foo_64 versions this way. You would need to > > :use cmpxchg8b instead of addl/adcl for the acq and rel variants for SMP. > > > > This seems quite reasonable to me. > > > > Yes. I wrote the atomic functions (set, add, get) with cmpxchg8b. I also > measured the preformance and here are the results (100 mil additions on > pII 366): > > default 32 bit implementation took 1.25821 secs > atomic 32 bit implementation (from ) took 1.74043 secs > default 64 bit implementation took 2.226189 secs > atomic 64 bit implementation took 5.205156 secs atomic(9) says in the description that they can be used as an syncronisation primitive, which is why at least alphas implementation includes memory barriers. MBs are not needed for the variable itself, but they are making this family of functions very expensive. It's not very wise to handle counters with atomic_ functions unless the need to have MBs in them is not removed. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message