Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2007 00:07:56 +0200
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        freebsd-arch@FreeBSD.org
Subject:   Re: Lockless uidinfo.
Message-ID:  <20070818220756.GH6498@garage.freebsd.pl>
In-Reply-To: <20070818120056.GA6498@garage.freebsd.pl>
References:  <20070818120056.GA6498@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

--gKijDXBCEH69PxaN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Two more things...

> The patch below remove per-uidinfo locks:
>=20
> 	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 =3D uip->ui_proccnt;
		if (old + diff > max)
			return (0);
	} while (atomic_cmpset_long(&uip->ui_proccnt, old, old + diff) =3D=3D 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.

--=20
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd@FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

--gKijDXBCEH69PxaN
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFGx228ForvXbEpPzQRAj+QAJ9Y4g6hqHOfEhndF71nVdz5e36KRwCgnJPM
R3JbjJEwLidFJy9fJ9FGzP0=
=yQ2d
-----END PGP SIGNATURE-----

--gKijDXBCEH69PxaN--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070818220756.GH6498>