Date: Fri, 28 Dec 2001 23:49:35 -0800 From: Mike Smith <msmith@freebsd.org> To: John Baldwin <jhb@FreeBSD.org> Cc: arch@FreeBSD.org Subject: Re: 64 bit counters Message-ID: <200112290749.fBT7nZF20289@mass.dis.org> In-Reply-To: Your message of "Fri, 28 Dec 2001 23:28:18 PST." <XFMail.011228232818.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> >> > lock; addl %eax,(u_int64_t) > >> > lock; adcl $0,4(u_int64_t) > >> > >> This is all well and good, but not portable. > > > > Aren't all other architectures we support 64 bit? Not PowerPC, for example. > > On i386 even present > > form (32 bit addition) isn't atomic (no lock involved). That's not correct; these counters currently hide behind Giant. > > Anyway the code probably should be rewritten to use mutexes or atomic > > operations or whatever. I'll look at some current sources and maybe I'll > > be able to understand what are all these locks, mutexes, msleep and so on. Mutexes and atomic ops are both *expensive*. The sampled approach I described is relatively cheap (and has a known, fixed cost). > 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 is probably the best way to go, though the cost of the atomic operations makes me twitchy. -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E 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?200112290749.fBT7nZF20289>