Subject: Re: mbuf external storage sharing
To: Martin Husemann <email@example.com>
From: David Laight <firstname.lastname@example.org>
Date: 10/08/2004 10:51:59
On Fri, Oct 08, 2004 at 10:30:15AM +0200, Martin Husemann wrote:
> On Fri, Oct 08, 2004 at 11:29:33AM +0900, YAMAMOTO Takashi wrote:
> > (it might be good to have MI-exposed atomic_ operations like
> > freebsd and linux. but it's a separate topic.)
> Yes, in deed.
> Are there any archs that can not easily provide macros for those, so
> we could copy the FreeBSD interface?
> Otherwise we'd need a feature test macro and fall back to spinlocks,
> for archs that don't provide the atomice macros.
You can't do atomic increment on sparc, I don't think you can do it on
ppc (also arm - but i've not seem MP arm).
On architectures with an 'atomic exchange woth memory' you can:
For accurate statistics (but not reference counts) you can use an
'atomic exchange with memory' to write the new value, and repeat if the
returned value has changed.
For a reference counts you can use the exchange to write a 'magic' value
(eg ~0) when reading the current value, then write back the new one.
Loop and repeat if the read returns the 'magic value'.
Note that these both (effectively) implement a spin-lock using the
data area as a lock.
For stats, per-processor counts are usually better.
David Laight: email@example.com