Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Jan 2002 10:08:23 +0100
From:      Bernd Walter <ticso@cicely8.cicely.de>
To:        Michal Mertl <mime@traveller.cz>
Cc:        Matthew Dillon <dillon@apollo.backplane.com>, arch@FreeBSD.ORG
Subject:   When to use atomic_ functions? (was: 64 bit counters)
Message-ID:  <20020101100822.B96092@cicely8.cicely.de>
In-Reply-To: <Pine.BSF.4.41.0112300114010.48350-100000@prg.traveller.cz>
References:  <200112292016.fBTKGWR01735@apollo.backplane.com> <Pine.BSF.4.41.0112300114010.48350-100000@prg.traveller.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <machine/atomic.h>) 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020101100822.B96092>