Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.60.2.2 retrieving revision 1.72 diff -u -p -r1.60.2.2 -r1.72 --- src/sys/kern/subr_pool.c 2002/03/16 16:01:50 1.60.2.2 +++ src/sys/kern/subr_pool.c 2002/03/09 01:56:27 1.72 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.60.2.2 2002/03/16 16:01:50 jdolecek Exp $ */ +/* $NetBSD: subr_pool.c,v 1.72 2002/03/09 01:56:27 thorpej Exp $ */ /*- * Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.60.2.2 2002/03/16 16:01:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.72 2002/03/09 01:56:27 thorpej Exp $"); #include "opt_pool.h" #include "opt_poollog.h" @@ -145,6 +145,16 @@ struct pool_item { /* The cache group pool. */ static struct pool pcgpool; +/* The pool cache group. */ +#define PCG_NOBJECTS 16 +struct pool_cache_group { + TAILQ_ENTRY(pool_cache_group) + pcg_list; /* link in the pool cache's group list */ + u_int pcg_avail; /* # available objects */ + /* pointers to the objects */ + void *pcg_objects[PCG_NOBJECTS]; +}; + static void pool_cache_reclaim(struct pool_cache *); static int pool_catchup(struct pool *); @@ -1031,45 +1041,6 @@ pool_put(struct pool *pp, void *v) #endif /* - * Add N items to the pool. - */ -int -pool_prime(struct pool *pp, int n) -{ - struct pool_item_header *ph; - caddr_t cp; - int newpages; - - simple_lock(&pp->pr_slock); - - newpages = roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; - - while (newpages-- > 0) { - simple_unlock(&pp->pr_slock); - cp = pool_allocator_alloc(pp, PR_NOWAIT); - if (__predict_true(cp != NULL)) - ph = pool_alloc_item_header(pp, cp, PR_NOWAIT); - simple_lock(&pp->pr_slock); - - if (__predict_false(cp == NULL || ph == NULL)) { - if (cp != NULL) - pool_allocator_free(pp, cp); - break; - } - - pool_prime_page(pp, cp, ph); - pp->pr_npagealloc++; - pp->pr_minpages++; - } - - if (pp->pr_minpages >= pp->pr_maxpages) - pp->pr_maxpages = pp->pr_minpages + 1; /* XXX */ - - simple_unlock(&pp->pr_slock); - return (0); -} - -/* * Add a page worth of items to the pool. * * Note, we must be called with the pool descriptor LOCKED. @@ -1149,7 +1120,9 @@ pool_prime_page(struct pool *pp, caddr_t * * Note 1, we never wait for memory here, we let the caller decide what to do. * - * Note 2, we must be called with the pool already locked, and we return + * Note 2, this doesn't work with static pools. + * + * Note 3, we must be called with the pool already locked, and we return * with it locked. */ static int @@ -1187,6 +1160,7 @@ pool_catchup(struct pool *pp) void pool_setlowat(struct pool *pp, int n) { + int error; simple_lock(&pp->pr_slock); @@ -1196,7 +1170,7 @@ pool_setlowat(struct pool *pp, int n) : roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; /* Make sure we're caught up with the newly-set low water mark. */ - if (POOL_NEEDS_CATCHUP(pp) && pool_catchup(pp) != 0) { + if (POOL_NEEDS_CATCHUP(pp) && (error = pool_catchup(pp) != 0)) { /* * XXX: Should we log a warning? Should we set up a timeout * to try again in a second or so? The latter could break @@ -1942,9 +1916,9 @@ pool_allocator_alloc(struct pool *org, i TAILQ_INSERT_TAIL(&pa->pa_list, pp, pr_alloc_list); if (pp == org) continue; - simple_unlock(&pa->pa_slock); + simple_unlock(&pa->pa_list); freed = pool_reclaim(pp); - simple_lock(&pa->pa_slock); + simple_lock(&pa->pa_list); } while ((pp = TAILQ_FIRST(&pa->pa_list)) != start && freed == 0);