Lockless uidinfo.

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Aug 24 07:10:39 PDT 2007


On Wed, Aug 22, 2007 at 09:02:53PM +0200, Attilio Rao wrote:
> 2007/8/21, Pawel Jakub Dawidek <pjd at freebsd.org>:
> >
> > New patch is here:
> >
> >         http://people.freebsd.org/~pjd/patches/uidinfo_waitfree.patch
> 
> ---  sys/ia64/include/atomic.h.orig
> +++  sys/ia64/include/atomic.h
> @@ -370,4 +370,15 @@
> 
>  #define	atomic_fetchadd_int		atomic_fetchadd_32
> 
> +static __inline u_long
> +atomic_fetchadd_long(volatile u_long *p, u_long v)
> +{
> +	u_long value;
> +
> +	do {
> +		value = *p;
> +	} while (!atomic_cmpset_64(p, value, value + v));
> +	return (value);
> +}
> +
> 
> In cycles like those, as you get spinning, I would arrange things in
> order to do a cpu_spinwait(). Like this:
> 
> for (;;) {
>         value = *p;
>         if (atomic_cmpset_64(p, value, value + v))
>                 break;
>         cpu_spinwait();
> }

In this case there is no difference as this is MI ia64 code and
cpu_spinwait() is defined as /* nothing */ there. As a general rule,
this might be a good idea.

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20070824/95c03553/attachment.pgp


More information about the freebsd-arch mailing list