From owner-freebsd-arch Sat Dec 29 16:48:15 2001 Delivered-To: freebsd-arch@freebsd.org Received: from prg.traveller.cz (prg.traveller.cz [193.85.2.77]) by hub.freebsd.org (Postfix) with ESMTP id B515F37B405 for ; Sat, 29 Dec 2001 16:48:11 -0800 (PST) Received: from prg.traveller.cz (localhost [127.0.0.1]) by prg.traveller.cz (8.12.1[KQ-CZ](1)/8.12.1/pukvis) with ESMTP id fBU0m7lk049972; Sun, 30 Dec 2001 01:48:07 +0100 (CET) Received: from localhost (mime@localhost) by prg.traveller.cz (8.12.1[KQ-CZ](1)/pukvis) with ESMTP id fBU0m7j7049969; Sun, 30 Dec 2001 01:48:07 +0100 (CET) Date: Sun, 30 Dec 2001 01:48:07 +0100 (CET) From: Michal Mertl To: Matthew Dillon Cc: arch@freebsd.org Subject: Re: 64 bit counters In-Reply-To: <200112292016.fBTKGWR01735@apollo.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 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 <>< 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 ) 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