diff options
author | dg <dg@FreeBSD.org> | 1995-04-04 02:01:13 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1995-04-04 02:01:13 +0000 |
commit | b3c54e9bcdd8f8a2b50a5f5ccf9a56de409ea1ad (patch) | |
tree | 68f8b7afc54e8eb8e88174f20ec57f9253dd8ae0 /sys/kern/kern_subr.c | |
parent | 27e6941140e02804857a1c772cc325ec59d631e1 (diff) | |
download | FreeBSD-src-b3c54e9bcdd8f8a2b50a5f5ccf9a56de409ea1ad.zip FreeBSD-src-b3c54e9bcdd8f8a2b50a5f5ccf9a56de409ea1ad.tar.gz |
kern_subr.c:
Added a new type to uiomove - "UIO_NOCOPY" which causes it to update
pointers and counts, but doesn't do any data copying. This is needed
for upcoming changes to the way that the vnode pager does its page
outs.
Added a new hash init function call "phashinit" that allocates and
initializes a prime number sized hash table.
vfs_cache.c:
Changed hashing algorithm to use the remainder of dividing by a prime
number to improve the distribution characteristcs. Uses new phashinit
function in kern_subr.c.
Diffstat (limited to 'sys/kern/kern_subr.c')
-rw-r--r-- | sys/kern/kern_subr.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 0c1d970..c191239 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94 - * $Id: kern_subr.c,v 1.3 1994/08/02 07:42:14 davidg Exp $ + * $Id: kern_subr.c,v 1.4 1995/02/12 09:11:47 davidg Exp $ */ #include <sys/param.h> @@ -90,6 +90,8 @@ uiomove(cp, n, uio) else bcopy(iov->iov_base, (caddr_t)cp, cnt); break; + case UIO_NOCOPY: + break; } iov->iov_base += cnt; iov->iov_len -= cnt; @@ -213,3 +215,36 @@ hashinit(elements, type, hashmask) *hashmask = hashsize - 1; return (hashtbl); } + +#define NPRIMES 24 +static int primes[] = { 61, 127, 251, 509, 761, 1021, 1531, 2039, 2557, + 3067, 3583, 4093, 4603, 5119, 5623, 6143, 6653, + 7159, 7673, 8191, 12281, 16381, 24571, 32749 }; + +/* + * General routine to allocate a prime number sized hash table. + */ +void * +phashinit(elements, type, nentries) + int elements, type; + u_long *nentries; +{ + long hashsize; + LIST_HEAD(generic, generic) *hashtbl; + int i; + + if (elements <= 0) + panic("hashinit: bad cnt"); + for (i = 1, hashsize = primes[1]; hashsize <= elements;) { + i++; + if (i == NPRIMES) + break; + hashsize = primes[i]; + } + hashsize = primes[i - 1]; + hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), type, M_WAITOK); + for (i = 0; i < hashsize; i++) + LIST_INIT(&hashtbl[i]); + *nentries = hashsize; + return (hashtbl); +} |