Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Dec 2001 01:48:07 +0100 (CET)
From:      Michal Mertl <mime@traveller.cz>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        arch@freebsd.org
Subject:   Re: 64 bit counters
Message-ID:  <Pine.BSF.4.41.0112300114010.48350-100000@prg.traveller.cz>
In-Reply-To: <200112292016.fBTKGWR01735@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.
> :
> :--
> :
> :John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
> :"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
>
>     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

With locks (for SMP) both 32 and 64 bit are quite a lot slower (32bit 6.3
and 64 12.3 sec).

I doesn't seem too bad to me, but I do have a problem - I can't implement
real atomic 64 bit operations on an i386. It shouldn't be named atomic_XXX
if it isn't atomic. So that other people don't start to use it on <586
with some variable which changes fast.

What about making the counters not 64 bit, but the size of biggest atomic
type? Something like type u_maxatomic_t which would be 32 bit on <586 and
64 bit otherwise. There would still be problem in determining at compile
time the size but we could choose the safe size if not somewhere defined
otherwise.

I can make changes to my local tree but how should I send them someone for
review? Should I send them to arch? I tried to find the answer to this
question in developers's handbook but didn't find it.


> 					-Matt


-- 
Michal Mertl
mime@traveller.cz



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?Pine.BSF.4.41.0112300114010.48350-100000>