Lockless uidinfo.

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Aug 18 15:09:01 PDT 2007


Two more things...

> The patch below remove per-uidinfo locks:
> 
> 	http://people.freebsd.org/~pjd/patches/uidinfo_lockless.patch

We could upgrade from lock-free algorithm I used here to wait-free
algorithm, but we don't have atomic_fetchadd_long(). How hard will it be
to implement it?

We could then change:

	do {
		old = uip->ui_proccnt;
		if (old + diff > max)
			return (0);
	} while (atomic_cmpset_long(&uip->ui_proccnt, old, old + diff) == 0);

to something like this:

	if (atomic_fetchadd_long(&uip->ui_proccnt, diff) + diff > max) {
		atomic_subtract_long(&uip->ui_proccnt, diff);
		return (0);
	}

> I needed to change ui_sbsize from rlim_t (64bit) to long, because we
> don't have 64bit atomics on all archs, and because sbsize represents
> size in bytes, it can't go beyond 32bit on 32bit archs (PAE might be a
> bit of a problem).

Currently it's not a problem, because socket buffers have to be mapped
in kernel space, so we can't map more than 4GB. This might be eventually
a problem if we implement unmapped socket buffers and ui_sbsize will be
sum of socket buffers from many processes.

-- 
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/20070818/08af4162/attachment.pgp


More information about the freebsd-arch mailing list